Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into HK-180-no-duplicate-re…
Browse files Browse the repository at this point in the history
…sumes
  • Loading branch information
christianhelp committed Jan 3, 2025
2 parents 6159373 + 74498e7 commit 147cac5
Show file tree
Hide file tree
Showing 28 changed files with 454 additions and 276 deletions.
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@radix-ui/react-switch": "^1.0.3",
"@react-email/components": "^0.0.21",
"@t3-oss/env-nextjs": "^0.10.1",
"@tanstack/match-sorter-utils": "^8.19.4",
"@tanstack/react-query": "^5.51.11",
"@tanstack/react-table": "^8.19.3",
"@trpc/client": "11.0.0-rc.466",
Expand Down
Binary file removed apps/web/public/img/dash/pass/bg.png
Binary file not shown.
Binary file added apps/web/public/img/dash/pass/bg.webp
Binary file not shown.
13 changes: 5 additions & 8 deletions apps/web/src/actions/admin/modify-nav-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { z } from "zod";
import { adminAction } from "@/lib/safe-action";
import { kv } from "@vercel/kv";
import { redisSAdd, redisHSet, removeNavItem } from "@/lib/utils/server/redis";
import { revalidatePath } from "next/cache";

const metadataSchema = z.object({
Expand All @@ -16,8 +16,8 @@ const navAdminPage = "/admin/toggles/landing";
export const setItem = adminAction
.schema(metadataSchema)
.action(async ({ parsedInput: { name, url }, ctx: { user, userId } }) => {
await kv.sadd("config:navitemslist", encodeURIComponent(name));
await kv.hset(`config:navitems:${encodeURIComponent(name)}`, {
await redisSAdd("config:navitemslist", encodeURIComponent(name));
await redisHSet(`config:navitems:${encodeURIComponent(name)}`, {
url,
name,
enabled: true,
Expand All @@ -29,10 +29,7 @@ export const setItem = adminAction
export const removeItem = adminAction
.schema(z.string())
.action(async ({ parsedInput: name, ctx: { user, userId } }) => {
const pipe = kv.pipeline();
pipe.srem("config:navitemslist", encodeURIComponent(name));
pipe.del(`config:navitems:${encodeURIComponent(name)}`);
await pipe.exec();
await removeNavItem(name);
// await new Promise((resolve) => setTimeout(resolve, 1500));
revalidatePath(navAdminPage);
return { success: true };
Expand All @@ -45,7 +42,7 @@ export const toggleItem = adminAction
parsedInput: { name, statusToSet },
ctx: { user, userId },
}) => {
await kv.hset(`config:navitems:${encodeURIComponent(name)}`, {
await redisHSet(`config:navitems:${encodeURIComponent(name)}`, {
enabled: statusToSet,
});
revalidatePath(navAdminPage);
Expand Down
18 changes: 12 additions & 6 deletions apps/web/src/actions/admin/registration-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { z } from "zod";
import { adminAction } from "@/lib/safe-action";
import { kv } from "@vercel/kv";
import { redisSet } from "@/lib/utils/server/redis";
import { revalidatePath } from "next/cache";

const defaultRegistrationToggleSchema = z.object({
Expand All @@ -16,39 +16,45 @@ const defaultRSVPLimitSchema = z.object({
export const toggleRegistrationEnabled = adminAction
.schema(defaultRegistrationToggleSchema)
.action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => {
await kv.set("config:registration:registrationEnabled", enabled);
await redisSet("config:registration:registrationEnabled", enabled);
revalidatePath("/admin/toggles/registration");
return { success: true, statusSet: enabled };
});

export const toggleRegistrationMessageEnabled = adminAction
.schema(defaultRegistrationToggleSchema)
.action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => {
await kv.set("config:registration:registrationMessageEnabled", enabled);
await redisSet(
"config:registration:registrationMessageEnabled",
enabled,
);
revalidatePath("/admin/toggles/registration");
return { success: true, statusSet: enabled };
});

export const toggleSecretRegistrationEnabled = adminAction
.schema(defaultRegistrationToggleSchema)
.action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => {
await kv.set("config:registration:secretRegistrationEnabled", enabled);
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 } }) => {
await kv.set("config:registration:allowRSVPs", enabled);
await redisSet("config:registration:allowRSVPs", enabled);
revalidatePath("/admin/toggles/registration");
return { success: true, statusSet: enabled };
});

export const setRSVPLimit = adminAction
.schema(defaultRSVPLimitSchema)
.action(async ({ parsedInput: { rsvpLimit }, ctx: { user, userId } }) => {
await kv.set("config:registration:maxRSVPs", rsvpLimit);
await redisSet("config:registration:maxRSVPs", rsvpLimit);
revalidatePath("/admin/toggles/registration");
return { success: true, statusSet: rsvpLimit };
});
9 changes: 2 additions & 7 deletions apps/web/src/app/admin/toggles/registration/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import { RegistrationToggles } from "@/components/admin/toggles/RegistrationSettings";
import { kv } from "@vercel/kv";
import { redisMGet } from "@/lib/utils/server/redis";
import { parseRedisBoolean, parseRedisNumber } from "@/lib/utils/server/redis";
import c from "config";

export default async function Page() {
const pipe = kv.pipeline();
pipe.get("config:registration:registrationEnabled");
pipe.get("config:registration:secretRegistrationEnabled");
// const result = await pipe.exec();

const [
defaultRegistrationEnabled,
defaultSecretRegistrationEnabled,
defaultRSVPsEnabled,
defaultRSVPLimit,
]: (string | null)[] = await kv.mget(
]: (string | null)[] = await redisMGet(
"config:registration:registrationEnabled",
"config:registration:secretRegistrationEnabled",
"config:registration:allowRSVPs",
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/app/admin/users/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ export default async function Page({ params }: { params: { slug: string } }) {
<Link href={`/@${user.hackerTag}`} target="_blank">
<Button variant={"outline"}>Hacker Profile</Button>
</Link>
<Button variant={"outline"}>Email Hacker</Button>

<Link href={`mailto:${user.email}`}>
<Button variant={"outline"}>Email Hacker</Button>
</Link>

<UpdateRoleDialog
name={`${user.firstName} ${user.lastName}`}
canMakeAdmins={admin.role === "super_admin"}
Expand Down
50 changes: 8 additions & 42 deletions apps/web/src/app/admin/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,16 @@ import { DataTable } from "@/components/admin/users/UserDataTable";
import { columns } from "@/components/admin/users/UserColumns";
import { Button } from "@/components/shadcn/ui/button";
import { FolderInput } from "lucide-react";
import { DefaultPagination } from "@/components/admin/users/DefaultPagination";
import SearchBar from "@/components/admin/users/SearchBar";
import { getAllUsers } from "db/functions";
import { userCommonData } from "db/schema";

export default async function Page({
searchParams,
}: {
searchParams: { [key: string]: string | undefined };
}) {
// COME BACK AND CHANGE
const maxPerPage = 30;

let page = +(searchParams["page"] ?? "1");
let user = searchParams["user"] ?? "";
const checkedBoxes = searchParams["checkedBoxes"] ?? "";

console.log(checkedBoxes);

const start = maxPerPage * (page - 1);
const end = maxPerPage + start;

// Might want to work with cache in prod to see if this will be plausible to do
const userData = await db.query.userCommonData.findMany({
with: { hackerData: true },
where: and(
or(
ilike(userCommonData.firstName, `%${user}%`),
ilike(userCommonData.lastName, `%${user}%`),
),
),
});
// This begs a question where we might want to have an option later on to sort by the role as we might want different things
export default async function Page() {
const userData = await getAllUsers();

return (
<div className="mx-auto max-w-7xl px-5 pt-44">
<div className="mb-5 grid w-full grid-cols-3">
<div className="mx-auto max-w-7xl px-5 pt-40">
<div className="mb-5 grid w-full grid-cols-2">
<div className="flex items-center">
<div>
<h2 className="text-3xl font-bold tracking-tight">
Expand All @@ -48,7 +23,6 @@ export default async function Page({
</p>
</div>
</div>
<SearchBar />
<div className="flex items-center justify-end">
<a download href="/api/admin/export">
<Button className="flex gap-x-1">
Expand All @@ -58,25 +32,17 @@ export default async function Page({
</a>
</div>
</div>
{/* TODO: Would very much like to not have "as any" here in the future */}
<div className="flex w-full space-x-10">
<div className="flex w-full justify-center">
{userData && userData.length > 0 ? (
<>
<DataTable
columns={columns}
data={userData.slice(start, end) as any}
/>
<DataTable columns={columns} data={userData} />
</>
) : (
<div className="flex w-full items-center justify-center">
<h1>No Results :(</h1>
</div>
)}
{/* <Filters/> */}
</div>
<DefaultPagination
maxPages={Math.ceil(userData.length / maxPerPage)}
/>
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions apps/web/src/app/dash/pass/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function EventPass({ qrPayload, user, clerk, guild }: EventPassProps) {
src={c.eventPassBgImage}
alt={""}
fill
priority
className="no-select -translate-y-[15%] scale-[0.8] object-contain"
/>
<div className="grid h-20 w-full grid-cols-2">
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/app/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { auth, currentUser } from "@clerk/nextjs";
import { redirect } from "next/navigation";
import Navbar from "@/components/shared/Navbar";
import Link from "next/link";
import { kv } from "@vercel/kv";
import { redisMGet } from "@/lib/utils/server/redis";
import { parseRedisBoolean } from "@/lib/utils/server/redis";
import { Button } from "@/components/shadcn/ui/button";
import { getUser } from "db/functions";
Expand All @@ -22,7 +22,7 @@ export default async function Page() {
const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled]: (
| string
| null
)[] = await kv.mget(
)[] = await redisMGet(
"config:registration:registrationEnabled",
"config:registration:secretRegistrationEnabled",
);
Expand Down
11 changes: 7 additions & 4 deletions apps/web/src/app/rsvp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import { eq } from "db/drizzle";
import { userCommonData } from "db/schema";
import ClientToast from "@/components/shared/ClientToast";
import { SignedOut, RedirectToSignIn } from "@clerk/nextjs";
import { kv } from "@vercel/kv";
import { parseRedisBoolean, parseRedisNumber } from "@/lib/utils/server/redis";
import {
parseRedisBoolean,
parseRedisNumber,
redisGet,
} from "@/lib/utils/server/redis";
import Link from "next/link";
import { Button } from "@/components/shadcn/ui/button";
import { getUser } from "db/functions";
Expand Down Expand Up @@ -41,7 +44,7 @@ export default async function RsvpPage({
}

const rsvpEnabled = parseRedisBoolean(
(await kv.get("config:registration:allowRSVPs")) as
(await redisGet("config:registration:allowRSVPs")) as
| string
| boolean
| null
Expand All @@ -53,7 +56,7 @@ export default async function RsvpPage({

if (rsvpEnabled === true) {
const rsvpLimit = parseRedisNumber(
await kv.get("config:registration:maxRSVPs"),
await redisGet("config:registration:maxRSVPs"),
c.rsvpDefaultLimit,
);

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/app/sign-up/[[...sign-up]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SignUp } from "@clerk/nextjs";
import { kv } from "@vercel/kv";
import { redisMGet } from "@/lib/utils/server/redis";
import { parseRedisBoolean } from "@/lib/utils/server/redis";
import c from "config";
import { Button } from "@/components/shadcn/ui/button";
Expand All @@ -9,7 +9,7 @@ export default async function Page() {
const [defaultRegistrationEnabled, defaultSecretRegistrationEnabled]: (
| string
| null
)[] = await kv.mget(
)[] = await redisMGet(
"config:registration:registrationEnabled",
"config:registration:secretRegistrationEnabled",
);
Expand Down
73 changes: 0 additions & 73 deletions apps/web/src/components/admin/users/DefaultPagination.tsx

This file was deleted.

Loading

0 comments on commit 147cac5

Please sign in to comment.