Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into speakers
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavvraja committed Nov 1, 2024
2 parents d243c3d + 107267d commit 4413085
Show file tree
Hide file tree
Showing 25 changed files with 1,216 additions and 577 deletions.
125 changes: 125 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.1",
"@radix-ui/react-radio-group": "^1.2.1",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tabs": "^1.1.0",
"@react-email/components": "^0.0.25",
"@react-email/tailwind": "0.1.0",
"@react-three/drei": "^9.114.0",
"@studio-freight/lenis": "^1.0.42",
"@tabler/icons-react": "^3.21.0",
"@tanstack/react-query": "^5.56.2",
"@types/canvas-confetti": "^1.6.4",
"@types/ioredis": "^4.28.10",
Expand All @@ -51,6 +53,7 @@
"gsap": "^3.12.5",
"ioredis": "^5.4.1",
"jest": "^29.7.0",
"ldrs": "^1.0.2",
"lenis": "^1.1.13",
"lodash.debounce": "^4.0.8",
"lucide-react": "^0.441.0",
Expand All @@ -61,6 +64,7 @@
"razorpay": "^2.9.4",
"react": "^18.3.1",
"react-dom": "^18",
"react-dropzone": "^14.2.10",
"react-email": "^3.0.1",
"react-hook-form": "^7.53.0",
"react-icons": "^5.3.0",
Expand Down
Binary file modified prisma/dev.db
Binary file not shown.
Binary file modified prisma/dev.db-journal
Binary file not shown.
26 changes: 26 additions & 0 deletions prisma/migrations/20241101021543_food/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Form" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"usn" TEXT,
"email" TEXT NOT NULL,
"contact" TEXT,
"designation" TEXT,
"foodPreference" TEXT NOT NULL DEFAULT 'veg',
"photo_url" TEXT NOT NULL,
"college_id_card" TEXT,
"entity_name" TEXT,
"referral_used" TEXT,
"paid_amount" REAL NOT NULL,
"created_by_id" TEXT NOT NULL,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Form_created_by_id_fkey" FOREIGN KEY ("created_by_id") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "Form_referral_used_fkey" FOREIGN KEY ("referral_used") REFERENCES "Referral" ("code") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Form" ("college_id_card", "contact", "created_at", "created_by_id", "designation", "email", "entity_name", "id", "name", "paid_amount", "photo_url", "referral_used", "usn") SELECT "college_id_card", "contact", "created_at", "created_by_id", "designation", "email", "entity_name", "id", "name", "paid_amount", "photo_url", "referral_used", "usn" FROM "Form";
DROP TABLE "Form";
ALTER TABLE "new_Form" RENAME TO "Form";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
32 changes: 32 additions & 0 deletions prisma/migrations/20241101022120_food_typo/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Warnings:
- You are about to drop the column `foodPreference` on the `Form` table. All the data in the column will be lost.
*/
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Form" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"usn" TEXT,
"email" TEXT NOT NULL,
"contact" TEXT,
"designation" TEXT,
"food_preference" TEXT NOT NULL DEFAULT 'veg',
"photo_url" TEXT NOT NULL,
"college_id_card" TEXT,
"entity_name" TEXT,
"referral_used" TEXT,
"paid_amount" REAL NOT NULL,
"created_by_id" TEXT NOT NULL,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Form_created_by_id_fkey" FOREIGN KEY ("created_by_id") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "Form_referral_used_fkey" FOREIGN KEY ("referral_used") REFERENCES "Referral" ("code") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Form" ("college_id_card", "contact", "created_at", "created_by_id", "designation", "email", "entity_name", "id", "name", "paid_amount", "photo_url", "referral_used", "usn") SELECT "college_id_card", "contact", "created_at", "created_by_id", "designation", "email", "entity_name", "id", "name", "paid_amount", "photo_url", "referral_used", "usn" FROM "Form";
DROP TABLE "Form";
ALTER TABLE "new_Form" RENAME TO "Form";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
20 changes: 20 additions & 0 deletions prisma/migrations/20241101062227_coupon_typo/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Referral" (
"id" TEXT NOT NULL PRIMARY KEY,
"code" TEXT NOT NULL,
"discount_percentage" TEXT NOT NULL DEFAULT '20',
"createdby_id" TEXT NOT NULL,
"usedby_id" TEXT,
"isUsed" BOOLEAN NOT NULL DEFAULT false,
"created_at" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "Referral_createdby_id_fkey" FOREIGN KEY ("createdby_id") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "Referral_usedby_id_fkey" FOREIGN KEY ("usedby_id") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Referral" ("code", "created_at", "createdby_id", "discount_percentage", "id", "isUsed", "usedby_id") SELECT "code", "created_at", "createdby_id", "discount_percentage", "id", "isUsed", "usedby_id" FROM "Referral";
DROP TABLE "Referral";
ALTER TABLE "new_Referral" RENAME TO "Referral";
CREATE UNIQUE INDEX "Referral_code_key" ON "Referral"("code");
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
31 changes: 16 additions & 15 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,26 @@ model Referral {
isUsed Boolean @default(false)
created_at DateTime @default(now())
createdBy User @relation("createdByUser", fields: [createdById], references: [id], onDelete: Cascade) // Admin who created the referral
usedBy User? @relation("usedByUser", fields: [usedById], references: [email])
createdBy User @relation("createdByUser", fields: [createdById], references: [id], onDelete: Cascade)
usedBy User? @relation("usedByUser", fields: [usedById], references: [id])
forms Form[]
}

model Form {
id String @id @default(cuid())
name String
usn String?
email String
contact String?
designation String?
photo String @map("photo_url") // URL of the photo uploaded by the participan
collegeIdCard String? @map("college_id_card")
entityName String @map("entity_name")
referralUsed String? @map("referral_used")
paidAmount Float @map("paid_amount")
createdById String @map("created_by_id")
created_at DateTime @default(now())
id String @id @default(cuid())
name String
usn String?
email String
contact String?
designation String?
foodPreference String @default("veg") @map("food_preference")
photo String @map("photo_url") // URL of the photo uploaded by the participan
collegeIdCard String? @map("college_id_card")
entityName String? @map("entity_name")
referralUsed String? @map("referral_used")
paidAmount Float @map("paid_amount")
createdById String @map("created_by_id")
created_at DateTime @default(now())
//registrationEmailSent Boolean? @default(false) @map("registration_email_sent")
user User @relation(fields: [createdById], references: [id], onDelete: Cascade)
Expand Down
20 changes: 12 additions & 8 deletions src/app/actions/invalidate-coupon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
import prisma from "@/server/db";
import { type Session as NextAuthSession } from "next-auth";
export async function invalidateCouponCode(couponCode: string, session: NextAuthSession) {
console.log("coupon code = "+couponCode , "session = " + session.user.id)
if (!couponCode) return;
const resp = await prisma.referral.update({
where: {
code: couponCode,
return await prisma.referral.update({
where:{
code:couponCode,
},
data: {
isUsed: true,
usedById: session.user.id,
},
});
data:{
isUsed:true,
usedById:session.user.id
}

})


}
5 changes: 3 additions & 2 deletions src/app/actions/submit-form.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use server";

import { FormDataInterface } from "@/components/common/registration-form";
import { getServerSideSession } from "@/lib/get-server-session";
import prisma from "@/server/db";
import { FormDataInterface } from "@/types";

export async function submitForm(data: FormDataInterface, amount: number) {
const session = await getServerSideSession();
Expand All @@ -15,13 +15,14 @@ export async function submitForm(data: FormDataInterface, amount: number) {
name: data.name,
usn: data.usn,
email: data.email,
foodPreference:data.foodPreference,
contact: data.phone,
designation: data.designation,
paidAmount: amount,
photo: data.photo,
collegeIdCard: data.idCard,
createdById: session.user.id,
entityName: data.name,
entityName: data.entityName,
},
});
}
Loading

0 comments on commit 4413085

Please sign in to comment.