Work on login
This commit is contained in:
parent
3800df1b40
commit
363d1269f2
|
@ -1,7 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { InputMenuItem } from "@nuxt/ui";
|
import type { InputMenuItem } from "@nuxt/ui";
|
||||||
import hadithaApi from "../../apis/hadithaApi";
|
import hadithaApi from "../../apis/hadithaApi";
|
||||||
import type { HadithResponseModel } from "../../types/hadithType";
|
|
||||||
import { useStorage } from "@vueuse/core";
|
import { useStorage } from "@vueuse/core";
|
||||||
import * as z from "zod";
|
import * as z from "zod";
|
||||||
import type { FormSubmitEvent } from "@nuxt/ui";
|
import type { FormSubmitEvent } from "@nuxt/ui";
|
||||||
|
@ -35,6 +34,7 @@ const search_type = ref("normal");
|
||||||
const type_key = ref("hadith");
|
const type_key = ref("hadith");
|
||||||
|
|
||||||
const synonymOne = ref(false);
|
const synonymOne = ref(false);
|
||||||
|
const synonymTwo = ref(false);
|
||||||
|
|
||||||
// If you want to share state across multiple components,
|
// If you want to share state across multiple components,
|
||||||
// you can use the same key in useState. Nuxt will ensure
|
// you can use the same key in useState. Nuxt will ensure
|
||||||
|
@ -203,6 +203,9 @@ const sendQuery = async () => {
|
||||||
// store search phrase
|
// store search phrase
|
||||||
useStorage("searchPhrase", searchTerm.value);
|
useStorage("searchPhrase", searchTerm.value);
|
||||||
})
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.info(err);
|
||||||
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
|
@ -342,6 +345,7 @@ async function openSynonymPopup(type: string) {
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<template #content>
|
<template #content>
|
||||||
|
<!-- synonym item -->
|
||||||
<div class="synonymItem px-2 py-4">
|
<div class="synonymItem px-2 py-4">
|
||||||
<div class="flex justify-between items-center p-3 mb-2">
|
<div class="flex justify-between items-center p-3 mb-2">
|
||||||
<span class="title"> نماز </span>
|
<span class="title"> نماز </span>
|
||||||
|
@ -367,21 +371,37 @@ async function openSynonymPopup(type: string) {
|
||||||
<!-- <UIcon name="i-haditha-close-bg-circle" size="12px"> </UIcon> -->
|
<!-- <UIcon name="i-haditha-close-bg-circle" size="12px"> </UIcon> -->
|
||||||
</UButton>
|
</UButton>
|
||||||
<UButton
|
<UButton
|
||||||
|
v-if="!showForm"
|
||||||
type="button"
|
type="button"
|
||||||
@click="true"
|
@click="showForm = true"
|
||||||
class="me-2.5 mb-3.5 add-button"
|
class="me-2.5 mb-3.5 add-button"
|
||||||
:class="{ active: false }"
|
:class="{ active: false }"
|
||||||
icon="i-haditha-add"
|
icon="i-haditha-add"
|
||||||
>
|
>
|
||||||
</UButton>
|
</UButton>
|
||||||
|
<UForm
|
||||||
|
v-else
|
||||||
|
:schema="schema"
|
||||||
|
:state="state"
|
||||||
|
class="w-25 me-2.5 mb-3.5"
|
||||||
|
>
|
||||||
|
<UFormField name="name" required size="md">
|
||||||
|
<UInput
|
||||||
|
v-model="Formstate.name"
|
||||||
|
placeholder="بنویسید ..."
|
||||||
|
/>
|
||||||
|
</UFormField>
|
||||||
|
</UForm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<USeparator class="px-2" color="neutral" type="solid" size="xs" />
|
<USeparator class="px-2" color="neutral" type="solid" size="xs" />
|
||||||
|
|
||||||
|
<!-- synonym item -->
|
||||||
<div class="synonymItem px-2 py-4">
|
<div class="synonymItem px-2 py-4">
|
||||||
<div class="flex justify-between items-center p-3 mb-2">
|
<div class="flex justify-between items-center p-3 mb-2">
|
||||||
<span class="title"> نماز </span>
|
<span class="title"> نماز </span>
|
||||||
<USwitch dir="ltr" v-model="synonymOne" />
|
<USwitch dir="ltr" v-model="synonymTwo" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center px-2">
|
<div class="flex items-center px-2">
|
||||||
<UButton
|
<UButton
|
||||||
|
@ -464,8 +484,8 @@ async function openSynonymPopup(type: string) {
|
||||||
</UButton>
|
</UButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- نوع -->
|
||||||
<div>
|
<div>
|
||||||
<!-- نوع -->
|
|
||||||
<UDropdownMenu
|
<UDropdownMenu
|
||||||
:items="state.type.items"
|
:items="state.type.items"
|
||||||
:content="{
|
:content="{
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import * as z from "zod";
|
import * as z from "zod";
|
||||||
import type { FormSubmitEvent } from "@nuxt/ui";
|
import type { FormSubmitEvent } from "@nuxt/ui";
|
||||||
|
import hadithaApi from "../../apis/hadithaApi";
|
||||||
|
import { useAuthStore } from "~/stores/authStore";
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: false,
|
layout: false,
|
||||||
|
@ -16,18 +18,22 @@ useHead({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const localizedErrors = {
|
const router = useRouter();
|
||||||
required: "Invalid email address",
|
const authStore = useAuthStore();
|
||||||
// Add more error codes and translations as needed
|
// const localizedErrors = {
|
||||||
};
|
// required: "Invalid email address",
|
||||||
|
// // Add more error codes and translations as needed
|
||||||
|
// };
|
||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
mobile: z
|
mobile: z
|
||||||
.string()
|
.string()
|
||||||
.min(1, "این فیلد ضروری است.(exmaple : 09--*******)")
|
.min(1, "این فیلد ضروری است.(exmaple : 09--*******)")
|
||||||
.max(11, "موبایل حداکثر 11 عدد می باشد.(exmaple : 09--*******)")
|
.max(11, "موبایل حداکثر 11 عدد می باشد.(exmaple : 09--*******)"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
type Schema = z.output<typeof schema>;
|
type Schema = z.output<typeof schema>;
|
||||||
|
|
||||||
const state = reactive<Partial<Schema>>({
|
const state = reactive<Partial<Schema>>({
|
||||||
|
@ -36,12 +42,35 @@ const state = reactive<Partial<Schema>>({
|
||||||
|
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
async function onSubmit(event: FormSubmitEvent<Schema>) {
|
async function onSubmit(event: FormSubmitEvent<Schema>) {
|
||||||
toast.add({
|
|
||||||
title: "Success",
|
|
||||||
description: "The form has been submitted.",
|
|
||||||
color: "success",
|
|
||||||
});
|
|
||||||
console.log(event.data);
|
console.log(event.data);
|
||||||
|
|
||||||
|
const payoload = {
|
||||||
|
username: "dev",
|
||||||
|
password: "dev123",
|
||||||
|
};
|
||||||
|
|
||||||
|
authStore
|
||||||
|
.login(payoload)
|
||||||
|
.then((res) => {
|
||||||
|
loading.value = false;
|
||||||
|
// check if search term is not empty
|
||||||
|
|
||||||
|
toast.add({
|
||||||
|
title: "Success",
|
||||||
|
description: res.data.message,
|
||||||
|
color: "success",
|
||||||
|
});
|
||||||
|
|
||||||
|
navigateTo({
|
||||||
|
name: "haditha",
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.info(err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// components declaration
|
// components declaration
|
||||||
|
|
Loading…
Reference in New Issue
Block a user