Sfoglia il codice sorgente

;fsdedqwdwedfqw

blog-new
Pavle Golubovic 3 anni fa
parent
commit
3de87cb7f9
2 ha cambiato i file con 30 aggiunte e 137 eliminazioni
  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 Vedi File

@@ -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',

+ 30
- 38
frontend/src/pages/Home.jsx Vedi File

@@ -32,47 +32,39 @@ import MapDilig from '../components/Map';
import useDataApi from '../hooks/useDataApi';
import useAnalytics from '../hooks/useAnalytics';
import ReactHelmet from '../components/shared/ReactHelmet';
import { strapiApiBuilder } from '../utils/strapiApiBuilder';

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 }) {
const [cnt, setCnt] = useState('');
@@ -82,7 +74,7 @@ export default function Home({ forwardedRef }) {
const [contactRef, setRef] = useState(forwardedRef);

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);


Loading…
Annulla
Salva