Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into emptystring
Browse files Browse the repository at this point in the history
  • Loading branch information
spiderCSman committed Jan 20, 2025
2 parents 7198fab + 87350f8 commit 9561b17
Show file tree
Hide file tree
Showing 37 changed files with 1,338 additions and 783 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.
43 changes: 34 additions & 9 deletions apps/web/src/actions/admin/modify-nav-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

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";
import { kv } from "@vercel/kv";

const metadataSchema = z.object({
name: z.string().min(1),
url: z.string(),
url: z.string().min(1),
});

const editMetadataSchema = metadataSchema.extend({
existingName: z.string().min(1),
enabled: z.boolean(),
});

// Maybe a better way to do this for revalidation? Who knows.
Expand All @@ -16,23 +22,42 @@ 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,
});
revalidatePath(navAdminPage);
return { success: true };
});

export const editItem = adminAction
.schema(editMetadataSchema)
.action(async ({ parsedInput: { name, url, existingName } }) => {
const pipe = kv.pipeline();

if (existingName != name) {
pipe.srem("config:navitemslist", encodeURIComponent(existingName));
}

pipe.sadd("config:navitemslist", encodeURIComponent(name));
pipe.hset(`config:navitems:${encodeURIComponent(name)}`, {
url,
name,
enabled: true,
});

await pipe.exec();

revalidatePath(navAdminPage);
return { success: true };
});

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 +70,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 };
});
Loading

0 comments on commit 9561b17

Please sign in to comment.