Skip to content

Commit

Permalink
Fixed: create offer form required Apply URl to submit and could not a…
Browse files Browse the repository at this point in the history
…ccess edit offer form of offer without applyURL
  • Loading branch information
FranciscoCardoso913 committed Sep 16, 2023
1 parent 3d0e58a commit d1ae9fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/Offers/Edit/EditOfferForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useContext, useEffect, useState } from "react";
import { OfferConstants, parseRequestErrors } from "../Form/OfferUtils";
import { OfferConstants, parseApplyURL, parseRequestErrors } from "../Form/OfferUtils";
import OfferForm from "../Form/form-components/OfferForm";
import { editOffer } from "../../../services/offerService";
import { Redirect, useLocation, useParams } from "react-router-dom";
Expand Down Expand Up @@ -29,6 +29,7 @@ const parseOfferForm = ({
isPaid,
vacancies,
description,
applyURL,
...offer
}) => ({
jobDuration: [
Expand All @@ -42,6 +43,7 @@ const parseOfferForm = ({
vacancies: vacancies || "",
description,
descriptionText: parseDescription(description),
applyURL: applyURL?.startsWith("mailto:") ? applyURL.substring(7) : applyURL,
...offer,
});

Expand Down Expand Up @@ -108,7 +110,7 @@ export const EditOfferController = () => {
requirements: data.requirements.map((val) => val.value),
isPaid: data.isPaid === "none" ? null : data.isPaid,
jobStartDate: !data.jobStartDate ? null : data.jobStartDate,
applyURL: data.applyURL || null,
applyURL: parseApplyURL(data.applyURL),
jobMinDuration,
jobMaxDuration,
})
Expand Down
3 changes: 2 additions & 1 deletion src/components/Offers/New/CreateOfferForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const CreateOfferController = () => {
(data) => {
params.setLoading(true);
const [jobMinDuration, jobMaxDuration] = data.jobDuration;
const parsedApplyURL = parseApplyURL(data.applyURL);

Check warning on line 18 in src/components/Offers/New/CreateOfferForm.js

View check run for this annotation

Codecov / codecov/patch

src/components/Offers/New/CreateOfferForm.js#L18

Added line #L18 was not covered by tests
newOffer({
...data,
vacancies: data.vacancies || undefined,
Expand All @@ -23,7 +24,7 @@ export const CreateOfferController = () => {
isPaid: data.isPaid === "none" ? undefined : data.isPaid,
jobStartDate: !data.jobStartDate ? undefined : data.jobStartDate,
owner: data.owner || params.company,
applyURL: parseApplyURL(data.applyURL),
applyURL: !parsedApplyURL ? undefined : parsedApplyURL,

Check warning on line 27 in src/components/Offers/New/CreateOfferForm.js

View check run for this annotation

Codecov / codecov/patch

src/components/Offers/New/CreateOfferForm.js#L27

Added line #L27 was not covered by tests
jobMinDuration,
jobMaxDuration,
})
Expand Down

0 comments on commit d1ae9fc

Please sign in to comment.