Skip to content

Commit

Permalink
fix setItem action
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuasilva414 committed Jan 3, 2025
1 parent 9407fd6 commit 2c33857
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 39 deletions.
27 changes: 9 additions & 18 deletions apps/web/src/actions/admin/modify-nav-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@ const navAdminPage = "/admin/toggles/landing";
export const setItem = adminAction
.schema(metadataSchema)
.action(async ({ parsedInput: { name, url }, ctx: { user, userId } }) => {
await sadd(
"config:navitemslist",
encodeURIComponent(name),
);
await hset(
"config:navitems:${encodeURIComponent(name)}",
{
url,
name,
enabled: true,
},
);
await sadd("config:navitemslist", encodeURIComponent(name));
await hset(`config:navitems:${encodeURIComponent(name)}`, {
url,
name,
enabled: true,
});
revalidatePath(navAdminPage);
return { success: true };
});
Expand All @@ -48,12 +42,9 @@ export const toggleItem = adminAction
parsedInput: { name, statusToSet },
ctx: { user, userId },
}) => {
await hset(
"config:navitems:${encodeURIComponent(name)}",
{
enabled: statusToSet,
},
);
await hset(`config:navitems:${encodeURIComponent(name)}`, {
enabled: statusToSet,
});
revalidatePath(navAdminPage);
return { success: true, itemStatus: statusToSet };
},
Expand Down
25 changes: 5 additions & 20 deletions apps/web/src/actions/admin/registration-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,54 +16,39 @@ const defaultRSVPLimitSchema = z.object({
export const toggleRegistrationEnabled = adminAction
.schema(defaultRegistrationToggleSchema)
.action(async ({ parsedInput: { enabled }, ctx: { user, userId } }) => {
await set(
"config:registration:registrationEnabled",
enabled,
);
await set("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 set(
"config:registration:registrationMessageEnabled",
enabled,
);
await set("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 set(
"config:registration:secretRegistrationEnabled",
enabled,
);
await set("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 set(
"config:registration:allowRSVPs",
enabled,
);
await set("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 set(
"config:registration:maxRSVPs",
rsvpLimit,
);
await set("config:registration:maxRSVPs", rsvpLimit);
revalidatePath("/admin/toggles/registration");
return { success: true, statusSet: rsvpLimit };
});
1 change: 1 addition & 0 deletions apps/web/src/lib/utils/server/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export async function getAllNavItems() {
}

export function removeNavItem(name: string) {
console.log("Removing: ", includeEnvPrefix("config:navitemslist"));
const pipe = kv.pipeline();
pipe.srem(
includeEnvPrefix("config:navitemslist"),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"prettier": "^3.3.3",
"turbo": "^2.0.9"
},
"packageManager": "[email protected]",
"packageManager": "[email protected]+sha512.d264f6640bf4f09de7cfcc547568515bcf0613cf485a03e8ff16616fa69c4172b6f9a0a2925ee44fb060df565c9c9a8eaf061749e77af318cb77f6684a7051f3",
"name": "hackkit",
"dependencies": {
"prettier-plugin-tailwindcss": "^0.6.5"
Expand Down

0 comments on commit 2c33857

Please sign in to comment.