1
1
import React , { useCallback , useContext , useEffect , useState } from "react" ;
2
- import { OfferConstants , parseRequestErrors } from "../Form/OfferUtils" ;
2
+ import { OfferConstants , parseApplyURL , parseRequestErrors } from "../Form/OfferUtils" ;
3
3
import OfferForm from "../Form/form-components/OfferForm" ;
4
4
import { editOffer } from "../../../services/offerService" ;
5
5
import { Redirect , useLocation , useParams } from "react-router-dom" ;
@@ -8,7 +8,6 @@ import useOfferForm from "../../../hooks/useOfferForm";
8
8
import { INITIAL_JOB_DURATION } from "../../../reducers/searchOffersReducer" ;
9
9
import useSession from "../../../hooks/useSession" ;
10
10
import EditOfferSchema from "./EditOfferSchema" ;
11
- import { MailRegex } from "../../../utils/offer/OfferUtils" ;
12
11
13
12
export const EditOfferControllerContext = React . createContext ( ) ;
14
13
@@ -43,18 +42,10 @@ const parseOfferForm = ({
43
42
vacancies : vacancies || "" ,
44
43
description,
45
44
descriptionText : parseDescription ( description ) ,
46
- applyURL : / ^ m a i l t o : / . test ( applyURL ) ? applyURL . substring ( 7 ) : applyURL ,
45
+ applyURL : applyURL . startsWith ( "mailto:" ) ? applyURL . substring ( 7 ) : applyURL ,
47
46
...offer ,
48
47
} ) ;
49
48
50
- const parseApplyURL = ( applyURL ) => {
51
- if ( ! applyURL )
52
- return null ;
53
- if ( MailRegex . test ( applyURL ) && / ^ (? ! m a i l t o : ) / . test ( applyURL ) )
54
- return `mailto:${ applyURL } ` ;
55
- return applyURL ;
56
- } ;
57
-
58
49
export const EditOfferController = ( ) => {
59
50
const { id } = useParams ( ) ;
60
51
const { offer, error : errorOffer , loading : loadingOffer } = useOffer ( id ) ;
0 commit comments