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