Skip to content

Commit

Permalink
fix(pencil): onSubmit fix
Browse files Browse the repository at this point in the history
  • Loading branch information
youssef.el-mkhantar committed Mar 26, 2024
1 parent 8ff0c17 commit b93624c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 56 deletions.
57 changes: 2 additions & 55 deletions src/pages/home/AuthModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,57 +53,9 @@ export default function AuthModal(props: AuthModalProps) {
props.setOpen(true);
};

<<<<<<< HEAD
useEffect(() => {
props.openModal ? modal.open() : null;
}, [props.openModal]);
=======
const navigate = useNavigate();

function handle(e: any) {
e.preventDefault();
if (!props.roomName) {
const room = generateRoomName();
props.setRoomName(room);
if (roomNameConstraintOk(room)) {
api.get('/authentication/whereami').then(res => {
if (res.data.toLowerCase() == 'internet') {
if (!props.authenticated) {
modal.open();
}
if (props.authenticated) {
props.joinConference(room);
}
}
if (res.data.toLowerCase() !== 'internet') {
props.joinConference(room);
}
});
}
} else if (roomNameConstraintOk(props.roomName)) {
api
.get('/roomExists/' + props.roomName)
.then(res => {
return navigate('/' + props.roomName);
})
.catch(err => {
api.get('/authentication/whereami').then(res => {
if (res.data.toLowerCase() == 'internet') {
if (!props.authenticated) {
return modal.open();
}
if (props.authenticated) {
return props.joinConference(props.roomName);
}
}
if (res.data.toLowerCase() !== 'internet') {
return props.joinConference(props.roomName);
}
});
});
}
}
>>>>>>> a306054b2c0e02f9d605371837dbce6a817ff84f

useEffect(() => {
props.setIsWhitelisted(null);
Expand Down Expand Up @@ -211,6 +163,7 @@ export default function AuthModal(props: AuthModalProps) {
<Button
className={styles.modalButtons}
onClick={() => mailSender(props.roomName)}
type="button"
>
<span className={styles.hidden} id="input-desc-error">
text
Expand All @@ -234,17 +187,10 @@ export default function AuthModal(props: AuthModalProps) {
</modal.Component>
<div className={styles.buttons}>
<Button
<<<<<<< HEAD
// onClick={handle}
type="submit"
className={styles.button}
disabled={!roomNameConstraintOk(props.roomName)}
=======
onClick={handle}
className={styles.button}
disabled={!roomNameConstraintOk(props.roomName)}
type="submit"
>>>>>>> a306054b2c0e02f9d605371837dbce6a817ff84f
>
Rejoindre ou créer
</Button>
Expand All @@ -256,6 +202,7 @@ export default function AuthModal(props: AuthModalProps) {
className={styles.button}
nativeButtonProps={{ id: 'copyButton' }}
onClick={copyLink}
type="button"
>
Copier le lien
</Button>
Expand Down
4 changes: 3 additions & 1 deletion src/pages/home/HomeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function HomeForm(props: AuthModalProps) {
api.get('/authentication/whereami').then(res => {
if (res.data.toLowerCase() == 'internet') {
if (!props.authenticated) {
return setOpenModal(true);
setOpenModal(true);
}
if (props.authenticated) {
return props.joinConference(props.roomName);
Expand All @@ -85,6 +85,7 @@ function HomeForm(props: AuthModalProps) {
});
});
}
setOpenModal(false);
}

const change = (e: string) => {
Expand Down Expand Up @@ -274,6 +275,7 @@ function HomeForm(props: AuthModalProps) {
className={styles.plusButton}
onClick={() => props.setButtons(!props.buttons)}
nativeButtonProps={{ id: 'plusButton' }}
type="button"
>
{props.buttons ? down : up}
</Button>
Expand Down

0 comments on commit b93624c

Please sign in to comment.