diff --git a/apps/bot/bot.ts b/apps/bot/bot.ts index 92140193..8a39735c 100644 --- a/apps/bot/bot.ts +++ b/apps/bot/bot.ts @@ -200,7 +200,7 @@ app.post("/api/checkDiscordVerification", async (h) => { } console.log("got here 2"); - const user = await getHacker(verification.clerkID, false); + const user = await getHacker(verification.clerkID); console.log("got here 2 with user", user); if (!user) { console.log("failed cause of no user in db"); diff --git a/apps/infrastructure-migrator/driver.ts b/apps/infrastructure-migrator/driver.ts index 012bdc1e..5e6b180f 100644 --- a/apps/infrastructure-migrator/driver.ts +++ b/apps/infrastructure-migrator/driver.ts @@ -30,8 +30,6 @@ const allUserHackerDataPromise = dbPostgres.query.userHackerData.findMany(); const allEventsPromise = dbPostgres.query.events.findMany(); const allFilesPromise = dbPostgres.query.files.findMany(); const allScansPromise = dbPostgres.query.scans.findMany(); -const allTeamsPromise = dbPostgres.query.teams.findMany(); -const allInvitesPromise = dbPostgres.query.invites.findMany(); const allErrorLogsPromise = dbPostgres.query.errorLog.findMany(); const alldiscordVerificationPromise = dbPostgres.query.discordVerification.findMany(); @@ -56,8 +54,6 @@ async function migratePostgresSqLite() { allEvents, allFiles, allScans, - allTeams, - allInvites, allErrorLogs, alldiscordVerification, allTickets, @@ -71,8 +67,6 @@ async function migratePostgresSqLite() { allEventsPromise, allFilesPromise, allScansPromise, - allTeamsPromise, - allInvitesPromise, allErrorLogsPromise, alldiscordVerificationPromise, allTicketsPromise, @@ -133,22 +127,6 @@ async function migratePostgresSqLite() { console.log("Migrated Scans ✅\n\n"); - console.log("Migrating Teams 🏆"); - - if (allTeams.length > 0) { - await db.insert(schema.teams).values(allTeams); - } - - console.log("Migrated Teams ✅\n\n"); - - console.log("Migrating Invites 💌"); - - if (allInvites.length > 0) { - await db.insert(schema.invites).values(allInvites); - } - - console.log("Migrated Invites ✅\n\n"); - console.log("Migrating Error Logs 📝"); if (allErrorLogs.length > 0) { diff --git a/apps/infrastructure-migrator/schema.ts b/apps/infrastructure-migrator/schema.ts index c326c277..c050daa5 100644 --- a/apps/infrastructure-migrator/schema.ts +++ b/apps/infrastructure-migrator/schema.ts @@ -132,8 +132,6 @@ export const userHackerData = pgTable("user_hacker_data", { // metadata group: integer("group").notNull(), - teamID: varchar("team_id", { length: 50 }), - points: integer("points").notNull().default(0), hasAcceptedMLHCoC: boolean("has_accepted_mlh_coc").notNull(), hasSharedDataWithMLH: boolean("has_shared_data_with_mlh").notNull(), isEmailable: boolean("is_emailable").notNull(), @@ -146,11 +144,6 @@ export const userHackerRelations = relations( fields: [userHackerData.clerkID], references: [userCommonData.clerkID], }), - team: one(teams, { - fields: [userHackerData.teamID], - references: [teams.id], - }), - invites: many(invites), }), ); @@ -160,7 +153,6 @@ export const events = pgTable("events", { startTime: timestamp("start_time").notNull(), endTime: timestamp("end_time").notNull(), location: varchar("location", { length: 255 }).default("TBD"), - points: integer("points").notNull().default(0), description: text("description").notNull(), type: varchar("type", { length: 50 }).notNull(), host: varchar("host", { length: 255 }), @@ -211,46 +203,6 @@ export const scansRelations = relations(scans, ({ one }) => ({ }), })); -export const teams = pgTable("teams", { - id: varchar("id", { length: 50 }).notNull().primaryKey().unique(), - name: varchar("name", { length: 255 }).notNull(), - tag: varchar("tag", { length: 50 }).notNull().unique(), - bio: text("bio"), - photo: varchar("photo", { length: 400 }).notNull(), - createdAt: timestamp("created_at").notNull().defaultNow(), - ownerID: varchar("owner_id", { length: 255 }).notNull(), - devpostURL: varchar("devpost_url", { length: 255 }), -}); - -export const teamsRelations = relations(teams, ({ one, many }) => ({ - members: many(userHackerData), - invites: many(invites), -})); - -export const invites = pgTable( - "invites", - { - inviteeID: varchar("invitee_id", { length: 255 }).notNull(), - teamID: varchar("team_id", { length: 50 }).notNull(), - createdAt: timestamp("created_at").notNull().defaultNow(), - status: inviteType("status").notNull().default("pending"), - }, - (table) => ({ - id: primaryKey(table.inviteeID, table.teamID), - }), -); - -export const invitesRelations = relations(invites, ({ one }) => ({ - invitee: one(userHackerData, { - fields: [invites.inviteeID], - references: [userHackerData.clerkID], - }), - team: one(teams, { - fields: [invites.teamID], - references: [teams.id], - }), -})); - export const errorLog = pgTable("error_log", { id: varchar("id", { length: 50 }).notNull().primaryKey(), createdAt: timestamp("created_at").notNull().defaultNow(), diff --git a/apps/web/src/actions/admin/registration-actions.ts b/apps/web/src/actions/admin/registration-actions.ts index 1d069199..9ad5c027 100644 --- a/apps/web/src/actions/admin/registration-actions.ts +++ b/apps/web/src/actions/admin/registration-actions.ts @@ -32,17 +32,6 @@ export const toggleRegistrationMessageEnabled = adminAction return { success: true, statusSet: enabled }; }); -export const toggleSecretRegistrationEnabled = adminAction - .schema(defaultRegistrationToggleSchema) - .action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => { - await redisSet( - "config:registration:secretRegistrationEnabled", - enabled, - ); - revalidatePath("/admin/toggles/registration"); - return { success: true, statusSet: enabled }; - }); - export const toggleRSVPs = adminAction .schema(defaultRegistrationToggleSchema) .action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => { diff --git a/apps/web/src/actions/teams.ts b/apps/web/src/actions/teams.ts index a257024c..e69de29b 100644 --- a/apps/web/src/actions/teams.ts +++ b/apps/web/src/actions/teams.ts @@ -1,87 +0,0 @@ -"use server"; - -// TODO: update team /api endpoints to be actions -import { authenticatedAction } from "@/lib/safe-action"; -import { boolean, string, z } from "zod"; -import { db } from "db"; -import { userHackerData, teams, invites } from "db/schema"; -import { eq } from "db/drizzle"; -import { revalidatePath } from "next/cache"; -import { getHacker } from "db/functions"; -import { returnValidationErrors } from "next-safe-action"; - -export const leaveTeam = authenticatedAction - .outputSchema( - z.object({ - success: z.boolean(), - message: z.string(), - }), - ) - .action(async ({ ctx: { userId } }) => { - const user = await getHacker(userId, false); - if (!user) - returnValidationErrors(z.null(), { _errors: ["User not found"] }); - - if (!user.hackerData.teamID) { - revalidatePath("/dash/team"); - return { - success: false, - message: "User is not on a team", - }; - } - - const result = await db.transaction(async (tx) => { - await tx - .update(userHackerData) - .set({ teamID: null }) - .where(eq(userHackerData.clerkID, user.clerkID)); - const team = await tx.query.teams.findFirst({ - where: eq(teams.id, user.hackerData.teamID as string), // Converted to string since TS does not realise for some reason that we checked above. - with: { - members: { - with: { - commonData: true, - }, - }, - }, - }); - - if (!team) { - revalidatePath("/dash/team"); - return { - success: false, - message: "Team not found.", - }; - } - - if (team.members.length < 1) { - await tx.delete(teams).where(eq(teams.id, team.id)); - await tx.delete(invites).where(eq(invites.teamID, team.id)); - revalidatePath("/dash/team"); - return { - success: true, - message: - "Team has been left. Team has been deleted since it has no members.", - }; - } - - if (team.ownerID == userId) { - await tx - .update(teams) - .set({ ownerID: team.members[0].clerkID }) - .where(eq(teams.id, team.id)); - revalidatePath("/dash/team"); - return { - success: true, - message: `Team has been left. Ownership has been transferred to ${team.members[0].commonData.firstName} ${team.members[0].commonData.lastName}.`, - }; - } - revalidatePath("/dash/team"); - return { - success: true, - message: "Team has been left.", - }; - }); - - return result; - }); diff --git a/apps/web/src/app/admin/scanner/[id]/page.tsx b/apps/web/src/app/admin/scanner/[id]/page.tsx index ac0958fb..473be983 100644 --- a/apps/web/src/app/admin/scanner/[id]/page.tsx +++ b/apps/web/src/app/admin/scanner/[id]/page.tsx @@ -49,7 +49,7 @@ export default async function Page({ ); } - const scanUser = await getHacker(searchParams.user, false); + const scanUser = await getHacker(searchParams.user); const scan = !scanUser ? null diff --git a/apps/web/src/app/admin/toggles/layout.tsx b/apps/web/src/app/admin/toggles/layout.tsx index b56bb32d..71e48895 100644 --- a/apps/web/src/app/admin/toggles/layout.tsx +++ b/apps/web/src/app/admin/toggles/layout.tsx @@ -10,15 +10,11 @@ export default function Layout({ children }: ToggleLayoutProps) {
- + -
{children}
diff --git a/apps/web/src/app/admin/toggles/registration/page.tsx b/apps/web/src/app/admin/toggles/registration/page.tsx index 841fe64d..626b97d7 100644 --- a/apps/web/src/app/admin/toggles/registration/page.tsx +++ b/apps/web/src/app/admin/toggles/registration/page.tsx @@ -4,14 +4,11 @@ import { parseRedisBoolean, parseRedisNumber } from "@/lib/utils/server/redis"; import c from "config"; export default async function Page() { - const [ - defaultRegistrationEnabled, - defaultSecretRegistrationEnabled, - defaultRSVPsEnabled, - defaultRSVPLimit, - ]: (string | null)[] = await redisMGet( + const [defaultRegistrationEnabled, defaultRSVPsEnabled, defaultRSVPLimit]: ( + | string + | null + )[] = await redisMGet( "config:registration:registrationEnabled", - "config:registration:secretRegistrationEnabled", "config:registration:allowRSVPs", "config:registration:maxRSVPs", ); @@ -28,10 +25,6 @@ export default async function Page() { defaultRegistrationEnabled, true, )} - defaultSecretRegistrationEnabled={parseRedisBoolean( - defaultSecretRegistrationEnabled, - false, - )} defaultRSVPsEnabled={parseRedisBoolean( defaultRSVPsEnabled, true, diff --git a/apps/web/src/app/admin/users/[slug]/page.tsx b/apps/web/src/app/admin/users/[slug]/page.tsx index 951b148a..a3a64ef4 100644 --- a/apps/web/src/app/admin/users/[slug]/page.tsx +++ b/apps/web/src/app/admin/users/[slug]/page.tsx @@ -8,7 +8,6 @@ import { AccountInfo, PersonalInfo, ProfileInfo, - TeamInfo, } from "@/components/admin/users/ServerSections"; import { auth } from "@clerk/nextjs/server"; import { notFound } from "next/navigation"; @@ -25,7 +24,7 @@ export default async function Page({ params }: { params: { slug: string } }) { const admin = await getUser(userId); if (!admin || !isUserAdmin(admin)) return notFound(); - const user = await getHacker(params.slug, true); + const user = await getHacker(params.slug); if (!user) { return

User Not Found

; @@ -104,7 +103,6 @@ export default async function Page({ params }: { params: { slug: string } }) { - diff --git a/apps/web/src/app/api/team/create/route.ts b/apps/web/src/app/api/team/create/route.ts deleted file mode 100644 index 435b796b..00000000 --- a/apps/web/src/app/api/team/create/route.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { auth } from "@clerk/nextjs/server"; -import { NextResponse } from "next/server"; -import { db } from "db"; -import { eq } from "db/drizzle"; -import { userHackerData, teams } from "db/schema"; -import { getHacker } from "db/functions"; -import { newTeamValidator } from "@/validators/shared/team"; -import { nanoid } from "nanoid"; -import c from "config"; -import { logError } from "@/lib/utils/server/logError"; - -export async function POST(req: Request) { - const { userId } = await auth(); - if (!userId) return new Response("Unauthorized", { status: 401 }); - - const user = await getHacker(userId, false); - if (!user) return new Response("Unauthorized", { status: 401 }); - - if (user.hackerData.teamID) { - return NextResponse.json({ - success: false, - message: - "You are already on a team. Leave your current team to create a new one.", - }); - } - - const rawBody = await req.json(); - const body = newTeamValidator.safeParse(rawBody); - - if (!body.success) { - return NextResponse.json({ - success: false, - message: body.error.message, - }); - } - - const teamID = nanoid(); - - try { - await db.transaction(async (tx) => { - await tx.insert(teams).values({ - id: teamID, - name: body.data.name, - tag: body.data.tag, - photo: body.data.photo, - ownerID: userId, - }); - await tx - .update(userHackerData) - .set({ teamID }) - .where(eq(userHackerData.clerkID, userId)); - }); - return NextResponse.json({ - success: true, - message: body.data.tag, - }); - } catch (e) { - const errorID = await logError({ - error: e, - userID: userId, - route: "/api/team/create", - }); - return NextResponse.json({ - success: false, - message: `An error occurred while creating your team. If this is a continuing issue, please reach out to ${c.issueEmail} with error ID ${errorID}.`, - }); - } -} diff --git a/apps/web/src/app/api/team/invite/accept/route.ts b/apps/web/src/app/api/team/invite/accept/route.ts deleted file mode 100644 index 712c5809..00000000 --- a/apps/web/src/app/api/team/invite/accept/route.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { serverZodResponse } from "@/lib/utils/server/types"; -import { BasicServerValidator } from "@/validators/shared/basic"; -import { db } from "db"; -import { eq, and } from "db/drizzle"; -import { userCommonData, userHackerData, invites, teams } from "db/schema"; -import { auth } from "@clerk/nextjs/server"; -import { NextResponse } from "next/server"; -import { z } from "zod"; -import c from "config"; - -const inviteAcceptValidator = z.object({ - teamInviteID: z.string().min(1).max(50), -}); - -export async function POST( - req: Request, -): serverZodResponse { - const { userId } = await auth(); - if (!userId) return NextResponse.json("Unauthorized", { status: 401 }); - - const rawBody = req.json(); - const body = inviteAcceptValidator.safeParse(rawBody); - - if (!body.success) { - return NextResponse.json({ - success: false, - message: `Invalid body. Error: ${body.error.message}`, - }); - } - - const user = await db.query.userCommonData.findFirst({ - where: eq(userCommonData.clerkID, userId), - with: { - hackerData: { - with: { - invites: { - where: eq(invites.teamID, body.data.teamInviteID), - }, - }, - }, - }, - }); - if (!user) return NextResponse.json("Unauthorized", { status: 401 }); - - if (user.hackerData.teamID) { - return NextResponse.json({ - success: false, - message: "You are already on a team.", - internalCode: "already_on_team", - }); - } - - if (user.hackerData.invites.length === 0) { - return NextResponse.json({ - success: false, - message: "You have not been invited to this team.", - internalCode: "not_invited", - }); - } - - const team = await db.query.teams.findFirst({ - where: eq(teams.id, user.hackerData.invites[0].teamID), - with: { - members: true, - }, - }); - - if (!team) { - return NextResponse.json({ - success: false, - message: "Team not found", - internalCode: "team_not_found", - }); - } - - if (team.members.length >= c.maxTeamSize) { - return NextResponse.json({ - success: false, - message: "Team is full", - internalCode: "team_full", - }); - } - - await db - .update(userHackerData) - .set({ teamID: user.hackerData.invites[0].teamID }) - .where(eq(userHackerData.clerkID, userId)); - - // TODO: would be interesting to see if the and() could be removed here in favor of directly looking up the composite key. - await db - .update(invites) - .set({ status: "accepted" }) - .where( - and( - eq(invites.teamID, user.hackerData.invites[0].teamID), - eq(invites.inviteeID, userId), - ), - ); - - return NextResponse.json({ - success: true, - message: "Successfully joined team", - internalCode: "success", - }); -} - -export const runtime = "edge"; diff --git a/apps/web/src/app/api/team/invite/create/route.ts b/apps/web/src/app/api/team/invite/create/route.ts deleted file mode 100644 index 0876167e..00000000 --- a/apps/web/src/app/api/team/invite/create/route.ts +++ /dev/null @@ -1,92 +0,0 @@ -import { auth } from "@clerk/nextjs/server"; -import { db } from "db"; -import { eq } from "db/drizzle"; -import { userCommonData } from "db/schema"; -import { NextResponse } from "next/server"; -import { newInviteValidator } from "@/validators/shared/team"; -import { BasicServerValidator } from "@/validators/shared/basic"; -import { invites } from "db/schema"; -import { getHacker } from "db/functions"; -import type { serverZodResponse } from "@/lib/utils/server/types"; - -export async function POST( - req: Request, -): serverZodResponse { - const { userId } = await auth(); - if (!userId) return NextResponse.json("Unauthorized", { status: 401 }); - - const user = await getHacker(userId, true); - if (!user) return NextResponse.json("Unauthorized", { status: 401 }); - - if (!user.hackerData.teamID || !user.hackerData.team) { - return NextResponse.json( - { - success: false, - message: - "You are not on a team. Join a team to invite members.", - }, - { status: 400 }, - ); - } - - if (user.hackerData.team.ownerID !== userId) { - return NextResponse.json( - { - success: false, - message: "You are not the owner of this team.", - }, - { status: 400 }, - ); - } - - const rawBody = await req.json(); - const body = newInviteValidator.safeParse(rawBody); - if (!body.success) { - return NextResponse.json({ - success: false, - message: `Invalid body. Error: ${body.error.message}`, - }); - } - - const invitee = await db.query.userCommonData.findFirst({ - where: eq(userCommonData.hackerTag, body.data.inviteeTag), - with: { - hackerData: { - with: { - team: true, - invites: { - where: eq(invites.teamID, user.hackerData.teamID), - }, - }, - }, - }, - }); - - if (!invitee) { - return NextResponse.json({ - success: false, - message: "No user with that tag exists.", - internalCode: "user_not_found", - }); - } - - if (invitee.hackerData.invites.length > 0) { - return NextResponse.json({ - success: false, - message: "That user already has an invite.", - internalCode: "user_already_invited", - }); - } - - await db.insert(invites).values({ - inviteeID: invitee.clerkID, - teamID: user.hackerData.teamID, - }); - - return NextResponse.json({ - success: true, - message: "Invite sent successfully!", - }); -} - -export const runtime = "edge"; diff --git a/apps/web/src/app/api/team/invite/decline/route.ts b/apps/web/src/app/api/team/invite/decline/route.ts deleted file mode 100644 index 8fab0892..00000000 --- a/apps/web/src/app/api/team/invite/decline/route.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { auth } from "@clerk/nextjs/server"; -import { NextResponse } from "next/server"; -import { z } from "zod"; -import { db } from "db"; -import { userCommonData, invites } from "db/schema"; -import { eq, and } from "db/drizzle"; - -const inviteDeclineValidator = z.object({ - teamInviteID: z.string().min(1).max(50), -}); - -export async function POST(req: Request) { - const { userId } = await auth(); - if (!userId) return NextResponse.json("Unauthorized", { status: 401 }); - - const rawBody = req.json(); - const body = inviteDeclineValidator.safeParse(rawBody); - - if (!body.success) { - return NextResponse.json({ - success: false, - message: `Invalid body. Error: ${body.error.message}`, - }); - } - - // TODO(xander): adjust logic here. null check shouldnt require a join, and invite can be queried directly - const user = await db.query.userCommonData.findFirst({ - where: eq(userCommonData.clerkID, userId), - with: { - hackerData: { - with: { - invites: { - where: eq(invites.teamID, body.data.teamInviteID), - }, - }, - }, - }, - }); - - if (!user) return NextResponse.json("Unauthorized", { status: 401 }); - - // TODO(xander): get invite using body data here to avoid joins above - await db - .update(invites) - .set({ - status: "declined", - }) - .where( - and( - eq(invites.teamID, user.hackerData.invites[0].teamID), - eq(invites.inviteeID, userId), - ), - ); -} diff --git a/apps/web/src/app/dash/pass/page.tsx b/apps/web/src/app/dash/pass/page.tsx index f5b478f9..367a2cf7 100644 --- a/apps/web/src/app/dash/pass/page.tsx +++ b/apps/web/src/app/dash/pass/page.tsx @@ -24,7 +24,7 @@ export default async function Page() { const user = await currentUser(); if (!user) return null; - const userDbRecord = await getHacker(user.id, false); + const userDbRecord = await getHacker(user.id); if (!userDbRecord) return null; const qrPayload = createQRpayload({ diff --git a/apps/web/src/app/dash/team/new/page.tsx b/apps/web/src/app/dash/team/new/page.tsx deleted file mode 100644 index 5d54fe40..00000000 --- a/apps/web/src/app/dash/team/new/page.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import c from "config"; -import NewTeamForm from "@/components/dash/main/team/NewTeam"; - -export default async function Page() { - return ( -
-
-

{c.hackathonName}

-

- Team -

-
-

New Team

- -
-
- ); -} diff --git a/apps/web/src/app/dash/team/page.tsx b/apps/web/src/app/dash/team/page.tsx deleted file mode 100644 index 10599ba7..00000000 --- a/apps/web/src/app/dash/team/page.tsx +++ /dev/null @@ -1,203 +0,0 @@ -import c from "config"; -import { auth } from "@clerk/nextjs/server"; -import { db } from "db"; -import { userCommonData } from "db/schema"; -import { eq } from "db/drizzle"; -import { Button } from "@/components/shadcn/ui/button"; -import Link from "next/link"; -import { Plus, User } from "lucide-react"; -import Image from "next/image"; -import TeamInvite from "@/components/dash/team/invite"; -import { Fragment } from "react"; -import { Badge } from "@/components/shadcn/ui/badge"; -import LeaveTeamButton from "@/components/dash/team/LeaveTeamButton"; - -export default async function Page() { - const { userId } = await auth(); - if (!userId) return null; - - // TODO: make this db query not so bad - const user = await db.query.userCommonData.findFirst({ - where: eq(userCommonData.clerkID, userId), - with: { - hackerData: { - with: { - team: { - with: { - members: { - with: { - commonData: true, - }, - }, - }, - }, - invites: { - with: { - team: true, - }, - }, - }, - }, - }, - }); - if (!user) return null; - - if (!user.hackerData.teamID) { - return ( -
-
-

{c.hackathonName}

-

- Team -

-
-
-
-

You are not currently in a team.

- - How do Teams work? - -
-
- - - -
-
-
-

- Invitations -

- {user.hackerData.invites.length > 0 ? ( - user.hackerData.invites.map((invite) => ( -
-
-

- {invite.team.name} -

-

- ~{invite.team.tag} -

-
-
- - - - -
-
- )) - ) : ( -

No Pending Invites

- )} -
-
-
- ); - } else { - if (!user.hackerData.team) return null; - const team = user.hackerData.team; - return ( -
-
-
-
-

- - Team -

- {/*

{users.length} Total Users

*/} -
-
-
- - -
-
-
-
-
- {`Team -
-

- {team.name} -

-

- ~{team.tag} -

-

{team.bio}

-
- - Est.{" "} - {team.createdAt - .toDateString() - .split(" ") - .slice(1) - .join(" ")} - -
-
-
- {team.members.map((member) => ( - - -
-
- {`${member.commonData.hackerTag}'s -
-

- { - member.commonData - .firstName - }{" "} - {member.commonData.lastName} -

-

- @ - { - member.commonData - .hackerTag - } -

-
-
-
- -
- ))} -
-
-
- ); - } -} - -export const runtime = "edge"; diff --git a/apps/web/src/app/register/page.tsx b/apps/web/src/app/register/page.tsx index 686b872b..a550f912 100644 --- a/apps/web/src/app/register/page.tsx +++ b/apps/web/src/app/register/page.tsx @@ -19,12 +19,8 @@ export default async function Page() { const registration = await getUser(userId); if (registration) return redirect("/dash"); - const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled]: ( - | string - | null - )[] = await redisMGet( + const [defaultRegistrationEnabled]: (string | null)[] = await redisMGet( "config:registration:registrationEnabled", - "config:registration:secretRegistrationEnabled", ); if (parseRedisBoolean(defaultRegistrationEnabled, true) === true) { diff --git a/apps/web/src/app/sign-up/[[...sign-up]]/page.tsx b/apps/web/src/app/sign-up/[[...sign-up]]/page.tsx index ecd4c49f..90518930 100644 --- a/apps/web/src/app/sign-up/[[...sign-up]]/page.tsx +++ b/apps/web/src/app/sign-up/[[...sign-up]]/page.tsx @@ -6,12 +6,8 @@ import { Button } from "@/components/shadcn/ui/button"; import Link from "next/link"; export default async function Page() { - const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled]: ( - | string - | null - )[] = await redisMGet( + const [defaultRegistrationEnabled]: (string | null)[] = await redisMGet( "config:registration:registrationEnabled", - "config:registration:secretRegistrationEnabled", ); if (parseRedisBoolean(defaultRegistrationEnabled, true) === true) { diff --git a/apps/web/src/app/team/[tag]/page.tsx b/apps/web/src/app/team/[tag]/page.tsx deleted file mode 100644 index 9bcb1912..00000000 --- a/apps/web/src/app/team/[tag]/page.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { db } from "db"; -import { teams } from "db/schema"; -import { notFound } from "next/navigation"; -import { eq } from "db/drizzle"; -import Image from "next/image"; -import Link from "next/link"; -import Navbar from "@/components/shared/Navbar"; - -export default async function Page({ params }: { params: { tag: string } }) { - if (!params.tag || params.tag.length <= 1) return notFound(); - - const team = await db.query.teams.findFirst({ - where: eq(teams.tag, params.tag), - with: { - members: { - with: { - commonData: true, - }, - }, - }, - }); - - if (!team) return notFound(); - - return ( - <> - -
-
-
- {`Team -
-

{team.name}

- {team.bio && team.bio.length > 0 && ( -

{team.bio}

- )} -
- {team.members.map((member) => ( - -
- {`${member.commonData.hackerTag}'s -
-

- {member.commonData.firstName}{" "} - {member.commonData.lastName} -

-

- @{member.commonData.hackerTag} -

-
-
- - ))} -
-
- - ); -} - -export const runtime = "edge"; -export const revalidate = 30; diff --git a/apps/web/src/app/user/[tag]/page.tsx b/apps/web/src/app/user/[tag]/page.tsx index f4d0c5ed..b9ba546f 100644 --- a/apps/web/src/app/user/[tag]/page.tsx +++ b/apps/web/src/app/user/[tag]/page.tsx @@ -10,7 +10,7 @@ import { getHackerByTag } from "db/functions"; export default async function ({ params }: { params: { tag: string } }) { if (!params.tag || params.tag.length <= 1) return notFound(); - const user = await getHackerByTag(params.tag, false); + const user = await getHackerByTag(params.tag); if (!user) return notFound(); return ( diff --git a/apps/web/src/components/admin/toggles/RegistrationSettings.tsx b/apps/web/src/components/admin/toggles/RegistrationSettings.tsx index bbf699ad..116aa1f3 100644 --- a/apps/web/src/components/admin/toggles/RegistrationSettings.tsx +++ b/apps/web/src/components/admin/toggles/RegistrationSettings.tsx @@ -9,7 +9,6 @@ import { toast } from "sonner"; import { toggleRegistrationEnabled, toggleRegistrationMessageEnabled, - toggleSecretRegistrationEnabled, toggleRSVPs, setRSVPLimit, } from "@/actions/admin/registration-actions"; @@ -17,30 +16,15 @@ import { UpdateItemWithConfirmation } from "./UpdateItemWithConfirmation"; interface RegistrationTogglesProps { defaultRegistrationEnabled: boolean; - defaultSecretRegistrationEnabled: boolean; defaultRSVPsEnabled: boolean; defaultRSVPLimit: number; } export function RegistrationToggles({ - defaultSecretRegistrationEnabled, defaultRegistrationEnabled, defaultRSVPsEnabled, defaultRSVPLimit, }: RegistrationTogglesProps) { - const { - execute: executeToggleSecretRegistrationEnabled, - optimisticState: ToggleSecretRegistrationEnabledOptimisticData, - } = useOptimisticAction(toggleSecretRegistrationEnabled, { - currentState: { - success: true, - statusSet: defaultSecretRegistrationEnabled, - }, - updateFn: (state, { enabled }) => { - return { statusSet: enabled, success: true }; - }, - }); - const { execute: executeToggleRSVPs, optimisticState: toggleRSVPsOptimisticData, @@ -93,26 +77,6 @@ export function RegistrationToggles({ }} /> - {/* removed until implemented */} - {/*
-

- Allow Secret Code Sign-up -

- { - toast.success( - `Secret registration ${checked ? "enabled" : "disabled"} successfully!`, - ); - executeToggleSecretRegistrationEnabled({ - enabled: checked, - }); - }} - /> -
*/}
diff --git a/apps/web/src/components/admin/users/ServerSections.tsx b/apps/web/src/components/admin/users/ServerSections.tsx index 7c262308..21b7c6cb 100644 --- a/apps/web/src/components/admin/users/ServerSections.tsx +++ b/apps/web/src/components/admin/users/ServerSections.tsx @@ -29,10 +29,6 @@ export function ProfileInfo({ user }: { user: Hacker }) {
- -
- - {user.hackerData.team ? ( - <> - - - - - ) : null} -
- {user.hackerData.team ? ( - - - - ) : null} - - ); -} - function Cell({ title, value, diff --git a/apps/web/src/components/dash/main/team/NewTeam.tsx b/apps/web/src/components/dash/main/team/NewTeam.tsx index 0f79769e..e69de29b 100644 --- a/apps/web/src/components/dash/main/team/NewTeam.tsx +++ b/apps/web/src/components/dash/main/team/NewTeam.tsx @@ -1,195 +0,0 @@ -"use client"; -import { useForm } from "react-hook-form"; -import { - Form, - FormField, - FormItem, - FormLabel, - FormControl, - FormDescription, - FormMessage, -} from "@/components/shadcn/ui/form"; -import { Input } from "@/components/shadcn/ui/input"; -import { Button } from "@/components/shadcn/ui/button"; -import { z } from "zod"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { Textarea } from "@/components/shadcn/ui/textarea"; -import { zpostSafe } from "@/lib/utils/client/zfetch"; -import { BasicServerValidator } from "@/validators/shared/basic"; -import { useState, useTransition } from "react"; -import { Shell } from "lucide-react"; -import { useRouter } from "next/navigation"; -import { newTeamValidator } from "@/validators/shared/team"; -import c from "config"; -import { put } from "@/lib/utils/client/file-upload"; - -export default function NewTeamForm() { - const formValidator = newTeamValidator.merge( - z.object({ photo: z.instanceof(File) }), - ); - const [loading, setLoading] = useState(false); - const router = useRouter(); - const [isPending, startTransition] = useTransition(); - const form = useForm>({ - resolver: zodResolver(formValidator), - defaultValues: { - name: "", - bio: "", - tag: "", - photo: new File([], ""), - }, - }); - - async function onSubmit(values: z.infer) { - setLoading(true); - - let teamPhotoURL: string | null = null; - const photo = values.photo; - - if (photo) { - // TODO: verify this works with the create team - const url = await put(photo.name, photo, { - presignHandlerUrl: "/api/upload/pfp", - }); - teamPhotoURL = url; - } else { - teamPhotoURL = `https://api.dicebear.com/6.x/shapes/svg?seed=${encodeURIComponent( - values.tag.toLowerCase(), - )}`; - } - - const res = await zpostSafe({ - url: "/api/team/create", - vReq: newTeamValidator, - vRes: BasicServerValidator, - body: { - bio: values.bio, - name: values.name, - tag: values.tag, - photo: teamPhotoURL, - }, - }); - - if (!res.success) { - return alert( - `An unknown error occurred. Please try again later. If this is a continuous issue, please contact us at ${c.issueEmail}.`, - ); - } - if (!res.data.success) { - console.log("error: ", res.data.message); - return alert(res.data.message); - } - - alert("Team Created Successfully! Redirecting to team page..."); - - // Due to weirdness with next router we have to use a react transition here. - - startTransition(() => router.push("/dash/team")); - startTransition(() => router.refresh()); - } - - return ( -
- - ( - - Team Name - - - - - This will be the public display name of your - team. - - - - )} - /> - ( - - TeamTag - -
-
- ~ -
- -
-
- - This will be the public, unique identifier for - your team. - - -
- )} - /> - ( - - Media - - - field.onChange( - e.target.files - ? e.target.files[0] - : null, - ) - } - /> - - - - )} - /> - ( - - Bio - -