Validation flow seems OK.

This commit is contained in:
Eric van der Vlist 2023-03-04 10:54:32 +01:00
parent 04cd163906
commit 24fb46c0fb
1 changed files with 98 additions and 33 deletions

View File

@ -1,4 +1,11 @@
import { Box, Button, TextField } from '@suid/material';
import {
Alert,
Box,
Button,
Modal,
TextField,
Typography,
} from '@suid/material';
import { Component, createEffect, createSignal, Show } from 'solid-js';
import Dialog from '../dialog';
@ -50,7 +57,12 @@ const Invitation: Component<props> = (props) => {
`${invitation().url.href}/${invitation().code}`
);
const codeData = await response.json();
setInvitation({ ...invitation(), codeData });
setInvitation({
...invitation(),
codeData,
failure: codeData.response !== 'OK',
success: codeData.response === 'OK',
});
} catch (error) {}
};
@ -58,39 +70,92 @@ const Invitation: Component<props> = (props) => {
setInvitation({ ...invitation(), code: event.target.value });
};
const handleModalFailureClose = () => {
setInvitation({ ...invitation(), failure: undefined });
};
const handleModalSuccessClose = () => {
setInvitation(false);
};
return (
<Dialog
open={!!invitation()}
fullScreen={false}
closeHandler={closeHandler}
title='Invitation'
>
<Box
component='form'
sx={{
width: '100%',
'& .MuiTextField-root': { m: 1, width: '100%' },
paddingTop: '5px',
}}
noValidate
autoComplete='off'
<>
<Dialog
open={!!invitation()}
fullScreen={false}
closeHandler={closeHandler}
title='Invitation'
>
<p>
Pour configurer cette application en tant que "{invitation().data.id}
", copier le code qui vous a été envoyé par mail à l'adresse "
{invitation().data.mail}" :{' '}
</p>
<TextField
required
label='Code'
type='number'
onChange={codeChangeHandler}
/>
<Button variant='contained' onClick={submitHandler}>
OK
</Button>
</Box>
</Dialog>
<Box
component='form'
sx={{
width: '100%',
'& .MuiTextField-root': { m: 1, width: '100%' },
paddingTop: '5px',
}}
noValidate
autoComplete='off'
>
<p>
Pour configurer cette application en tant que "
{invitation().data.id}
", copier le code qui vous a été envoyé par mail à l'adresse "
{invitation().data.mail}" :{' '}
</p>
<TextField
required
label='Code'
type='number'
onChange={codeChangeHandler}
/>
<Button variant='contained' onClick={submitHandler}>
OK
</Button>
</Box>
</Dialog>
<Modal
open={!!invitation().failure}
onClose={handleModalFailureClose}
aria-labelledby='modal-modal-title'
aria-describedby='modal-modal-description'
>
<Box
sx={{
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: 400,
border: '2px solid #000',
boxShadow: '24px',
p: 4,
}}
>
<Alert severity='error'>Le code est erroné !</Alert>
</Box>
</Modal>{' '}
<Modal
open={!!invitation().success}
onClose={handleModalSuccessClose}
aria-labelledby='modal-modal-title'
aria-describedby='modal-modal-description'
>
<Box
sx={{
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: 400,
border: '2px solid #000',
boxShadow: '24px',
p: 4,
}}
>
<Alert severity='success'>C'est tout bon !</Alert>
</Box>
</Modal>
</>
);
};