-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthForm.vue
More file actions
66 lines (61 loc) · 1.61 KB
/
AuthForm.vue
File metadata and controls
66 lines (61 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!-- This component represents the login/sign-up card with a form. -->
<script setup lang="ts">
import { ref } from "vue";
import { ElNotification } from "element-plus";
const props = defineProps({
hasPasswordConfirm: Boolean,
headerText: {
type: String,
required: true,
},
submitText: {
type: String,
required: true,
},
});
const emit = defineEmits(["submitted"]);
const loginData = ref({
email: "",
password: "",
passwordConfirm: "",
});
function submit() {
if (
props.hasPasswordConfirm &&
loginData.value.password !== loginData.value.passwordConfirm
) {
ElNotification({
title: "Error",
message: "Passwords must match",
type: "error",
});
} else {
emit("submitted", loginData.value);
}
}
</script>
<template>
<ElCard
shadow="never"
class="w-96 px-5 rounded-lg my-10 mx-auto text-center bg-neutral-100"
>
<h1 class="text-2xl font-bold">{{ headerText }}</h1>
Welcome to the Brain Game Center
<div class="p-2"></div>
<ElForm label-position="top" @submit.prevent="submit">
<ElFormItem label="Email">
<ElInput v-model="loginData.email" />
</ElFormItem>
<ElFormItem label="Password">
<ElInput v-model="loginData.password" type="password" />
</ElFormItem>
<ElFormItem v-if="hasPasswordConfirm" label="Re-enter Password">
<ElInput v-model="loginData.passwordConfirm" type="password" />
</ElFormItem>
<ElButton type="primary" class="bg-sky-800" @click="submit">
{{ submitText }}
</ElButton>
<input type="submit" hidden />
</ElForm>
</ElCard>
</template>