feat: polish admin UI, phone login, and product details
Switch admin auth to mobile, restyle shell/login with Vuesax icons, and add product detail fields plus public product pages. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
import { DeleteOutlined, EditOutlined, PlusOutlined } from "@ant-design/icons-vue";
|
||||
import {
|
||||
type AdminUserDto,
|
||||
ROLE_LABELS,
|
||||
@@ -12,6 +11,7 @@ import { message } from "ant-design-vue";
|
||||
import { computed, onMounted, type Ref, ref } from "vue";
|
||||
import type { z } from "zod";
|
||||
import { api, errorMessage } from "@/api/http";
|
||||
import VuesaxIcon from "@/components/VuesaxIcon.vue";
|
||||
import FormField from "@/components/FormField.vue";
|
||||
import PageHeader from "@/components/PageHeader.vue";
|
||||
import { useZodForm } from "@/composables/useZodForm";
|
||||
@@ -28,7 +28,7 @@ const saving = ref(false);
|
||||
|
||||
// one form model for both create and update; the matching schema validates on save
|
||||
type Form = z.input<typeof userCreateSchema> & { isActive: boolean };
|
||||
const empty: Form = { email: "", name: "", role: "EDITOR", password: "", isActive: true };
|
||||
const empty: Form = { phone: "", name: "", role: "EDITOR", password: "", isActive: true };
|
||||
const form = useZodForm(userCreateSchema, empty);
|
||||
const model = form.model as unknown as Ref<Form>;
|
||||
const isNew = computed(() => editing.value === 0);
|
||||
@@ -50,7 +50,7 @@ function openNew() {
|
||||
editing.value = 0;
|
||||
}
|
||||
function openEdit(u: AdminUserDto) {
|
||||
form.reset({ email: u.email, name: u.name, role: u.role, isActive: u.isActive, password: "" } as Form);
|
||||
form.reset({ phone: u.phone, name: u.name, role: u.role, isActive: u.isActive, password: "" } as Form);
|
||||
editing.value = u.id;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ async function remove(u: AdminUserDto) {
|
||||
|
||||
const columns = [
|
||||
{ title: "نام", dataIndex: "name" },
|
||||
{ title: "ایمیل", key: "email" },
|
||||
{ title: "موبایل", key: "phone" },
|
||||
{ title: "نقش", key: "role", width: 110 },
|
||||
{ title: "وضعیت", key: "active", width: 100 },
|
||||
{ title: "آخرین ورود", key: "login", width: 170 },
|
||||
@@ -105,7 +105,7 @@ onMounted(load);
|
||||
<template>
|
||||
<PageHeader title="کاربران پنل" subtitle="مدیر کل به همه بخشها دسترسی دارد؛ ویرایشگر به جز کاربران و تنظیمات سایت">
|
||||
<a-button type="primary" @click="openNew">
|
||||
<template #icon><PlusOutlined /></template>
|
||||
<template #icon><VuesaxIcon name="add" :size="16" /></template>
|
||||
کاربر جدید
|
||||
</a-button>
|
||||
</PageHeader>
|
||||
@@ -113,7 +113,7 @@ onMounted(load);
|
||||
<a-card :body-style="{ padding: 0 }">
|
||||
<a-table :columns="columns" :data-source="rows" :loading="loading" row-key="id" :pagination="false" :scroll="{ x: 700 }">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'email'"><span dir="ltr">{{ record.email }}</span></template>
|
||||
<template v-if="column.key === 'phone'"><span dir="ltr">{{ record.phone }}</span></template>
|
||||
<template v-else-if="column.key === 'role'">
|
||||
<a-tag :color="record.role === 'ADMIN' ? 'orange' : 'blue'">{{ ROLE_LABELS[record.role as keyof typeof ROLE_LABELS] }}</a-tag>
|
||||
</template>
|
||||
@@ -123,7 +123,7 @@ onMounted(load);
|
||||
<template v-else-if="column.key === 'login'">{{ jalali(record.lastLoginAt) }}</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
<a-space :size="4">
|
||||
<a-button size="small" @click="openEdit(record as AdminUserDto)"><template #icon><EditOutlined /></template></a-button>
|
||||
<a-button size="small" @click="openEdit(record as AdminUserDto)"><template #icon><VuesaxIcon name="edit-2" :size="16" /></template></a-button>
|
||||
<a-popconfirm
|
||||
v-if="record.id !== auth.user?.id"
|
||||
title="این کاربر حذف شود؟"
|
||||
@@ -131,7 +131,7 @@ onMounted(load);
|
||||
cancel-text="انصراف"
|
||||
@confirm="remove(record as AdminUserDto)"
|
||||
>
|
||||
<a-button size="small" danger><template #icon><DeleteOutlined /></template></a-button>
|
||||
<a-button size="small" danger><template #icon><VuesaxIcon name="trash" :size="16" /></template></a-button>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
@@ -150,8 +150,14 @@ onMounted(load);
|
||||
@cancel="editing = null"
|
||||
>
|
||||
<a-form layout="vertical" class="mt-4" @submit.prevent="save">
|
||||
<FormField path="email" label="ایمیل" required>
|
||||
<a-input v-model:value="model.email" class="ltr-input" :disabled="!isNew" />
|
||||
<FormField path="phone" label="شماره موبایل" required>
|
||||
<a-input
|
||||
v-model:value="model.phone"
|
||||
class="ltr-input"
|
||||
:disabled="!isNew"
|
||||
inputmode="tel"
|
||||
placeholder="09121234567"
|
||||
/>
|
||||
</FormField>
|
||||
<FormField path="name" label="نام" required>
|
||||
<a-input v-model:value="model.name" />
|
||||
|
||||
Reference in New Issue
Block a user