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
2 changes: 1 addition & 1 deletion apps/bot/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
22 changes: 0 additions & 22 deletions apps/infrastructure-migrator/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -56,8 +54,6 @@ async function migratePostgresSqLite() {
allEvents,
allFiles,
allScans,
allTeams,
allInvites,
allErrorLogs,
alldiscordVerification,
allTickets,
Expand All @@ -71,8 +67,6 @@ async function migratePostgresSqLite() {
allEventsPromise,
allFilesPromise,
allScansPromise,
allTeamsPromise,
allInvitesPromise,
allErrorLogsPromise,
alldiscordVerificationPromise,
allTicketsPromise,
Expand Down Expand Up @@ -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) {
Expand Down
48 changes: 0 additions & 48 deletions apps/infrastructure-migrator/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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),
}),
);

Expand All @@ -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 }),
Expand Down Expand Up @@ -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(),
Expand Down
11 changes: 0 additions & 11 deletions apps/web/src/actions/admin/registration-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }) => {
Expand Down
87 changes: 0 additions & 87 deletions apps/web/src/actions/teams.ts
Original file line number Diff line number Diff line change
@@ -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;
});
2 changes: 1 addition & 1 deletion apps/web/src/app/admin/scanner/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions apps/web/src/app/admin/toggles/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ export default function Layout({ children }: ToggleLayoutProps) {
<div className="min-h-screen">
<ToggleItem name="Toggles" path="/admin/toggles" />
<ToggleItem name="Landing Page" path="/admin/toggles/landing" />
<ToggleItem name="Tickets" path="/admin/toggles/tickets" />

<ToggleItem
name="Registration & RSVP"
path="/admin/toggles/registration"
/>
<ToggleItem
name="User Dashboard"
path="/admin/toggles/dashboard"
/>
</div>
<div className="col-span-4">{children}</div>
</div>
Expand Down
15 changes: 4 additions & 11 deletions apps/web/src/app/admin/toggles/registration/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
);
Expand All @@ -28,10 +25,6 @@ export default async function Page() {
defaultRegistrationEnabled,
true,
)}
defaultSecretRegistrationEnabled={parseRedisBoolean(
defaultSecretRegistrationEnabled,
false,
)}
defaultRSVPsEnabled={parseRedisBoolean(
defaultRSVPsEnabled,
true,
Expand Down
4 changes: 1 addition & 3 deletions apps/web/src/app/admin/users/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 <p className="text-center font-bold">User Not Found</p>;
Expand Down Expand Up @@ -104,7 +103,6 @@ export default async function Page({ params }: { params: { slug: string } }) {
<PersonalInfo user={user} />
<ProfileInfo user={user} />
<AccountInfo user={user} />
<TeamInfo user={user} />
</div>
</div>
</main>
Expand Down
68 changes: 0 additions & 68 deletions apps/web/src/app/api/team/create/route.ts

This file was deleted.

Loading