diff --git a/src/components/Offers/Edit/EditOfferForm.js b/src/components/Offers/Edit/EditOfferForm.js index b014d64c..4a891566 100644 --- a/src/components/Offers/Edit/EditOfferForm.js +++ b/src/components/Offers/Edit/EditOfferForm.js @@ -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"; @@ -29,6 +29,7 @@ const parseOfferForm = ({ isPaid, vacancies, description, + applyURL, ...offer }) => ({ jobDuration: [ @@ -42,6 +43,7 @@ const parseOfferForm = ({ vacancies: vacancies || "", description, descriptionText: parseDescription(description), + applyURL: applyURL?.startsWith("mailto:") ? applyURL.substring(7) : applyURL, ...offer, }); @@ -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, }) diff --git a/src/components/Offers/New/CreateOfferForm.js b/src/components/Offers/New/CreateOfferForm.js index c45c4e79..619979f6 100644 --- a/src/components/Offers/New/CreateOfferForm.js +++ b/src/components/Offers/New/CreateOfferForm.js @@ -15,6 +15,7 @@ export const CreateOfferController = () => { (data) => { params.setLoading(true); const [jobMinDuration, jobMaxDuration] = data.jobDuration; + const parsedApplyURL = parseApplyURL(data.applyURL); newOffer({ ...data, vacancies: data.vacancies || undefined, @@ -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, jobMinDuration, jobMaxDuration, })