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 2fba7c8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions apps/web/src/actions/admin/modify-nav-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const setItem = adminAction
encodeURIComponent(name),
);
await hset(
"config:navitems:${encodeURIComponent(name)}",
`config:navitems:${encodeURIComponent(name)}`,
{
url,
name,
Expand Down Expand Up @@ -49,7 +49,7 @@ export const toggleItem = adminAction
ctx: { user, userId },
}) => {
await hset(
"config:navitems:${encodeURIComponent(name)}",
`config:navitems:${encodeURIComponent(name)}`,
{
enabled: statusToSet,
},
Expand Down
17 changes: 10 additions & 7 deletions apps/web/src/components/admin/toggles/NavItemsManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,16 @@ export function NavItemsManager({ navItems }: NavItemsManagerProps) {
</TableHeader>
<TableBody>
{navItems.map((item) => (
<TableRow key={item.name}>
<TableRow key={item?.name ?? ""}>
<TableCell className="font-medium">
{item.name}
{item?.name ?? ""}
</TableCell>
<TableCell>
<Link className="underline" href={item.url}>
{item.url}
<Link
className="underline"
href={item?.url ?? ""}
>
{item?.url ?? ""}
</Link>
</TableCell>
<TableCell>
Expand All @@ -75,8 +78,8 @@ export function NavItemsManager({ navItems }: NavItemsManagerProps) {
onCheckedChange={(checked) => didToggle(item.name, checked)}
/> */}
<ToggleSwitch
itemStatus={item.enabled}
name={item.name}
itemStatus={item?.enabled ?? ""}
name={item?.name ?? ""}
/>
</TableCell>
<TableCell className="space-x-2 text-right">
Expand All @@ -85,7 +88,7 @@ export function NavItemsManager({ navItems }: NavItemsManagerProps) {
</Button>
<Button
onClick={() => {
execute(item.name);
execute(item?.name ?? "");
}}
>
Delete
Expand Down
3 changes: 2 additions & 1 deletion 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 All @@ -69,7 +70,7 @@ export function parseRedisBoolean(
if (typeof value === "string") {
if (value === "true") return true;
if (value === "false") return false;
}
}
if (typeof value === "boolean") return value;
return defaultValue !== undefined ? defaultValue : false;
}
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 2fba7c8

Please sign in to comment.