From 4e78ff2de9247e60f352c24b4da71cf26c48a734 Mon Sep 17 00:00:00 2001 From: i701 Date: Sat, 30 Nov 2024 23:37:35 +0500 Subject: [PATCH] Update user schema and forms to include address and consent fields - Replaced 'house_name' with 'address' in user schema and related files. - Added new fields for terms and privacy policy acceptance in the signup form schema. - Updated package.json and package-lock.json to include @radix-ui/react-checkbox for checkbox functionality. - Modified seed script to reflect changes in the user model. --- lib/schemas.ts | 12 +++++++++++- package-lock.json | 30 ++++++++++++++++++++++++++++++ package.json | 1 + prisma/schema.prisma | 17 ++++++++++++++++- prisma/seed.ts | 2 +- 5 files changed, 59 insertions(+), 3 deletions(-) diff --git a/lib/schemas.ts b/lib/schemas.ts index 400d90c..59e1e56 100644 --- a/lib/schemas.ts +++ b/lib/schemas.ts @@ -9,11 +9,21 @@ export const signUpFormSchema = z.object({ island_id: z .string({ required_error: "Island is required." }) .min(2, { message: "Island is required." }), - house_name: z.string().min(2, { message: "House name is required." }), + address: z.string().min(2, { message: "address is required." }), dob: z.coerce.date({ message: "Date of birth is required." }), phone_number: z .string() .min(7, { message: "Phone number is required." }) .regex(/^[79][0-9]{2}[0-9]{4}$/, "Please enter a valid phone number") .transform((val) => val.replace(/\D/g, "")), + terms: z + .string({ + required_error: "You must accept the terms and conditions", + }) + .transform((val) => val === "on"), + policy: z + .string({ + required_error: "You must accept the privacy policy", + }) + .transform((val) => val === "on"), }); diff --git a/package-lock.json b/package-lock.json index e6f464f..f0e25fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@hookform/resolvers": "^3.9.1", "@prisma/client": "^5.22.0", "@radix-ui/react-alert-dialog": "^1.1.2", + "@radix-ui/react-checkbox": "^1.1.2", "@radix-ui/react-collapsible": "^1.1.1", "@radix-ui/react-dialog": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.1.2", @@ -1591,6 +1592,35 @@ } } }, + "node_modules/@radix-ui/react-checkbox": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.1.2.tgz", + "integrity": "sha512-/i0fl686zaJbDQLNKrkCbMyDm6FQMt4jg323k7HuqitoANm9sE23Ql8yOK3Wusk34HSLKDChhMux05FnP6KUkw==", + "dependencies": { + "@radix-ui/primitive": "1.1.0", + "@radix-ui/react-compose-refs": "1.1.0", + "@radix-ui/react-context": "1.1.1", + "@radix-ui/react-presence": "1.1.1", + "@radix-ui/react-primitive": "2.0.0", + "@radix-ui/react-use-controllable-state": "1.1.0", + "@radix-ui/react-use-previous": "1.1.0", + "@radix-ui/react-use-size": "1.1.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-collapsible": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.1.1.tgz", diff --git a/package.json b/package.json index 27d2277..6ade3cb 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "@hookform/resolvers": "^3.9.1", "@prisma/client": "^5.22.0", "@radix-ui/react-alert-dialog": "^1.1.2", + "@radix-ui/react-checkbox": "^1.1.2", "@radix-ui/react-collapsible": "^1.1.1", "@radix-ui/react-dialog": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.1.2", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b0f0b0a..4f66963 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -21,7 +21,7 @@ model User { firstPaymentDone Boolean @default(false) verified Boolean @default(false) // island String? - house_name String? + address String? id_card String? @unique dob DateTime? atoll Atoll? @relation(fields: [atollId], references: [id]) @@ -32,6 +32,10 @@ model User { updatedAt DateTime @updatedAt phoneNumber String @unique phoneNumberVerified Boolean @default(false) + termsAccepted Boolean @default(false) + policyAccepted Boolean @default(false) + + devices Device[] role String? lang String? @@ -102,3 +106,14 @@ model Island { updatedAt DateTime @updatedAt User User[] } + +model Device { + id String @id @default(cuid()) + name String + mac String + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + User User? @relation(fields: [userId], references: [id]) + userId String? +} diff --git a/prisma/seed.ts b/prisma/seed.ts index 1d1d8c3..de6b1d8 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -12,7 +12,7 @@ async function main() { emailVerified: false, firstPaymentDone: false, verified: false, - house_name: faker.location.streetAddress(), + address: faker.location.streetAddress(), id_card: `A${Math.round(Math.random() * 999999)}`, dob: faker.date.between({ from: "1900-01-01",