feat: enhance party user schema with company, status, role and verification fields, update seeding and frontend form
This commit is contained in:
@@ -1279,4 +1279,8 @@ model PartyUser {
|
||||
sessions Session[]
|
||||
info Json?
|
||||
phoneNumber String @default("")
|
||||
company String @default("")
|
||||
status String @default("pending")
|
||||
role String @default("")
|
||||
isVerified Boolean @default(false)
|
||||
}
|
||||
|
@@ -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,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@@ -7,7 +7,8 @@ clear
|
||||
while true; do
|
||||
yarn db:studio &
|
||||
|
||||
npx nodemon --ext ts,tsx,prisma --exec "yarn db:push && yarn seed && yarn dev"
|
||||
npx nodemon --ext ts,tsx,prisma --exec "yarn dev"
|
||||
# npx nodemon --ext ts,tsx,prisma --exec "yarn db:push && yarn seed && yarn dev"
|
||||
# yarn dev
|
||||
|
||||
killall node
|
||||
|
@@ -5,10 +5,10 @@ Content-Type: application/json
|
||||
|
||||
{
|
||||
"partyUserData": {
|
||||
"id": "cmbxzds7q0009xyn5367ifizp",
|
||||
"id": "cmc0cedkx000boln3viy77598",
|
||||
"createdAt": "2025-06-15T17:47:24.547Z",
|
||||
"updatedAt": "2025-06-15T17:47:24.547Z",
|
||||
"name": "Alice",
|
||||
"name": "Alice 123321",
|
||||
"username": null,
|
||||
"email": "alice@prisma.io",
|
||||
"emailVerified": "2025-06-15T17:47:23.919Z",
|
||||
@@ -16,6 +16,7 @@ Content-Type: application/json
|
||||
"image": null,
|
||||
"bucketImage": null,
|
||||
"admin": false,
|
||||
"info": null
|
||||
"info": null,
|
||||
"phoneNumber": "+85291234567"
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user