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
5 changes: 5 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ tasks:
- git config core.hooksPath .github/hooks
- echo "Git hooks configured successfully."

gen-vapid:
desc: Generate a VAPID keypair for push notifications (prints to stdout; copy into .env)
cmds:
- go run ./cmd/genvapid

test:
desc: Run all Go tests
cmds:
Expand Down
39 changes: 39 additions & 0 deletions client/web/src/components/PushPromptHost.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useEffect } from "react";
import { toast } from "sonner";

import { usePushPrompt } from "@/shared/push/usePushPrompt";

const TOAST_ID = "push-prompt";

export function PushPromptHost() {
const { shouldPrompt, accept, dismiss } = usePushPrompt();

useEffect(() => {
if (!shouldPrompt) return;

toast("Get notified about your application status", {
id: TOAST_ID,
description:
"Allow push notifications so we can let you know when reviews and announcements drop.",
duration: Infinity,
action: {
label: "Enable",
onClick: () => {
void accept();
},
},
cancel: {
label: "Not now",
onClick: () => {
dismiss();
},
},
});

return () => {
toast.dismiss(TOAST_ID);
};
}, [shouldPrompt, accept, dismiss]);

return null;
}
6 changes: 6 additions & 0 deletions client/web/src/pages/admin/_shared/AppSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import {
Bell,
Calendar,
ClipboardList,
Handshake,
Expand Down Expand Up @@ -75,6 +76,11 @@ const superAdminNav = [
url: "/admin/sa/application",
icon: ClipboardList,
},
{
name: "Notifications",
url: "/admin/sa/notifications",
icon: Bell,
},
];

export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { useEffect } from "react";

import { Card, CardContent, CardHeader } from "@/components/ui/card";
import { Skeleton } from "@/components/ui/skeleton";

import { NotificationsTable } from "./components/NotificationsTable";
import { useNotificationsStore } from "./store";

export default function NotificationsPage() {
const {
notifications,
loading,
saving,
fetch: fetchNotifications,
create,
update,
remove,
} = useNotificationsStore();

useEffect(() => {
const controller = new AbortController();
fetchNotifications(controller.signal);
return () => controller.abort();
}, [fetchNotifications]);

if (loading && notifications.length === 0) {
return (
<div className="space-y-6 overflow-auto">
<Card>
<CardHeader>
<Skeleton className="h-5 w-40" />
</CardHeader>
<CardContent className="space-y-3">
{[...Array(3)].map((_, i) => (
<Skeleton key={i} className="h-14 w-full" />
))}
</CardContent>
</Card>
</div>
);
}

return (
<div className="flex h-full min-h-0 flex-col overflow-hidden">
<NotificationsTable
notifications={notifications}
saving={saving}
onCreate={create}
onUpdate={update}
onDelete={remove}
/>
</div>
);
}
59 changes: 59 additions & 0 deletions client/web/src/pages/superadmin/notifications/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {
deleteRequest,
getRequest,
patchRequest,
postRequest,
} from "@/shared/lib/api";
import type { ApiResponse } from "@/types";

import type {
ScheduledNotification,
ScheduledNotificationListResponse,
ScheduledNotificationPayload,
} from "./types";

export async function fetchScheduledNotifications(
signal?: AbortSignal,
): Promise<ApiResponse<ScheduledNotificationListResponse>> {
return getRequest<ScheduledNotificationListResponse>(
"/superadmin/notifications",
"scheduled notifications",
signal,
);
}

export async function createScheduledNotification(
payload: ScheduledNotificationPayload,
signal?: AbortSignal,
): Promise<ApiResponse<ScheduledNotification>> {
return postRequest<ScheduledNotification>(
"/superadmin/notifications",
payload,
"scheduled notification",
signal,
);
}

export async function updateScheduledNotification(
id: string,
payload: ScheduledNotificationPayload,
signal?: AbortSignal,
): Promise<ApiResponse<ScheduledNotification>> {
return patchRequest<ScheduledNotification>(
`/superadmin/notifications/${id}`,
payload,
"scheduled notification",
signal,
);
}

export async function deleteScheduledNotification(
id: string,
signal?: AbortSignal,
): Promise<ApiResponse<unknown>> {
return deleteRequest<unknown>(
`/superadmin/notifications/${id}`,
"scheduled notification",
signal,
);
}
Loading
Loading