page for list of rooms

This commit is contained in:
2026-03-19 00:32:48 +00:00
parent 00d9d4023c
commit 8677176706
7 changed files with 83 additions and 11 deletions

View File

@@ -3,23 +3,40 @@ import { ref } from 'vue';
const email = ref<string>("");
const pass = ref<string>("");
const text = ref<string>("");
function login(e: SubmitEvent) {
const emit = defineEmits(['nextPage']);
async function login(e: SubmitEvent) {
text.value = "";
e.preventDefault();
fetch("http://localhost:3000/login", {
const res = await fetch("http://localhost:3000/login", {
method: "POST",
body: JSON.stringify({ email: email.value, pass: pass.value }),
headers: new Headers({'content-type': 'application/json'})
});
if (res.ok) {
cookieStore.set("loggedIn", "true");
emit('nextPage');
} else {
text.value = await res.text();
}
}
function signup(e: Event) {
async function signup(e: Event) {
text.value = "";
e.preventDefault();
fetch("http://localhost:3000/createUser", {
const res = await fetch("http://localhost:3000/createUser", {
method: "POST",
body: JSON.stringify({ email: email.value, pass: pass.value, name: email.value.split("@")[0] }),
headers: new Headers({'content-type': 'application/json'})
});
if (res.ok) {
cookieStore.set("loggedIn", "true");
emit('nextPage');
} else {
text.value = await res.text();
}
}
</script>
@@ -32,5 +49,6 @@ function signup(e: Event) {
<input type="password" id="pass" v-model="pass"/> <br>
<button type="submit">Sign in</button> <br>
<button type="button" @click="signup">Sign up</button>
<p>{{ text }}</p>
</form>
</template>