From d1ae9fcc97faa43d5c55de2614753c6f33c26ae8 Mon Sep 17 00:00:00 2001 From: Francisco Cardoso Date: Sat, 16 Sep 2023 22:19:07 +0100 Subject: [PATCH] Fixed: create offer form required Apply URl to submit and could not access edit offer form of offer without applyURL --- src/components/Offers/Edit/EditOfferForm.js | 6 ++++-- src/components/Offers/New/CreateOfferForm.js | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) 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, })