Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions packages/db/src/schemas/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export const users = pgTable("user", {
email: text("email").notNull(),
emailVerified: timestamp("emailVerified", { mode: "date" }),
image: text("image"),
}, (table) => ({
emailIdx: index("user_email_idx").on(table.email),
nameIdx: index("user_name_idx").on(table.name),
}));
}, (table) => [
index("user_email_idx").on(table.email),
index("user_name_idx").on(table.name),
]);

export const accounts = pgTable(
"account",
Expand All @@ -29,12 +29,12 @@ export const accounts = pgTable(
id_token: text("id_token"),
session_state: text("session_state"),
},
(account) => ({
compoundKey: primaryKey({
(account) => [
primaryKey({
columns: [account.provider, account.providerAccountId],
}),
userIdIdx: index("account_user_id_idx").on(account.userId),
})
index("account_user_id_idx").on(account.userId),
]
);

export const sessions = pgTable("session", {
Expand All @@ -43,9 +43,9 @@ export const sessions = pgTable("session", {
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
expires: timestamp("expires", { mode: "date" }).notNull(),
}, (table) => ({
userIdIdx: index("session_user_id_idx").on(table.userId),
}));
}, (table) => [
index("session_user_id_idx").on(table.userId),
]);

export const verificationTokens = pgTable(
"verificationToken",
Expand All @@ -54,7 +54,7 @@ export const verificationTokens = pgTable(
token: text("token").notNull(),
expires: timestamp("expires", { mode: "date" }).notNull(),
},
(vt) => ({
compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
})
(vt) => [
primaryKey({ columns: [vt.identifier, vt.token] }),
]
);
36 changes: 18 additions & 18 deletions packages/db/src/schemas/hackathons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ export const hackathons = pgTable("hackathon", {
isPublic: boolean("is_public").notNull().default(true),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
}, (table) => ({
statusIdx: index("hackathon_status_idx").on(table.status),
}));
}, (table) => [
index("hackathon_status_idx").on(table.status),
]);

// Teams for hackathons
export const hackathonTeams = pgTable("hackathon_team", {
Expand All @@ -44,10 +44,10 @@ export const hackathonTeams = pgTable("hackathon_team", {
isOpen: boolean("is_open").notNull().default(true),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
}, (table) => ({
hackathonIdIdx: index("team_hackathon_id_idx").on(table.hackathonId),
captainIdIdx: index("team_captain_id_idx").on(table.captainId),
}));
}, (table) => [
index("team_hackathon_id_idx").on(table.hackathonId),
index("team_captain_id_idx").on(table.captainId),
]);

// Individual participants
export const hackathonParticipants = pgTable("hackathon_participant", {
Expand Down Expand Up @@ -82,13 +82,13 @@ export const hackathonParticipants = pgTable("hackathon_participant", {

registeredAt: timestamp("registered_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
}, (table) => ({
hackathonIdIdx: index("participant_hackathon_id_idx").on(table.hackathonId),
userIdIdx: index("participant_user_id_idx").on(table.userId),
teamIdIdx: index("participant_team_id_idx").on(table.teamId),
}, (table) => [
index("participant_hackathon_id_idx").on(table.hackathonId),
index("participant_user_id_idx").on(table.userId),
index("participant_team_id_idx").on(table.teamId),
// Compound for quick check "is this user in this hackathon?"
hackathonUserIdx: index("participant_hackathon_user_idx").on(table.hackathonId, table.userId),
}));
index("participant_hackathon_user_idx").on(table.hackathonId, table.userId),
]);

// Project submissions
export const hackathonProjects = pgTable("hackathon_project", {
Expand All @@ -113,11 +113,11 @@ export const hackathonProjects = pgTable("hackathon_project", {
submittedAt: timestamp("submitted_at"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
}, (table) => ({
hackathonIdIdx: index("project_hackathon_id_idx").on(table.hackathonId),
teamIdIdx: index("project_team_id_idx").on(table.teamId),
statusIdx: index("project_status_idx").on(table.status),
}));
}, (table) => [
index("project_hackathon_id_idx").on(table.hackathonId),
index("project_team_id_idx").on(table.teamId),
index("project_status_idx").on(table.status),
]);

// Relations
export const hackathonsRelations = relations(hackathons, ({ many }) => ({
Expand Down
48 changes: 24 additions & 24 deletions packages/db/src/schemas/judge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export const judges = pgTable("judge", {
isActive: boolean("is_active").notNull().default(true),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
}, (table) => ({
userIdIdx: index("judge_user_id_idx").on(table.userId),
}));
}, (table) => [
index("judge_user_id_idx").on(table.userId),
]);

export const judgeAssignments = pgTable("judge_assignment", {
id: uuid("id").defaultRandom().primaryKey(),
Expand All @@ -28,10 +28,10 @@ export const judgeAssignments = pgTable("judge_assignment", {
.references(() => hackathons.id, { onDelete: "cascade" }),
assignedAt: timestamp("assigned_at").defaultNow().notNull(),
isLead: boolean("is_lead").notNull().default(false),
}, (table) => ({
judgeIdIdx: index("assignment_judge_id_idx").on(table.judgeId),
hackathonIdIdx: index("assignment_hackathon_id_idx").on(table.hackathonId),
}));
}, (table) => [
index("assignment_judge_id_idx").on(table.judgeId),
index("assignment_hackathon_id_idx").on(table.hackathonId),
]);


// Projects with table numbers for judging (extends hackathon projects concept)
Expand All @@ -48,10 +48,10 @@ export const judgingProjects = pgTable("judging_project", {
projectUrl: text("project_url"),
repoUrl: text("repo_url"),
createdAt: timestamp("created_at").defaultNow().notNull(),
}, (table) => ({
hackathonIdIdx: index("judging_project_hackathon_id_idx").on(table.hackathonId),
tableNumberIdx: index("judging_project_table_idx").on(table.tableNumber),
}));
}, (table) => [
index("judging_project_hackathon_id_idx").on(table.hackathonId),
index("judging_project_table_idx").on(table.tableNumber),
]);

// Judge votes/scores for projects
export const judgeVotes = pgTable("judge_vote", {
Expand All @@ -72,12 +72,12 @@ export const judgeVotes = pgTable("judge_vote", {
comment: text("comment"),
votedAt: timestamp("voted_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
}, (table) => ({
judgeIdIdx: index("vote_judge_id_idx").on(table.judgeId),
projectIdIdx: index("vote_project_id_idx").on(table.projectId),
}, (table) => [
index("vote_judge_id_idx").on(table.judgeId),
index("vote_project_id_idx").on(table.projectId),
// Compound to enforce one vote per judge per project (app logic does this, index speeds up check)
uniqueVoteIdx: index("vote_unique_idx").on(table.judgeId, table.projectId),
}));
index("vote_unique_idx").on(table.judgeId, table.projectId),
]);

// Map images for hackathon venues
export const hackathonMaps = pgTable("hackathon_map", {
Expand All @@ -89,9 +89,9 @@ export const hackathonMaps = pgTable("hackathon_map", {
name: text("name"),
order: integer("order").notNull().default(0),
createdAt: timestamp("created_at").defaultNow().notNull(),
}, (table) => ({
hackathonIdIdx: index("map_hackathon_id_idx").on(table.hackathonId),
}));
}, (table) => [
index("map_hackathon_id_idx").on(table.hackathonId),
]);

// Track which tables a judge still needs to visit
export const judgeQueue = pgTable("judge_queue", {
Expand All @@ -108,12 +108,12 @@ export const judgeQueue = pgTable("judge_queue", {
order: integer("order").notNull(), // order to visit
isCompleted: boolean("is_completed").notNull().default(false),
completedAt: timestamp("completed_at"),
}, (table) => ({
judgeIdIdx: index("queue_judge_id_idx").on(table.judgeId),
hackathonIdIdx: index("queue_hackathon_id_idx").on(table.hackathonId),
}, (table) => [
index("queue_judge_id_idx").on(table.judgeId),
index("queue_hackathon_id_idx").on(table.hackathonId),
// Critical for "next table" logic
todoIdx: index("queue_todo_idx").on(table.judgeId, table.hackathonId, table.isCompleted),
}));
index("queue_todo_idx").on(table.judgeId, table.hackathonId, table.isCompleted),
]);

// Relations
export const judgesRelations = relations(judges, ({ one, many }) => ({
Expand Down
20 changes: 10 additions & 10 deletions packages/db/src/schemas/members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export const userProfiles = pgTable("user_profile", {
location: text("location"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
}, (table) => ({
userIdIdx: index("profile_user_id_idx").on(table.userId),
}));
}, (table) => [
index("profile_user_id_idx").on(table.userId),
]);

export const members = pgTable("member", {
id: uuid("id").defaultRandom().primaryKey(),
Expand Down Expand Up @@ -44,11 +44,11 @@ export const members = pgTable("member", {
portfolioUrl: text("portfolio_url"),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
}, (table) => ({
userIdIdx: index("member_user_id_idx").on(table.userId),
}, (table) => [
index("member_user_id_idx").on(table.userId),
// Optimized for "Active Members" directory listing
activeTypeIdx: index("member_active_type_idx").on(table.isActive, table.memberType),
}));
index("member_active_type_idx").on(table.isActive, table.memberType),
]);

export const membershipHistory = pgTable("membership_history", {
id: uuid("id").defaultRandom().primaryKey(),
Expand All @@ -60,9 +60,9 @@ export const membershipHistory = pgTable("membership_history", {
endDate: timestamp("end_date"),
notes: text("notes"),
createdAt: timestamp("created_at").defaultNow().notNull(),
}, (table) => ({
memberIdIdx: index("history_member_id_idx").on(table.memberId),
}));
}, (table) => [
index("history_member_id_idx").on(table.memberId),
]);

export const usersRelations = relations(users, ({ one }) => ({
profile: one(userProfiles, {
Expand Down
12 changes: 6 additions & 6 deletions packages/db/src/schemas/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export const auditLogs = pgTable("audit_logs", {
metadata: jsonb("metadata"),
severity: securitySeverityEnum("severity").default("info").notNull(),
createdAt: timestamp("created_at", { mode: "date" }).defaultNow().notNull(),
}, (table) => ({
userIdIdx: index("audit_user_id_idx").on(table.userId),
actionIdx: index("audit_action_idx").on(table.action),
createdAtIdx: index("audit_created_at_idx").on(table.createdAt),
severityIdx: index("audit_severity_idx").on(table.severity),
}));
}, (table) => [
index("audit_user_id_idx").on(table.userId),
index("audit_action_idx").on(table.action),
index("audit_created_at_idx").on(table.createdAt),
index("audit_severity_idx").on(table.severity),
]);
8 changes: 4 additions & 4 deletions packages/db/src/schemas/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export const stripePayments = pgTable("stripe_payment", {
metadata: text("metadata"), // JSON string for any extra Stripe metadata
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
}, (table) => ({
customerEmailIdx: index("stripe_payment_customer_email_idx").on(table.customerEmail),
linkedUserIdIdx: index("stripe_payment_linked_user_id_idx").on(table.linkedUserId),
}));
}, (table) => [
index("stripe_payment_customer_email_idx").on(table.customerEmail),
index("stripe_payment_linked_user_id_idx").on(table.linkedUserId),
]);

/**
* Links users who signed in with a different email (e.g., Google)
Expand Down
35 changes: 17 additions & 18 deletions sites/mainweb/components/portal/LinkStripeAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ export default function LinkStripeAccount({ onSuccess }: LinkStripeAccountProps)
},
});

const payMutation = trpc.stripe.createCheckoutSession.useMutation({
onSuccess: (data) => {
if (data?.url) {
window.location.href = data.url;
}
},
onError: (err) => {
setError(err.message);
},
});

const handlePay = () => {
setError(null);
payMutation.mutate({ returnUrl: window.location.href });
};
// const payMutation = trpc.stripe.createCheckoutSession.useMutation({
// onSuccess: (data) => {
// if (data?.url) {
// window.location.href = data.url;
// }
// },
// onError: (err) => {
// setError(err.message);
// },
// });

// const handlePay = () => {
// setError(null);
// payMutation.mutate({ returnUrl: window.location.href });
// };

const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
Expand Down Expand Up @@ -137,11 +137,10 @@ export default function LinkStripeAccount({ onSuccess }: LinkStripeAccountProps)

<div className="mt-auto space-y-3">
<button
onClick={handlePay}
disabled={payMutation.isPending}
onClick={() => window.open('https://linktr.ee/PLACEHOLDER', '_blank')}
className="w-full py-4 px-4 bg-[#00A8A8] text-black hover:bg-[#00A8A8]/90 text-xs font-bold tracking-[0.2em] uppercase transition-all rounded shadow-[0_0_20px_rgba(0,168,168,0.3)] hover:shadow-[0_0_30px_rgba(0,168,168,0.5)]"
>
{payMutation.isPending ? 'Initiating...' : 'Initialize Membership'}
Initialize Membership
</button>

<button
Expand Down
Loading