fixed bugs - 1 to 12
This commit is contained in:
@@ -36,3 +36,13 @@ direction: rtl;
|
||||
*:hover::-webkit-scrollbar-thumb {
|
||||
@apply bg-opacity-100;
|
||||
}
|
||||
input::-webkit-outer-spin-button,
|
||||
input::-webkit-inner-spin-button {
|
||||
-webkit-appearance: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Firefox */
|
||||
input[type=number] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export const useAdminsStore = defineStore('admins', {
|
||||
code: code.value
|
||||
})
|
||||
if (status == 200) {
|
||||
if (data.roles[0] === "Admin") {
|
||||
if (data.roles[0] === "Admin" || data.roles[1] === "Admin") {
|
||||
this.token = data.token
|
||||
}
|
||||
else {
|
||||
|
||||
+33
-11
@@ -29,11 +29,12 @@
|
||||
<div class="flex flex-col gap-1">
|
||||
<FloatLabel>
|
||||
<InputText
|
||||
type="number"
|
||||
v-model="newCourse.duration"
|
||||
class="w-full"
|
||||
prefix="ساعت"
|
||||
/>
|
||||
<label>{{ $t("مدت زمان دوره") }}</label>
|
||||
<label>{{ $t("مدت زمان دوره (ساعت)") }}</label>
|
||||
</FloatLabel>
|
||||
</div>
|
||||
|
||||
@@ -51,7 +52,10 @@
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<FloatLabel>
|
||||
<InputText
|
||||
<InputNumber
|
||||
|
||||
max = "100"
|
||||
prefix="%" fluid
|
||||
class="w-full"
|
||||
v-model="newCourse.completionPercentage"
|
||||
/>
|
||||
@@ -61,15 +65,15 @@
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<FloatLabel>
|
||||
<InputText class="w-full" v-model="newCourse.countOfVideos" />
|
||||
<InputText type="number" class="w-full" v-model="newCourse.countOfVideos" />
|
||||
<label>{{ $t("تعداد ویدیو ها") }}</label>
|
||||
</FloatLabel>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
<FloatLabel>
|
||||
<InputText class="w-full" v-model="newCourse.totalFileSize" />
|
||||
<label>{{ $t("حجم کل دوره") }}</label>
|
||||
<InputText type="number" class="w-full" v-model="newCourse.totalFileSize" />
|
||||
<label>{{ $t("حجم کل دوره (گیگابایت)") }}</label>
|
||||
</FloatLabel>
|
||||
</div>
|
||||
|
||||
@@ -87,7 +91,7 @@
|
||||
/>
|
||||
</Button>
|
||||
</InputGroup>
|
||||
<label>{{ $t("image") }}</label>
|
||||
<label>{{ imagePlaceholder }}</label>
|
||||
</FloatLabel>
|
||||
</div>
|
||||
</div>
|
||||
@@ -103,10 +107,10 @@
|
||||
</div>
|
||||
|
||||
<div class="basis-2/6 flex flex-col gap-7 ms-7">
|
||||
<div class="flex flex-col gap-1">
|
||||
<div class="flex flex-col gap-1" dir="rtl">
|
||||
<FloatLabel>
|
||||
<InputText class="w-full" v-model="newCourse.price" />
|
||||
<label>{{ $t("قیمت دوره") }}</label>
|
||||
<InputNumber type="number" class="w-full" v-model="newCourse.price" fluid/>
|
||||
<label>{{ $t("قیمت دوره (تومان)") }}</label>
|
||||
</FloatLabel>
|
||||
</div>
|
||||
|
||||
@@ -140,7 +144,16 @@
|
||||
|
||||
|
||||
|
||||
<div class="flex pt-4 justify-end">
|
||||
<div class="flex pt-4 gap-3 justify-end">
|
||||
|
||||
<Button
|
||||
:label="$t('انصراف')"
|
||||
icon="pi pi-save"
|
||||
severity="secondary"
|
||||
:loading="creating"
|
||||
@click="cansel"
|
||||
/>
|
||||
|
||||
<Button
|
||||
:label="$t('create')"
|
||||
icon="pi pi-save"
|
||||
@@ -148,6 +161,7 @@
|
||||
:loading="creating"
|
||||
@click="create(newCourse)"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
@@ -189,6 +203,7 @@ const selectedteacher = ref();
|
||||
const language = ref("");
|
||||
const saving = ref(false);
|
||||
const creating = ref(false);
|
||||
const imagePlaceholder = ref('تصویر')
|
||||
const selectCategory = () => {
|
||||
newCourse.categories = selectedCategory.value.id;
|
||||
};
|
||||
@@ -202,6 +217,8 @@ watchEffect(async () => {
|
||||
});
|
||||
watchEffect(async () => {
|
||||
await userStore.index();
|
||||
console.log(userStore.items.user);
|
||||
|
||||
teachers.value = userStore.items.user;
|
||||
});
|
||||
|
||||
@@ -237,6 +254,10 @@ const chooseImage = async (val) => {
|
||||
saving.value = true;
|
||||
const uploader = await uploadStore.uploader(val.target.files[0]);
|
||||
newCourse.image = uploader.data.url;
|
||||
|
||||
val.target.files[0].name ? imagePlaceholder.value = val.target.files[0].name : imagePlaceholder.value = "تصویر" ;
|
||||
|
||||
|
||||
saving.value = false;
|
||||
if (uploader.status === 200 || uploader.status === 201) {
|
||||
toast.add({
|
||||
@@ -256,6 +277,7 @@ const chooseImage = async (val) => {
|
||||
|
||||
};
|
||||
const router = useRouter();
|
||||
const cansel = () => router.back()
|
||||
const create = async (newCourse) => {
|
||||
creating.value = true;
|
||||
if (
|
||||
@@ -273,7 +295,7 @@ const create = async (newCourse) => {
|
||||
) {
|
||||
creating.value = false;
|
||||
return toast.add({
|
||||
life: 2000,
|
||||
life: 4000,
|
||||
severity: "error",
|
||||
summary: t("error"),
|
||||
detail: t("تمام فیلد ها را وارد کنید"),
|
||||
|
||||
+70
-10
@@ -11,9 +11,13 @@
|
||||
<template #content>
|
||||
<div class="flex flex-col gap-1">
|
||||
<FloatLabel>
|
||||
<InputText v-model="number" class="w-full ltr" />
|
||||
<InputText
|
||||
oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
||||
maxlength = "11"
|
||||
type="number" v-model="number" class="w-full ltr" />
|
||||
<label>{{ $t("phoneNumber") }}</label>
|
||||
</FloatLabel>
|
||||
|
||||
<small v-if="errors.length > 0">{{ errors }}</small>
|
||||
</div>
|
||||
</template>
|
||||
@@ -39,7 +43,7 @@
|
||||
<template #content>
|
||||
<div class="flex flex-col gap-1">
|
||||
<FloatLabel>
|
||||
<InputText v-model="code" class="w-full ltr" />
|
||||
<InputText type="number" v-model="code" class="w-full ltr" />
|
||||
<label>{{ $t("otp") }}</label>
|
||||
</FloatLabel>
|
||||
<small v-if="errors.length > 0">{{ errors }}</small>
|
||||
@@ -56,7 +60,7 @@
|
||||
</Card>
|
||||
</template>
|
||||
<script setup>
|
||||
import { inject, ref } from "vue";
|
||||
import { inject, ref, watch } from "vue";
|
||||
import { useAdminsStore } from "@/stores/admins";
|
||||
import { useRouter } from "vue-router";
|
||||
const { toast, t } = inject("service");
|
||||
@@ -64,13 +68,34 @@ const loading = ref(false);
|
||||
const changeForm = ref(false);
|
||||
const store = useAdminsStore();
|
||||
const errors = ref({});
|
||||
const emptyError = ref(false)
|
||||
const number = ref(null);
|
||||
const maxlength = ref(2)
|
||||
const code = ref(1234);
|
||||
const router = useRouter();
|
||||
const pattern = /^(\+98|0)?9\d{9}$/;
|
||||
const login = async () => {
|
||||
if (number.value === null || number.value === '') {
|
||||
return toast.add({
|
||||
severity: "error",
|
||||
life: 2000,
|
||||
detail: t("شماره موبایل را وارد کنید"),
|
||||
summary: t("error"),
|
||||
});
|
||||
}
|
||||
if (!pattern.test(number.value)) {
|
||||
return toast.add({
|
||||
severity: "error",
|
||||
life: 2000,
|
||||
detail: t("شماره موبایل را صحیح وارد کنید"),
|
||||
summary: t("error"),
|
||||
});
|
||||
};
|
||||
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const { status, data } = await store.login(number);
|
||||
loading.value = false;
|
||||
if (status === 200) {
|
||||
changeForm.value = true;
|
||||
toast.add({
|
||||
@@ -80,16 +105,39 @@ const login = async () => {
|
||||
summary: t("successful"),
|
||||
closable: false,
|
||||
});
|
||||
loading.value = false;
|
||||
}else{
|
||||
loading.value = false;
|
||||
return toast.add({
|
||||
severity: "error",
|
||||
life: 2000,
|
||||
detail: t("خطایی رخ داد، لطفا مجدد تلاش کنید"),
|
||||
summary: t("error"),
|
||||
});
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
return toast.add({
|
||||
severity: "error",
|
||||
life: 2000,
|
||||
detail: error.response.data.error,
|
||||
summary: t("error"),
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
const checkOtp = async () => {
|
||||
loading.value = true;
|
||||
const { status, data } = await store.sendOtp(number, code);
|
||||
console.log("login", data);
|
||||
|
||||
loading.value = false;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const {data, status} = await store.sendOtp(number, code);
|
||||
if (status === 200) {
|
||||
if (data.roles[0] === "Admin") {
|
||||
if (data.roles[0] === "Admin" || data.roles[1] === "Admin" || data.roles[2] === "Admin") {
|
||||
toast.add({
|
||||
severity: "success",
|
||||
life: 2000,
|
||||
@@ -97,16 +145,28 @@ const checkOtp = async () => {
|
||||
summary: t("successful"),
|
||||
closable: false,
|
||||
});
|
||||
loading.value = false;
|
||||
setTimeout(() => router.push("/"), 300);
|
||||
} else {
|
||||
loading.value = false
|
||||
return toast.add({
|
||||
severity: "error",
|
||||
life: 2000,
|
||||
detail: t("شما مجوز ورود ندارید"),
|
||||
detail: t("شماره مجوز ورود ندارید !"),
|
||||
summary: t("error"),
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
loading.value = false;
|
||||
return toast.add({
|
||||
severity: "error",
|
||||
life: 2000,
|
||||
detail: error.response.data.error,
|
||||
summary: t("error"),
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user