|
|
|
@@ -10,15 +10,8 @@ import { motion } from 'framer-motion'; |
|
|
|
import ReactGA from 'react-ga4'; |
|
|
|
import MyDropzone from './MyDropzone'; |
|
|
|
import HashPositions from './HashPositions'; |
|
|
|
<<<<<<< HEAD |
|
|
|
import useDataApi from '../../hooks/useDataApi'; |
|
|
|
import axios from 'axios'; |
|
|
|
|
|
|
|
const api_url = 'http://localhost:1337'; |
|
|
|
======= |
|
|
|
import ReCAPTCHA from 'react-google-recaptcha'; |
|
|
|
import axios from 'axios'; |
|
|
|
>>>>>>> staging |
|
|
|
|
|
|
|
export default function JobForm(props) { |
|
|
|
const [sucMsg, setSucMsg] = useState(false); |
|
|
|
@@ -97,15 +90,7 @@ export default function JobForm(props) { |
|
|
|
initialValues={jobForm} |
|
|
|
validationSchema={validationSchema} |
|
|
|
onChange={changeFormHandler} |
|
|
|
<<<<<<< HEAD |
|
|
|
onSubmit={values => { |
|
|
|
|
|
|
|
setSucMsg(false); |
|
|
|
|
|
|
|
//prep file |
|
|
|
======= |
|
|
|
onSubmit={async values => { |
|
|
|
>>>>>>> staging |
|
|
|
const prepFile = async file => { |
|
|
|
if (file.size >= 2000000) { |
|
|
|
setErrorMsg('File too large!'); |
|
|
|
@@ -130,89 +115,6 @@ export default function JobForm(props) { |
|
|
|
}; |
|
|
|
}); |
|
|
|
}; |
|
|
|
<<<<<<< HEAD |
|
|
|
|
|
|
|
let data = {}; |
|
|
|
|
|
|
|
// &filters[SubmitDate][$gte]=${period} |
|
|
|
|
|
|
|
//const hookdata = useDataApi(`${api_url}/api/job-submissions?filters[Email][$eq]=${values.email}&filters[SubmitDate][$gte]=${period}`); |
|
|
|
const fetchData = async () => { |
|
|
|
axios.get(`${api_url}/api/job-submissions?filters[Email][$eq]=${values.email}`) |
|
|
|
.then((res) => { |
|
|
|
data = res.data.data[0]; |
|
|
|
console.log(data); |
|
|
|
const submitDate = new Date(data.attributes.SubmitDate); |
|
|
|
const now = new Date(); |
|
|
|
if ((now.getMonth() - submitDate.getMonth()) < 1) |
|
|
|
{ |
|
|
|
setErrorMsg('You Already sent an email'); |
|
|
|
return false |
|
|
|
} |
|
|
|
else { |
|
|
|
|
|
|
|
fetch(`${api_url}/api/job-submissions/${data.id}`, { |
|
|
|
method: "PUT", |
|
|
|
headers: { |
|
|
|
"Content-type": "application/json; charset=UTF-8", |
|
|
|
}, |
|
|
|
body: JSON.stringify({ |
|
|
|
data: { |
|
|
|
SubmitDate: now, |
|
|
|
} |
|
|
|
}) |
|
|
|
}).then(r => r.json()).then(() => { |
|
|
|
setErrorMsg(''); |
|
|
|
return true; |
|
|
|
}).catch(err => { |
|
|
|
return false |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
console.log(fetchData()); |
|
|
|
|
|
|
|
if (jobForm.file === '') { |
|
|
|
setErrorMsg('CV is Required'); |
|
|
|
} else { |
|
|
|
if (fetchData()) { |
|
|
|
|
|
|
|
|
|
|
|
prepFile(jobForm.file).then(res => { |
|
|
|
const newtemplateParams = { |
|
|
|
Position: values.position, |
|
|
|
Other: values.other, |
|
|
|
Firstname: values.firstName, |
|
|
|
Lastname: values.lastName, |
|
|
|
Coverletter: values.coverLetter, |
|
|
|
Email: values.email, |
|
|
|
Link: values.link, |
|
|
|
File: res, |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// emailjs |
|
|
|
// .send( |
|
|
|
// process.env.REACT_APP_SERVICE_ID, |
|
|
|
// process.env.REACT_APP_JOB_TEMPLATE_ID, |
|
|
|
// newtemplateParams, |
|
|
|
// process.env.REACT_APP_USER_ID, |
|
|
|
// ) |
|
|
|
// .then( |
|
|
|
// result => { |
|
|
|
// console.log(result.text); |
|
|
|
// setSucMsg(true); |
|
|
|
// }, |
|
|
|
// error => { |
|
|
|
// console.log(error.text); |
|
|
|
// }, |
|
|
|
// ); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
======= |
|
|
|
if ( |
|
|
|
selectedPosition === '' || |
|
|
|
(otherInputState === false && values.other === '') |
|
|
|
@@ -264,7 +166,6 @@ export default function JobForm(props) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
>>>>>>> staging |
|
|
|
} |
|
|
|
ReactGA.event('contact', { |
|
|
|
category: 'Contact', |