From 34700a46d91f1ce1e377105e79a4f76d9f6d2574 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 15 Dec 2022 15:16:47 +0100 Subject: [PATCH] fix - modifications importantes --- .vscode/settings.json | 5 - components/NavBar.tsx | 4 + package-lock.json | 13 ++ package.json | 1 + pages/admin.tsx | 239 ++++++++++++++++++---------------- pages/api/apiGain/index.ts | 99 -------------- pages/api/testcode/index.ts | 25 ++-- pages/api/user/search.ts | 49 +++++++ pages/api/user/update-gift.ts | 2 +- pages/index.tsx | 24 ++-- prisma/schema.prisma | 6 +- prisma/seed.ts | 14 -- prisma/seed/gains.ts | 52 -------- prisma/seed/user.ts | 57 +++++++- 14 files changed, 267 insertions(+), 323 deletions(-) delete mode 100644 pages/api/apiGain/index.ts create mode 100644 pages/api/user/search.ts delete mode 100644 prisma/seed/gains.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 297b8d0..7a73a41 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,2 @@ { - "workbench.colorCustomizations": { - "activityBar.background": "#4C1F25", - "titleBar.activeBackground": "#6A2C34", - "titleBar.activeForeground": "#FEFCFC" - } } \ No newline at end of file diff --git a/components/NavBar.tsx b/components/NavBar.tsx index 7959a4f..e7cd367 100644 --- a/components/NavBar.tsx +++ b/components/NavBar.tsx @@ -29,6 +29,10 @@ const NavBar = () => { const checkRole = () => { const isAdmin = ['SELLER', 'ADMIN', 'SUPERADMIN'].includes(session?.user['role']); + console.log('isAdmin', isAdmin); + console.log('role', session?.user['role']); + + return isAdmin ? setIsAdmin(true) : setIsAdmin(false); } diff --git a/package-lock.json b/package-lock.json index 1b9d4e9..89d8b96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -43,6 +43,7 @@ "@testing-library/user-event": "^14.4.3", "@tomfreudenberg/next-auth-mock": "^0.5.5", "@types/chance": "^1.1.3", + "@types/dateformat": "^5.0.0", "@types/jest": "^29.2.4", "@types/next-auth": "3.13.0", "@types/node": "^18.11.9", @@ -1960,6 +1961,12 @@ "integrity": "sha512-X6c6ghhe4/sQh4XzcZWSFaTAUOda38GQHmq9BUanYkOE/EO7ZrkazwKmtsj3xzTjkLWmwULE++23g3d3CCWaWw==", "dev": true }, + "node_modules/@types/dateformat": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/dateformat/-/dateformat-5.0.0.tgz", + "integrity": "sha512-SZg4JdHIWHQGEokbYGZSDvo5wA4TLYPXaqhigs/wH+REDOejcJzgH+qyY+HtEUtWOZxEUkbhbdYPqQDiEgrXeA==", + "dev": true + }, "node_modules/@types/debug": { "version": "4.1.7", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", @@ -10355,6 +10362,12 @@ "integrity": "sha512-X6c6ghhe4/sQh4XzcZWSFaTAUOda38GQHmq9BUanYkOE/EO7ZrkazwKmtsj3xzTjkLWmwULE++23g3d3CCWaWw==", "dev": true }, + "@types/dateformat": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/dateformat/-/dateformat-5.0.0.tgz", + "integrity": "sha512-SZg4JdHIWHQGEokbYGZSDvo5wA4TLYPXaqhigs/wH+REDOejcJzgH+qyY+HtEUtWOZxEUkbhbdYPqQDiEgrXeA==", + "dev": true + }, "@types/debug": { "version": "4.1.7", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz", diff --git a/package.json b/package.json index 58245a9..40c3005 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "@testing-library/user-event": "^14.4.3", "@tomfreudenberg/next-auth-mock": "^0.5.5", "@types/chance": "^1.1.3", + "@types/dateformat": "^5.0.0", "@types/jest": "^29.2.4", "@types/next-auth": "3.13.0", "@types/node": "^18.11.9", diff --git a/pages/admin.tsx b/pages/admin.tsx index 05bda0b..b20f87c 100644 --- a/pages/admin.tsx +++ b/pages/admin.tsx @@ -21,11 +21,18 @@ import { Token } from "nodemailer/lib/xoauth2"; import { isGeneratorFunction } from "util/types"; import { UserProps } from "../types/user"; import { UserGainProps } from "../types/userGain"; -import { Gain, Produit, Role, TicketsRestants, User } from "@prisma/client"; +import { Gain, Produit, Role, User } from "@prisma/client"; import { Doughnut } from "react-chartjs-2"; -import { Chart as ChartJS, ArcElement, Tooltip, Legend, RadialLinearScale } from 'chart.js'; -import { PolarArea } from 'react-chartjs-2'; - +import { + Chart as ChartJS, + CategoryScale, + LinearScale, + BarElement, + Title, + Tooltip, + Legend, +} from 'chart.js'; +import { Bar } from 'react-chartjs-2'; type FormData = { email: string; @@ -52,7 +59,8 @@ export async function getServerSideProps(context) { const users = await prisma.user.findMany({ include: { gains: true - } + }, + take: 5 }); const user = await prisma.user.findUnique({ @@ -61,8 +69,29 @@ export async function getServerSideProps(context) { } }); - const tickets = await prisma.gain.findMany({}) - const totalTirageRestant = await prisma.ticketsRestants.findFirst({}) + const ticketRestants = await prisma.gain.count({ + where: { + codeActif: true, + dateAchat: { + not: null, + } + } + }) + + const ticketsSaisis = await prisma.gain.count({ + where: { + codeActif: false, + }, + }) + + const gainsRetires = await prisma.gain.count({ + where: { + retrait: true + }, + }) + + console.log("🚀 ~ file: admin.tsx:87 ~ getServerSideProps ~ gainsRetires", gainsRetires) + const produits = await prisma.produit.findMany({}) return { @@ -70,8 +99,9 @@ export async function getServerSideProps(context) { user: JSON.parse(JSON.stringify(user)), produits: JSON.parse(JSON.stringify(produits)), users: JSON.parse(JSON.stringify(users)), - tickets: JSON.parse(JSON.stringify(tickets)), - totalTirageRestant: JSON.parse(JSON.stringify(totalTirageRestant)) + ticketRestants: JSON.parse(JSON.stringify(ticketRestants)), + ticketsSaisis: JSON.parse(JSON.stringify(ticketsSaisis)), + gainsRetires: JSON.parse(JSON.stringify(gainsRetires)), }, } } @@ -80,10 +110,12 @@ type Props = { user: User; produits: Produit[]; users: any, - tickets: Gain[] - totalTirageRestant: TicketsRestants + ticketRestants: number, + ticketsSaisis: number, + gainsRetires: number, } + const Admin = (props: Props) => { const { data: session, status } = useSession(); const [response, setResponse] = useState(null) @@ -93,57 +125,55 @@ const Admin = (props: Props) => { const [query, setQuery] = useState(""); const router = useRouter() + const isAdmin = session?.user['role'] === Role.ADMIN const isSuperAdmin = session?.user['role'] === Role.SUPERADMIN const bigWinner = users?.find((user) => user?.isBigWinner) - ChartJS.register(RadialLinearScale, ArcElement, Tooltip, Legend); - - const TicketRestants = props.tickets?.filter(ticket => ticket.codeActif === true).length - console.log("🚀 ~ file: admin.tsx:103 ~ Admin ~ TicketRestants", TicketRestants) - const TicketUtilise = props.tickets?.filter(ticket => ticket.codeActif === false).length - console.log("🚀 ~ file: admin.tsx:104 ~ Admin ~ TicketUtilise", TicketUtilise) - const TicketTotal = props.totalTirageRestant.total; - console.log("🚀 ~ file: admin.tsx:107 ~ Admin ~ TicketTotal", TicketTotal) - - - - const TotalTirageRestant = props.totalTirageRestant?.total; - - const ticketDataChart = { - labels: ['Tickets gĂ©nĂ©rĂ© utlisĂ©s', 'Tickets gĂ©nĂ©rĂ© restants'], - datasets: [ - { - label: 'Tickets restants gĂ©nĂ©rĂ©', - data: [TicketUtilise, TicketRestants], - backgroundColor: [ - 'rgba(255, 99, 132, 0.2)', - 'rgba(54, 162, 235, 0.2)', - ], - borderColor: [ - 'rgba(255, 99, 132, 1)', - 'rgba(54, 162, 235, 1)', - ], - borderWidth: 1, - }, - ], + ChartJS.register( + CategoryScale, + LinearScale, + BarElement, + Title, + Tooltip, + Legend + ); + + const labels = ['Tickets gĂ©nĂ©rĂ©s', 'Codes saisis', 'Cadeaux rĂ©cupĂ©rĂ©s']; + + const data = { + labels: labels, + datasets: [{ + data: [props.ticketRestants, props.ticketsSaisis, props.gainsRetires], + backgroundColor: [ + 'rgba(255, 99, 132, 0.2)', + 'rgba(255, 159, 64, 0.2)', + 'rgba(255, 205, 86, 0.2)', + ], + borderColor: [ + 'rgb(255, 99, 132)', + 'rgb(255, 159, 64)', + 'rgb(255, 205, 86)', + ], + borderWidth: 1 + }] }; - const TotalTirageRestantData = { - labels: ['Total tirage restant'], - datasets: [ - { - label: 'Tirage de ticket', - data: [TotalTirageRestant], - backgroundColor: [ - 'rgba(54, 162, 235, 0.5)', - ], - borderWidth: 1, + const options = { + responsive: true, + plugins: { + legend: { + display: false }, - ], - } - + title: { + display: false, + }, + }, + }; + const numberWithSpaces = (x: number): string => { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); + } const { register, setValue, handleSubmit, formState: { errors } } = useForm({ }); @@ -160,28 +190,10 @@ const Admin = (props: Props) => { setResponse(data); callback; if (data.err) { - toast.error(data.err, { - position: "top-center", - autoClose: 2000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, - theme: "light", - }); + toastError(data.err); return; } - toast.success(data.message, { - position: "top-center", - autoClose: 5000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, - theme: "light", - }); + toastSuccess(data.message); }) } catch (error) { @@ -189,6 +201,32 @@ const Admin = (props: Props) => { } } + const toastError = (text: string) => { + toast.error(text, { + position: "top-center", + autoClose: 2000, + hideProgressBar: false, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + progress: undefined, + theme: "light", + }); + } + + const toastSuccess = (text: string) => { + toast.success(text, { + position: "top-center", + autoClose: 5000, + hideProgressBar: false, + closeOnClick: true, + pauseOnHover: true, + draggable: true, + progress: undefined, + theme: "light", + }); + } + const onSubmit = async ({ email, name, @@ -218,19 +256,13 @@ const Admin = (props: Props) => { const onDeleteUser = async (userEmail: string) => { const body = { selectedUserEmail: userEmail } if (props.user.email === userEmail) { - toast.error('Vous devez ĂȘtre dĂ©connectĂ© pour supprimer votre compte', { - position: "top-center", - autoClose: 2000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, - theme: "light", - }); + toastError('Vous devez ĂȘtre dĂ©connectĂ© pour supprimer votre compte') return; } fetcher('/api/user/delete', 'DELETE', body) + setTimeout(() => { + router.refresh(); + }, 2000) }; const selectUser = (user: any) => { @@ -256,38 +288,19 @@ const Admin = (props: Props) => { const customers = users.filter((user) => user.role === 'USER') if (users.length <= 0) { - toast.error("Il n'y a pas encore d'utilisateur", { - position: "top-center", - autoClose: 2000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, - theme: "light", - }); + toastError("Il n'y a pas encore d'utilisateur") return; } const customersWithTicket = customers.filter((user) => user.gains.length >= 1) if (customersWithTicket.length <= 0) { - toast.error("Il n'y a pas encore d'utilisateurs ayant jouĂ©", { - position: "top-center", - autoClose: 2000, - hideProgressBar: false, - closeOnClick: true, - pauseOnHover: true, - draggable: true, - progress: undefined, - theme: "light", - }); + toastError("Il n'y a pas encore d'utilisateurs ayant jouĂ©"); return; } const winUser = customersWithTicket[Math.floor(Math.random() * customersWithTicket.length)] const body = { selectedUserEmail: winUser.email } - console.log(body) fetcher('/api/user/bigwinner', 'PUT', body) setTimeout(() => { router.refresh(); @@ -306,7 +319,7 @@ const Admin = (props: Props) => { const filtered = searchFilter(props.users) const handleChange = (e: React.ChangeEvent) => { - setQuery(e.target.value) + setQuery(e.target.value); } return ( @@ -324,17 +337,13 @@ const Admin = (props: Props) => {

Dashboard Administration


- -
-

Total tirages restant 📈 {props.totalTirageRestant?.total?.toString()}

- +

Total tirages restant 📈 {numberWithSpaces(props.ticketRestants).toString()}

+
-
@@ -361,7 +370,7 @@ const Admin = (props: Props) => { Nom PrĂ©nom Email - Types + {session?.user['role'] !== Role.SELLER && Types} @@ -371,7 +380,7 @@ const Admin = (props: Props) => { {info.surname} {info.name} {info.isBigWinner && '🎁'}{info.email} - {info.role !== Role.SELLER && + {session?.user['role'] !== Role.SELLER && } - {info.role !== Role.SELLER && } + {session?.user['role'] !== Role.SELLER && } ; })} diff --git a/pages/api/apiGain/index.ts b/pages/api/apiGain/index.ts deleted file mode 100644 index 4ef88a9..0000000 --- a/pages/api/apiGain/index.ts +++ /dev/null @@ -1,99 +0,0 @@ -import prisma from '../../../lib/prisma'; -import chance from 'chance' -import cryptoRandomString from 'crypto-random-string'; - - -import { NextApiRequest, NextApiResponse } from 'next'; -import { getSession } from 'next-auth/react'; -import { Cadeaux } from '../../../enum/cadeaux.enum'; -import { Role } from '../../../enum/role.enum'; -import process from 'process'; - - - -//API gain qui va generer un code cadeau qui sera sur la facture du client -//On part du principe qu'une 'API caisse'(qu'on ne gere pas) dĂ©clenche l'appel Ă  l'API gain - -//--> http://localhost:3000/api/apiGain?pass=... (a effacer) - -export default async function apiGain(req: NextApiRequest, res: NextApiResponse) { - const { pass } = req.query; - const goodPassword = pass === 'P9RDK2b47x1XQV5s3fSaW6erGpzTNudk8jZwCycJYtMHAqhEnm'; - - if (!process.env.ACTION_API) { - return res.status(401).send({ message: 'Unauthorized' }) - } - - //rĂ©cuperation des tickets disponible - const getTickets = await prisma.ticketsRestants.findFirst({ - where: { - id: 1 - }, - }) - - const { total } = getTickets; - const isTicketsAvaible = total > 0; - - if (isTicketsAvaible && goodPassword) { - - //creation d'un numĂ©ro de gain alĂ©atoire - const gainNumber = cryptoRandomString({ length: 10, type: 'distinguishable' }); - - - //crĂ©ation d'un id de produit de façon pondĂ©rĂ©e - let weightedRandomGainId = chance().weighted([ - Cadeaux.GrandCoffretDecouverte, - Cadeaux.CoffretDecouverte, - Cadeaux.TheSignature, - Cadeaux.TheDetox, - Cadeaux.Infuseur], - [4, 6, 10, 20, 60]); - - //crĂ©ation d'un gain - const gainCreated = await prisma.gain.create({ - data: { - codeCadeau: gainNumber, - } - }) - - //mise Ă  jour du gain avec l'id de produit pondĂ©rĂ© - const gainResult = await prisma.gain.update({ - where: { id: gainCreated.id }, - data: { - produitId: weightedRandomGainId, - } - }) - - //on retire 1 ticket - await prisma.ticketsRestants.update({ - where: { - id: getTickets.id - }, - data: { - total: { - decrement: 1 - } - } - }) - return res.status(200).send({ message: 'Gain has been generated !', result: gainResult }); - } else { - return res.status(401).send({ message: 'Unauthorized' }) - } -} - - - - - - - - - - - - - - - - - diff --git a/pages/api/testcode/index.ts b/pages/api/testcode/index.ts index c80c968..d4aa2eb 100644 --- a/pages/api/testcode/index.ts +++ b/pages/api/testcode/index.ts @@ -23,7 +23,7 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse //est-ce que le code tapĂ© par l'utilisateur est valide ? const isValidCodeCadeau = codeCadeau.match(regex); if (!isValidCodeCadeau) { - res.status(401).json({ err: 'Ce code est invalide' }); + res.status(406).json({ err: 'Ce code est invalide' }); return } @@ -32,9 +32,15 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse where: { codeCadeau } }) + //si l'API gain n'a pas instanciĂ© une date pour ce gain + if (!codeCadeauInfo.dateAchat) { + res.status(406).json({ err: 'Ce code est invalide' }); + return; + } + //check si le code a dĂ©ja Ă©tĂ© utilisĂ© if (!codeCadeauInfo.codeActif) { - res.status(401).json({ err: 'Ce code a dĂ©ja Ă©tĂ© utilisĂ©' }); + res.status(406).json({ err: 'Ce code a dĂ©ja Ă©tĂ© utilisĂ©' }); return; } @@ -45,27 +51,16 @@ export default async function testCode(req: NextApiRequest, res: NextApiResponse }) //ajout du gain au profil de l'utilisateur - const joinGain = await prisma.gain.update({ + await prisma.gain.update({ where: { codeCadeau: codeCadeauInfo.codeCadeau }, data: { userId: getCurrentUser[0].id } }) - //retire un ticket du total de ticket restant - const ticketUpdate = await prisma.ticketsRestants.update({ - where: { - id: 1 - }, - data: { - total: { - decrement: 1 - } - } - }) //passage du code en non-actif - const codeUpdate = await prisma.gain.update({ + await prisma.gain.update({ where: { id: codeCadeauInfo.id }, diff --git a/pages/api/user/search.ts b/pages/api/user/search.ts new file mode 100644 index 0000000..d4c1c80 --- /dev/null +++ b/pages/api/user/search.ts @@ -0,0 +1,49 @@ +import prisma from '../../../lib/prisma'; +import { NextApiRequest, NextApiResponse } from 'next'; +import { getSession } from 'next-auth/react'; + +export default async function updateOrCreate(req: NextApiRequest, res: NextApiResponse) { + const session = await getSession({ req }) + const { targetUserMail } = req.body; + + // est-ce la mĂ©thode est un POST ou PUT? + if (!(['POST'].indexOf(req.method) > -1)) { + throw new Error( + `The HTTP ${req.method} method is not supported at this route.` + ); + } + + // est-ce que utilisateur est connectĂ© ? + if (!session) { + res.status(401).json({ err: "Vous devez ĂȘtre connectĂ©" }); + return; + } + + + //rĂ©cupĂ©ration des informations de l'utilisateur connectĂ© + const user = await prisma.user.findFirst({ + where: { email: targetUserMail }, + }) + + + res.status(200).send({ message: 'user :', res: user }); + +} + + + + + + + + + + + + + + + + + + diff --git a/pages/api/user/update-gift.ts b/pages/api/user/update-gift.ts index 4345ba2..c12c550 100644 --- a/pages/api/user/update-gift.ts +++ b/pages/api/user/update-gift.ts @@ -51,7 +51,7 @@ export default async function updtateGift(req: NextApiRequest, res: NextApiRespo include: { gains: true } }) - return res.status(200).send({ message: `Le gain a ont Ă©tĂ© mis Ă  jour !`, res: updatedCurrentUser }); + return res.status(200).send({ message: `Le gain a Ă©tĂ© mis Ă  jour !`, res: updatedCurrentUser }); } diff --git a/pages/index.tsx b/pages/index.tsx index da68962..dabcb0e 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -45,14 +45,6 @@ const Index = () => { } = useForm(); const onSubmit = async (data: CodeSubmitForm) => { - if (!errors) { - if (!session) { - return -

Vous devez vous connecter pour tester votre code cadeau!

-
- } - } - try { const body = { codeCadeau: data.codeCadeau }; await fetch(`/api/testcode`, { @@ -83,7 +75,7 @@ const Index = () => { } catch (error) { console.error('ERROR :', error); } - }; + } const confettiTime = async (): Promise => { const JSConfetti = (await import('js-confetti')).default @@ -134,13 +126,13 @@ const Index = () => { />
diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 43773e5..78b19bb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -60,14 +60,10 @@ model User { @@map(name: "users") } -model TicketsRestants { - id Int @id @default(autoincrement()) - total Int -} - model Gain { id Int @id @default(autoincrement()) codeCadeau String @unique + dateAchat DateTime? dateRetrait DateTime? produit Produit? @relation(fields: [produitId], references: [id]) produitId Int? diff --git a/prisma/seed.ts b/prisma/seed.ts index b885125..28eb8f3 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -1,7 +1,6 @@ import { PrismaClient } from '@prisma/client'; // import prisma from '../lib/prisma' -import { generateGains } from './seed/gains' import { produitsData } from './seed/produits' import { userData } from './seed/user' @@ -10,14 +9,6 @@ const prisma = new PrismaClient(); async function main() { console.log(`Start seeding ...`) - //création des tickets restants - const tickets = await prisma.ticketsRestants.create({ - data: { - total: 1500000 - }, - }) - console.log(`Created ticket: ${tickets.total}`) - //création des produits for (const p of produitsData) { @@ -37,11 +28,6 @@ async function main() { console.log(`Created user with id: ${user.id}`) } - //création de gains - for (let i = 1; i <= (50); i++) { - await generateGains(); - } - console.log(`Seeding finished.`) } diff --git a/prisma/seed/gains.ts b/prisma/seed/gains.ts deleted file mode 100644 index ac4b6e8..0000000 --- a/prisma/seed/gains.ts +++ /dev/null @@ -1,52 +0,0 @@ -// import { produits } from './produits'; -import prisma from '../../lib/prisma' -import { Chance } from 'chance' -import { Cadeaux } from '../../enum/cadeaux.enum'; -import cryptoRandomString from 'crypto-random-string'; -let chance = new Chance(); - -export const generateGains = async () => { - //génération d'un code cadeau - const randomNoGain = cryptoRandomString({ length: 10, type: 'distinguishable' }); - - //création d'un gain - const gainCreated = await prisma.gain.create({ - data: { - codeCadeau: randomNoGain, - codeActif: true, - retrait: false - } - }) - - //crétion d'un id de produit de façon pondérée - let weightedRandomGain = chance.weighted([ - Cadeaux.GrandCoffretDecouverte, - Cadeaux.CoffretDecouverte, - Cadeaux.TheSignature, - Cadeaux.TheDetox, - Cadeaux.Infuseur], - [4, 6, 10, 20, 60]); - - //mise à jour du gain avec l'id de produit pondéré - const gainUpdated = await prisma.gain.update({ - where: { id: gainCreated.id }, - data: { - produitId: weightedRandomGain, - } - }) - //on retire 1 ticket - await prisma.ticketsRestants.update({ - where: { - id: 1 - }, - data: { - total: { - decrement: 1 - } - } - }) - - console.log(`Created gain ! : ${gainUpdated.codeCadeau}`) -} - - diff --git a/prisma/seed/user.ts b/prisma/seed/user.ts index b1f839c..34b1222 100644 --- a/prisma/seed/user.ts +++ b/prisma/seed/user.ts @@ -11,7 +11,7 @@ export const userData: Prisma.UserCreateInput[] = [ name: 'John', email: 'john@prisma.io', createdAt: new Date(), - role: 'SELLER' + role: 'USER' }, { name: 'Mosse', @@ -19,4 +19,59 @@ export const userData: Prisma.UserCreateInput[] = [ createdAt: new Date(), role: 'USER' }, + { + name: 'doug', + email: 'doug@prisma.io', + createdAt: new Date(), + role: 'USER' + }, + { + name: 'molda', + email: 'molda@prisma.io', + createdAt: new Date(), + role: 'USER' + }, + { + name: 'pierro', + email: 'pierro@prisma.io', + createdAt: new Date(), + role: 'USER' + }, + { + name: 'brian', + email: 'brian@prisma.io', + createdAt: new Date(), + role: 'USER' + }, + { + name: 'benji', + email: 'benji@prisma.io', + createdAt: new Date(), + role: 'USER' + }, + { + name: 'abdel', + email: 'abdel@prisma.io', + createdAt: new Date(), + role: 'USER' + }, + { + name: 'guillaume', + email: 'guillaume@prisma.io', + createdAt: new Date(), + role: 'USER' + }, + { + name: 'roger', + email: 'roger@prisma.io', + createdAt: new Date(), + role: 'USER' + }, + { + name: 'jacko', + email: 'jacko@prisma.io', + createdAt: new Date(), + role: 'USER' + }, + ] \ No newline at end of file