feat: enhance party user schema with company, status, role and verification fields, update seeding and frontend form
This commit is contained in:
@@ -1,6 +1,41 @@
|
||||
import { faker as enFaker } from '@faker-js/faker/locale/en_US';
|
||||
import { faker as zhFaker } from '@faker-js/faker/locale/zh_CN';
|
||||
import { faker as jaFaker } from '@faker-js/faker/locale/ja';
|
||||
import { faker as koFaker } from '@faker-js/faker/locale/ko';
|
||||
import { faker as twFaker } from '@faker-js/faker/locale/zh_TW';
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const ROLE = [
|
||||
`CEO`,
|
||||
`CTO`,
|
||||
`Project Coordinator`,
|
||||
`Team Leader`,
|
||||
`Software Developer`,
|
||||
`Marketing Strategist`,
|
||||
`Data Analyst`,
|
||||
`Product Owner`,
|
||||
`Graphic Designer`,
|
||||
`Operations Manager`,
|
||||
`Customer Support Specialist`,
|
||||
`Sales Manager`,
|
||||
`HR Recruiter`,
|
||||
`Business Consultant`,
|
||||
`Financial Planner`,
|
||||
`Network Engineer`,
|
||||
`Content Creator`,
|
||||
`Quality Assurance Tester`,
|
||||
`Public Relations Officer`,
|
||||
`IT Administrator`,
|
||||
`Compliance Officer`,
|
||||
`Event Planner`,
|
||||
`Legal Counsel`,
|
||||
`Training Coordinator`,
|
||||
];
|
||||
|
||||
const STATUS = ['active', 'pending', 'banned'];
|
||||
|
||||
async function partyUser() {
|
||||
const alice = await prisma.partyUser.upsert({
|
||||
where: { email: 'alice@prisma.io' },
|
||||
@@ -8,8 +43,14 @@ async function partyUser() {
|
||||
create: {
|
||||
email: 'alice@prisma.io',
|
||||
name: 'Alice',
|
||||
username: 'pualice',
|
||||
password: 'Aa12345678',
|
||||
emailVerified: new Date(),
|
||||
phoneNumber: '+85291234567',
|
||||
company: 'helloworld company',
|
||||
status: STATUS[0],
|
||||
role: ROLE[0],
|
||||
isVerified: true,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -19,31 +60,48 @@ async function partyUser() {
|
||||
create: {
|
||||
email: 'demo@minimals.cc',
|
||||
name: 'Demo',
|
||||
username: 'pudemo',
|
||||
password: '@2Minimal',
|
||||
emailVerified: new Date(),
|
||||
phoneNumber: '+85291234568',
|
||||
company: 'helloworld company',
|
||||
status: STATUS[1],
|
||||
role: ROLE[1],
|
||||
isVerified: true,
|
||||
},
|
||||
});
|
||||
|
||||
await prisma.partyUser.upsert({
|
||||
where: { email: 'bob@prisma.io' },
|
||||
update: {},
|
||||
create: {
|
||||
email: 'bob@prisma.io',
|
||||
name: 'Bob',
|
||||
password: 'Aa12345678',
|
||||
emailVerified: new Date(),
|
||||
},
|
||||
});
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const CJK_LOCALES = {
|
||||
en: enFaker,
|
||||
zh: zhFaker,
|
||||
ja: jaFaker,
|
||||
ko: koFaker,
|
||||
tw: twFaker,
|
||||
};
|
||||
|
||||
function getRandomCJKFaker() {
|
||||
const locales = Object.keys(CJK_LOCALES);
|
||||
const randomKey = locales[Math.floor(Math.random() * locales.length)] as keyof typeof CJK_LOCALES;
|
||||
return CJK_LOCALES[randomKey];
|
||||
}
|
||||
|
||||
const randomFaker = getRandomCJKFaker();
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await prisma.partyUser.upsert({
|
||||
where: { email: `bob${i}@prisma.io` },
|
||||
where: { email: `party_user${i}@prisma.io` },
|
||||
update: {},
|
||||
create: {
|
||||
email: `bob${i}@prisma.io`,
|
||||
name: 'Bob',
|
||||
email: `party_user${i}@prisma.io`,
|
||||
name: `Party Dummy ${i}`,
|
||||
username: `pu${i.toString()}`,
|
||||
password: 'Aa12345678',
|
||||
emailVerified: new Date(),
|
||||
phoneNumber: `+8529123456${i.toString()}`,
|
||||
company: randomFaker.company.name(),
|
||||
role: ROLE[Math.floor(Math.random() * ROLE.length)],
|
||||
status: STATUS[Math.floor(Math.random() * STATUS.length)],
|
||||
isVerified: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user