generateur_v3/frontend/src/routes/room/create/+page.svelte

55 lines
1.2 KiB
Svelte
Raw Normal View History

2023-02-22 12:43:39 +01:00
<script lang="ts">
2023-02-23 17:11:57 +01:00
import { createRoom } from "../../../requests/room.request";
import { getContext } from "svelte";
import { goto } from "$app/navigation";
import InputWithLabel from "../../../components/forms/InputWithLabel.svelte";
2023-02-22 12:43:39 +01:00
2023-02-23 17:11:57 +01:00
let name = "";
let pseudo = "";
const { isAuth } = getContext("auth");
2023-02-22 12:43:39 +01:00
</script>
<div class="container">
2023-02-23 17:11:57 +01:00
<div class="form">
<h1>Créer une salle</h1>
<InputWithLabel label="Nom de la salle" bind:value={name} />
{#if !$isAuth}
<InputWithLabel label="Votre pseudo" bind:value={pseudo} />
{/if}
<button
class="primary-btn"
on:click={() => {
2023-02-22 12:43:39 +01:00
console.log('(NAME)', name)
createRoom({ name }, !$isAuth ? pseudo : null).then((r) => {
if(!$isAuth){
sessionStorage.setItem('reconnect', r.member)
}
goto(`/room/${r.room}`);
});
}}
2023-02-23 17:11:57 +01:00
>
Valider
</button>
</div>
2023-02-22 12:43:39 +01:00
</div>
<style lang="scss">
h1 {
font-size: 3em;
margin-top: 20px;
}
.form {
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
2023-02-23 17:11:57 +01:00
width: max-content;
2023-02-22 12:43:39 +01:00
}
2023-02-23 17:11:57 +01:00
.container {
2023-02-22 12:43:39 +01:00
display: flex;
justify-content: center;
}
</style>