Skip to content

Commit

Permalink
fix(pencil): activating join button when roomName is valide
Browse files Browse the repository at this point in the history
  • Loading branch information
youssefElMkhantar committed Mar 22, 2024
1 parent 52bc11d commit a306054
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
21 changes: 16 additions & 5 deletions src/pages/home/AuthModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export default function AuthModal(props: AuthModalProps) {

const navigate = useNavigate();

function handle() {
function handle(e: any) {
e.preventDefault();
if (!props.roomName) {
const room = generateRoomName();
props.setRoomName(room);
Expand Down Expand Up @@ -118,9 +119,14 @@ export default function AuthModal(props: AuthModalProps) {
}, []);

const agentConnect = (room: string) => {
fetch(`${import.meta.env.VITE_BASE_URL}/authentication/login_authorize?room=${room}`, {
redirect: 'manual',
}).then(res => {
fetch(
`${
import.meta.env.VITE_BASE_URL
}/authentication/login_authorize?room=${room}`,
{
redirect: 'manual',
}
).then(res => {
if (res.type === 'opaqueredirect') {
window.location.href = res.url;
} else {
Expand Down Expand Up @@ -222,7 +228,12 @@ export default function AuthModal(props: AuthModalProps) {
) : null}
</modal.Component>
<div className={styles.buttons}>
<Button onClick={handle} className={styles.button}>
<Button
onClick={handle}
className={styles.button}
disabled={!roomNameConstraintOk(props.roomName)}
type="submit"
>
Rejoindre ou créer
</Button>
<br />
Expand Down
5 changes: 3 additions & 2 deletions src/pages/home/HomeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ function HomeForm(props: AuthModalProps) {
/>
<Button
className={styles.plusButton}
onClick={() => {
onClick={e => {
e.preventDefault();
verifyAndSetVAlue(generateRoomName());
}}
>
Expand Down Expand Up @@ -271,4 +272,4 @@ function generateRoomName() {
Math.floor(Math.random() * 10) +
Math.floor(Math.random() * 10)
);
}
}

0 comments on commit a306054

Please sign in to comment.