changes
This commit is contained in:
105
app/components/LogIn.vue
Normal file
105
app/components/LogIn.vue
Normal file
@@ -0,0 +1,105 @@
|
||||
<script setup>
|
||||
const emit = defineEmits(["close"]);
|
||||
const store = useStore();
|
||||
|
||||
const userCreds = {
|
||||
email: "user@gmail.com",
|
||||
password: "99171123",
|
||||
};
|
||||
const adminCreds = {
|
||||
email: "admin@gmail.com",
|
||||
password: "1234567890",
|
||||
};
|
||||
|
||||
const formValues = ref(adminCreds);
|
||||
|
||||
function login() {
|
||||
if (formValues.value.email.includes("admin")) store.login = adminRec;
|
||||
else store.login = userRec;
|
||||
window.location.assign("/");
|
||||
}
|
||||
const adminRec = {
|
||||
id: 1,
|
||||
avatar: null,
|
||||
username: "admin",
|
||||
fullname: "Admin",
|
||||
type: 1,
|
||||
type__code: "admin",
|
||||
type__name: "Quản trị hệ thống",
|
||||
is_admin: true,
|
||||
token: "3j3ki2rvy",
|
||||
};
|
||||
const userRec = {
|
||||
id: 2,
|
||||
avatar: null,
|
||||
username: "user",
|
||||
fullname: "User",
|
||||
type: 2,
|
||||
type__code: "user",
|
||||
type__name: "Nhân viên",
|
||||
is_admin: false,
|
||||
token: "b2z0as13x",
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="buttons is-centered is-flex-wrap-nowrap pb-3">
|
||||
<button
|
||||
@click="formValues = userCreds"
|
||||
class="button fs-14 is-fullwidth"
|
||||
:class="formValues.email === userCreds.email && 'is-primary is-light has-text-weight-bold'"
|
||||
>
|
||||
Nhân viên
|
||||
</button>
|
||||
<button
|
||||
@click="formValues = adminCreds"
|
||||
class="button fs-14 is-fullwidth"
|
||||
:class="formValues.email === adminCreds.email && 'is-primary is-light has-text-weight-bold'"
|
||||
>
|
||||
Admin
|
||||
</button>
|
||||
</div>
|
||||
<form>
|
||||
<div class="field">
|
||||
<p class="control has-icons-left has-icons-right">
|
||||
<input
|
||||
class="input"
|
||||
type="email"
|
||||
placeholder="Email"
|
||||
v-model="formValues.email"
|
||||
disabled
|
||||
/>
|
||||
<span class="icon is-small is-left">
|
||||
<SvgIcon v-bind="{ name: 'email.svg', type: 'grey', size: 18 }" />
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="field">
|
||||
<p class="control has-icons-left">
|
||||
<input
|
||||
class="input"
|
||||
type="password"
|
||||
placeholder="Mật khẩu"
|
||||
v-model="formValues.password"
|
||||
disabled
|
||||
/>
|
||||
<span class="icon is-small is-left">
|
||||
<SvgIcon v-bind="{ name: 'password.svg', type: 'grey', size: 18 }" />
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="field is-grouped is-grouped-centered">
|
||||
<p class="control">
|
||||
<button
|
||||
@click="login"
|
||||
type="button"
|
||||
class="button is-success"
|
||||
>
|
||||
Đăng nhập
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user