Selaa lähdekoodia

;fsdedqwdwedfqw

blog-new
Pavle Golubovic 3 vuotta sitten
vanhempi
commit
3de87cb7f9
2 muutettua tiedostoa jossa 30 lisäystä ja 137 poistoa
  1. 0
    99
      frontend/src/components/shared/JobForm.jsx
  2. 30
    38
      frontend/src/pages/Home.jsx

+ 0
- 99
frontend/src/components/shared/JobForm.jsx Näytä tiedosto

import ReactGA from 'react-ga4'; import ReactGA from 'react-ga4';
import MyDropzone from './MyDropzone'; import MyDropzone from './MyDropzone';
import HashPositions from './HashPositions'; 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 ReCAPTCHA from 'react-google-recaptcha';
import axios from 'axios'; import axios from 'axios';
>>>>>>> staging


export default function JobForm(props) { export default function JobForm(props) {
const [sucMsg, setSucMsg] = useState(false); const [sucMsg, setSucMsg] = useState(false);
initialValues={jobForm} initialValues={jobForm}
validationSchema={validationSchema} validationSchema={validationSchema}
onChange={changeFormHandler} onChange={changeFormHandler}
<<<<<<< HEAD
onSubmit={values => {

setSucMsg(false);

//prep file
=======
onSubmit={async values => { onSubmit={async values => {
>>>>>>> staging
const prepFile = async file => { const prepFile = async file => {
if (file.size >= 2000000) { if (file.size >= 2000000) {
setErrorMsg('File too large!'); setErrorMsg('File too large!');
}; };
}); });
}; };
<<<<<<< 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 ( if (
selectedPosition === '' || selectedPosition === '' ||
(otherInputState === false && values.other === '') (otherInputState === false && values.other === '')
} }
} }
} }
>>>>>>> staging
} }
ReactGA.event('contact', { ReactGA.event('contact', {
category: 'Contact', category: 'Contact',

+ 30
- 38
frontend/src/pages/Home.jsx Näytä tiedosto

import useDataApi from '../hooks/useDataApi'; import useDataApi from '../hooks/useDataApi';
import useAnalytics from '../hooks/useAnalytics'; import useAnalytics from '../hooks/useAnalytics';
import ReactHelmet from '../components/shared/ReactHelmet'; import ReactHelmet from '../components/shared/ReactHelmet';
import { strapiApiBuilder } from '../utils/strapiApiBuilder';


const api_url = process.env.REACT_APP_API_URL; const api_url = process.env.REACT_APP_API_URL;
// const fieldArray = [
// 'landing',
// 'why',
// 'why.heading',
// 'why.card_left.icon',
// 'why.card_mid.icon',
// 'why.card_right.icon',
// 'landing.heading',
// 'SEO',
// 'SEO.metaSocial',
// 'SEO.metaImage',
// 'SEO.metaSocial.image',
// ];


const strapiPopulate = [
'Heading',
'Heading.subtitle',
'Heading.title',
'WhyUsHeading',
'Cards',
'Cards.Card1',
'Cards.Card1.Icon',
'Cards.Card2',
'Cards.Card2.Icon',
'Cards.Card3',
'Cards.Card3.Icon',
'HeroNumbers',
'HeroNumbers.number',
const fieldArray = [
'landing',
'why',
'why.heading',
'why.card_left.icon',
'why.card_mid.icon',
'why.card_right.icon',
'landing.heading',
'SEO',
'SEO.metaSocial',
'SEO.metaImage',
'SEO.metaSocial.image',
]; ];


const stringBuilder = () => {
let stringQuery = '';
strapiPopulate.map((item, index) => {
if (index !== 0) stringQuery += '&';
stringQuery += `populate=${item}`;
});
return stringQuery;
};

// const strapiPopulate = [
// 'Heading',
// 'Heading.subtitle',
// 'Heading.title',
// 'WhyUsHeading',
// 'Cards',
// 'Cards.Card1',
// 'Cards.Card1.Icon',
// 'Cards.Card2',
// 'Cards.Card2.Icon',
// 'Cards.Card3',
// 'Cards.Card3.Icon',
// 'HeroNumbers',
// 'HeroNumbers.number',
// ];


export default function Home({ forwardedRef }) { export default function Home({ forwardedRef }) {
const [cnt, setCnt] = useState(''); const [cnt, setCnt] = useState('');
const [contactRef, setRef] = useState(forwardedRef); const [contactRef, setRef] = useState(forwardedRef);


const [{ data, isLoading, isError }, doFetch] = useDataApi( const [{ data, isLoading, isError }, doFetch] = useDataApi(
`${api_url}/api/w-home-page?${stringBuilder()}`,
`${api_url}/api/w-home-page?${stringBuilder(fieldArray)}`,
); );
const [contactElement, setContactElement] = useState(0); const [contactElement, setContactElement] = useState(0);



Loading…
Peruuta
Tallenna