Skip to content

Commit

Permalink
create attendee call
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Žingor committed Dec 21, 2022
1 parent 6e6ca35 commit cc38ce0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/app/components/App/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import * as Yup from 'yup';
import {DesktopDatePicker} from '@mui/x-date-pickers/DesktopDatePicker';
import {LocalizationProvider} from '@mui/x-date-pickers/LocalizationProvider';
import {AdapterDayjs} from '@mui/x-date-pickers/AdapterDayjs';
import axios from 'axios';
import moment from 'moment';

import {Dropzone} from './Dropzone';

Expand Down Expand Up @@ -70,6 +72,7 @@ const FormSchema = Yup.object().shape({
const Form: React.FC = () => {
const [, setFileSelected] = React.useState<File>();
const [imagePreview, setImagePreview] = React.useState<string>('');
console.log(imagePreview);

return (
<FormContainer>
Expand All @@ -78,10 +81,18 @@ const Form: React.FC = () => {
initialValues={{email: '', name: '', info: '', birthdate: new Date()}}
validationSchema={FormSchema}
onSubmit={(values, {setSubmitting}) => {
setTimeout(() => {
alert(JSON.stringify(values, null, 2));
setSubmitting(false);
}, 400);
axios.post('http://localhost:8081/attendees', {
id: 'uuid' + Math.floor(Math.random() * 1000),
name: values.name,
'e-mail': values.email,
birthdate: (moment(values.birthdate.toString())).format('D.M.YYYY').toString(),
moreInfo: values.info,
file: imagePreview
}).catch( (error) => {
console.log(error);
});

setSubmitting(false);
}}
>
{({
Expand Down
10 changes: 10 additions & 0 deletions src/app/models/App/Attendee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
interface Attendee {
id: string;
name: string;
'e-mail': string;
birthdate: string;
moreInfo: string;
file: string;
}

export {Attendee};

0 comments on commit cc38ce0

Please sign in to comment.