diff --git a/.gitignore b/.gitignore index d39eb1d2a80ebaf318efda96ed92ee8a35d18ad1..5eab1a953054b7ff8f1351fd806642aab6872ac2 100644 --- a/.gitignore +++ b/.gitignore @@ -138,4 +138,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* yarn.lock -.docz/ \ No newline at end of file +.docz/ +._.DS_Store \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 89d8e2f8d447669a3cf0b006cab7d605b6a7d70c..eff19068d86ecac464c94e0705e65735672d1df3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,13 +2,14 @@ import React, { FC } from 'react'; import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'; import { HomePage } from './components/HomePage/HomePage'; import { AuthUser } from './components/AuthUser/AuthUser'; +import { LandingPage } from './components/LandingPage/LandingPage'; export const App: FC = () => ( <Router> <div data-testid="App"> <Switch> <Route path="/auth" component={AuthUser} /> - <Route exact path="/" component={HomePage} /> + <Route exact path="/" component={LandingPage} /> </Switch> </div> </Router> diff --git a/src/components/AuthUser/AuthUser.tsx b/src/components/AuthUser/AuthUser.tsx index 9f819e776c7333e9acaeafa351bd24c87e125556..52b4a2b1c270be80ca3598d841c40ec4c6f1e0a5 100644 --- a/src/components/AuthUser/AuthUser.tsx +++ b/src/components/AuthUser/AuthUser.tsx @@ -7,7 +7,9 @@ export const AuthUser: FC = () => { useEffect(() => { axios .get('api/web/csrf') - .then((response) => console.log(response)) + .then((response) => + sessionStorage.setItem('CSRF_TOKEN', response.data.token), + ) .catch((error) => console.log(error)); }, []); return ( diff --git a/src/components/AuthUser/SignInForm/InputField.tsx b/src/components/AuthUser/SignInForm/InputField.tsx index a2dc677dcc785b87fc28e94d1cc1a40b6cc4c065..fc11e0adc031f0d0c1a686a7b7b3052f7ba0dda9 100644 --- a/src/components/AuthUser/SignInForm/InputField.tsx +++ b/src/components/AuthUser/SignInForm/InputField.tsx @@ -6,10 +6,12 @@ type Props = { label: string; error: boolean; errorMessage: string; + value: string; + onChange: any; }; export const InputField: FC<Props> = (props: Props) => { - const { id, label, error, errorMessage } = props; + const { id, label, error, errorMessage, onChange, value } = props; return ( <TextField variant="outlined" @@ -19,6 +21,8 @@ export const InputField: FC<Props> = (props: Props) => { id={id} label={label} name={id} + onChange={onChange} + value={value} autoComplete={id} autoFocus error={error} diff --git a/src/components/AuthUser/SignInForm/SignInForm.tsx b/src/components/AuthUser/SignInForm/SignInForm.tsx index 585c6b8fa3c5dd512672cdd89de3f47ac60cfd8f..5aae7b9363442f5acd2a4cf1c6460961c94ee207 100644 --- a/src/components/AuthUser/SignInForm/SignInForm.tsx +++ b/src/components/AuthUser/SignInForm/SignInForm.tsx @@ -1,4 +1,5 @@ import React, { FC } from 'react'; +import axios from 'axios'; import { useForm, Controller, appendErrors } from 'react-hook-form'; import { useIntl } from 'react-intl'; import { createStyles, makeStyles, Theme } from '@material-ui/core/styles'; @@ -40,7 +41,17 @@ export const SignInForm: FC = () => { }); const onSubmit: any = (values: FormData) => { - alert(JSON.stringify(values)); + axios + .post('/api/web/login', { + values, + token: sessionStorage.getItem('CSRF_TOKEN'), + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.log(error); + }); }; const intl = useIntl(); const classes = useStyles(); @@ -63,11 +74,13 @@ export const SignInForm: FC = () => { message: intl.formatMessage({ id: 'email' }), }, }} - render={() => ( + render={({ onChange, value }) => ( <InputField id="email" + value={value} + onChange={onChange} label={intl.formatMessage({ id: 'email' })} - error={Boolean(errors.email)} + error={!!errors.email} errorMessage={intl.formatMessage({ id: 'error' })} /> )} @@ -76,17 +89,18 @@ export const SignInForm: FC = () => { <Controller name="password" control={control} - defaultValues rules={{ minLength: 8, maxLength: 60, required: { value: true, message: 'You must enter your name' }, }} - render={() => ( + render={({ onChange, value }) => ( <InputField id="password" + value={value} + onChange={onChange} label="Password" - error={Boolean(errors.password)} + error={!!errors.password} errorMessage="Incorrect entry." /> )} diff --git a/src/components/LandingPage/LandingPage.tsx b/src/components/LandingPage/LandingPage.tsx new file mode 100644 index 0000000000000000000000000000000000000000..51f422645bf8db6a8990794dfdbc6cfb6fc97b05 --- /dev/null +++ b/src/components/LandingPage/LandingPage.tsx @@ -0,0 +1,41 @@ +import React, { FC, useEffect } from 'react'; + +export const LandingPage: FC = () => ( + <> + <section> + <h2>What is MoveAid?</h2> + + <p> + MoveAid is a project born in order to satisfy a specific problem. There + are many senior citizens who are not able to drive and move from a place + to another easily, because of this they sometimes need to take private + Taxis or public means of transport which could be expensive and not + simple. MoveAid wants to be the solution to this problem offering free + drives (carried out by voulunteers) for those who need them to reach + medical visit, to go to the supermarket or to satisfy any other need. + </p> + </section> + + <section> + <h2>How will MoveAid work?</h2> + + <p> + MoveAid will be the platform that will allow people to ask for a drive + (either by phone or online) and organizations of voulenteers to organise + and accept drives. + </p> + </section> + + <p> + <br /> + </p> + + <footer> + <p> + Authors: Alberto Defendi, Andrea Esposito, Marco Marinello, Francesco + Mazzini + </p> + <p>© 2021 - All right reserved</p> + </footer> + </> +); diff --git a/src/components/LandingPage/TeamPage.tsx b/src/components/LandingPage/TeamPage.tsx new file mode 100644 index 0000000000000000000000000000000000000000..58d850befb0555629c9a8391f6176e57ec393e03 --- /dev/null +++ b/src/components/LandingPage/TeamPage.tsx @@ -0,0 +1,86 @@ +import React, { FC, useEffect } from 'react'; + +export const TeamPage: FC = () => ( + <> + <section> + <h2>These are the students of the MoveAid project</h2> + + <div> + <h3>Alberto Defendi</h3> + <table> + <tr> + <td> </td> + <td> + <p> + Age: 19 <br /> + Role: Front End Developer + <br /> + Hobbys: Sports, maths + <br /> + </p> + </td> + </tr> + </table> + </div> + + <div> + <h3>Andrea Esposito</h3> + <table> + <tr> + <td> </td> + <td> + <p> + Age: 19 <br /> + Role: xxxxx + <br /> + Hobbys: xxxxxxxxx + <br /> + </p> + </td> + </tr> + </table> + </div> + + <div> + <h3>Marco Marinello</h3> + <table> + <tr> + <td> </td> + <td> + <p> + Age: 19 <br /> + Role: xxxxx + <br /> + Hobbys: xxxxxxxxx + <br /> + </p> + </td> + </tr> + </table> + </div> + + <div> + <h3>Francesco Mazzini</h3> + <table> + <tr> + <td> </td> + <td> + <p> + <strong>Age:</strong> 19 <br /> + <br /> + <strong>Role:</strong> Front End Developer + <br /> + <br /> + <strong>Hobbys:</strong> I like Graphic and Programing. + <br /> + I also like playing videogames, hanging out <br /> + with friends, watching tv series and <br /> + training in gym! + </p> + </td> + </tr> + </table> + </div> + </section> + </> +); diff --git a/src/components/LandingPage/assets/alberto.png b/src/components/LandingPage/assets/alberto.png new file mode 100644 index 0000000000000000000000000000000000000000..a4030b2bda405381ab60d5ba68b7ea7c057ebefe Binary files /dev/null and b/src/components/LandingPage/assets/alberto.png differ diff --git a/src/components/LandingPage/assets/logo04Circle.png b/src/components/LandingPage/assets/logo04Circle.png new file mode 100644 index 0000000000000000000000000000000000000000..4e5a76b9f51d9580a7f6b6b78f076f0a4a821f48 Binary files /dev/null and b/src/components/LandingPage/assets/logo04Circle.png differ diff --git a/src/components/LandingPage/assets/pp.jpg b/src/components/LandingPage/assets/pp.jpg new file mode 100644 index 0000000000000000000000000000000000000000..593205f4d623a459904abdcfb13c8517e4ccf666 Binary files /dev/null and b/src/components/LandingPage/assets/pp.jpg differ