优化
This commit is contained in:
50
monisuo-admin/src/pages/users/data/data.ts
Normal file
50
monisuo-admin/src/pages/users/data/data.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Award, BadgeDollarSign, Handshake, Shield } from 'lucide-vue-next'
|
||||
import { h } from 'vue'
|
||||
|
||||
import type { FacetedFilterOption } from '@/components/data-table'
|
||||
|
||||
export const callTypes: (FacetedFilterOption & { style: string })[] = [
|
||||
{
|
||||
label: 'Active',
|
||||
value: 'active',
|
||||
style: 'bg-teal-100/30 text-teal-900 dark:text-teal-200 border-teal-200',
|
||||
},
|
||||
{
|
||||
label: 'Inactive',
|
||||
value: 'inactive',
|
||||
style: 'bg-neutral-300/40 border-neutral-300',
|
||||
},
|
||||
{
|
||||
label: 'Invited',
|
||||
value: 'invited',
|
||||
style: 'bg-sky-200/40 text-sky-900 dark:text-sky-100 border-sky-300',
|
||||
},
|
||||
{
|
||||
label: 'Suspended',
|
||||
value: 'suspended',
|
||||
style: 'bg-destructive/10 dark:bg-destructive/50 text-destructive dark:text-primary border-destructive/10',
|
||||
},
|
||||
]
|
||||
|
||||
export const userTypes: FacetedFilterOption[] = [
|
||||
{
|
||||
label: 'Superadmin',
|
||||
value: 'superadmin',
|
||||
icon: h(BadgeDollarSign),
|
||||
},
|
||||
{
|
||||
label: 'Admin',
|
||||
value: 'admin',
|
||||
icon: h(Handshake),
|
||||
},
|
||||
{
|
||||
label: 'Manager',
|
||||
value: 'manager',
|
||||
icon: h(Award),
|
||||
},
|
||||
{
|
||||
label: 'Cashier',
|
||||
value: 'cashier',
|
||||
icon: h(Shield),
|
||||
},
|
||||
] as const
|
||||
23
monisuo-admin/src/pages/users/data/schema.ts
Normal file
23
monisuo-admin/src/pages/users/data/schema.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const userStatusSchema = z.enum(['active', 'inactive', 'invited', 'suspended'])
|
||||
export type UserStatus = z.infer<typeof userStatusSchema>
|
||||
|
||||
export const userRoleSchema = z.enum(['superadmin', 'admin', 'cashier', 'manager'])
|
||||
export type UserRole = z.infer<typeof userRoleSchema>
|
||||
|
||||
export const userSchema = z.object({
|
||||
id: z.string(),
|
||||
firstName: z.string(),
|
||||
lastName: z.string(),
|
||||
username: z.string(),
|
||||
email: z.string(),
|
||||
phoneNumber: z.string(),
|
||||
status: userStatusSchema,
|
||||
role: userRoleSchema,
|
||||
createdAt: z.coerce.date(),
|
||||
updatedAt: z.coerce.date(),
|
||||
})
|
||||
export type User = z.infer<typeof userSchema>
|
||||
|
||||
export const userListSchema = z.array(userSchema)
|
||||
30
monisuo-admin/src/pages/users/data/users.ts
Normal file
30
monisuo-admin/src/pages/users/data/users.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { faker } from '@faker-js/faker'
|
||||
|
||||
export const users = Array.from({ length: 20 }, () => {
|
||||
const firstName = faker.person.firstName()
|
||||
const lastName = faker.person.lastName()
|
||||
return {
|
||||
id: faker.string.uuid(),
|
||||
firstName,
|
||||
lastName,
|
||||
username: faker.internet
|
||||
.username({ firstName, lastName })
|
||||
.toLocaleLowerCase(),
|
||||
email: faker.internet.email({ firstName }).toLocaleLowerCase(),
|
||||
phoneNumber: faker.phone.number({ style: 'international' }),
|
||||
status: faker.helpers.arrayElement([
|
||||
'active',
|
||||
'inactive',
|
||||
'invited',
|
||||
'suspended',
|
||||
]),
|
||||
role: faker.helpers.arrayElement([
|
||||
'superadmin',
|
||||
'admin',
|
||||
'cashier',
|
||||
'manager',
|
||||
]),
|
||||
createdAt: faker.date.past(),
|
||||
updatedAt: faker.date.recent(),
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user