T1/Phase 1: scaffold Vite SPA + Hono API + Bun worker
- apps/web: Vite + React 19 + TanStack Router/Query + shadcn/ui - apps/api: Hono + Bun on :3001 with /api/health, /api/auth/*, /mcp stubs - apps/worker: Bun worker stub, DB connection, graceful SIGTERM - apps/web-legacy/: old Next.js code moved aside (preserved for T2-T8 reference) - Dockerfiles: api (Bun), worker (Bun), spa (multi-stage Caddy) - Caddyfile: serves dist + reverse-proxies /api/* + /mcp to api - docker-compose.yml: 4-service target (api, spa, db, worker) - packages/db/src/client.ts: shared Drizzle client for api + worker - db/client.ts: root-level alias for convenience Parent: t_e1cbd87d -> t_24c9c3fd (T0)
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { Label } from '@/components/ui/label';
|
||||
|
||||
const STORAGE_KEY = 'pe_notification_prefs';
|
||||
|
||||
const defaultPrefs: Record<string, boolean> = {
|
||||
task_created: true,
|
||||
task_completed: true,
|
||||
habit_logged: true,
|
||||
comment_added: true,
|
||||
};
|
||||
|
||||
const prefLabels: Record<string, string> = {
|
||||
task_created: 'Task created',
|
||||
task_completed: 'Task completed',
|
||||
habit_logged: 'Habit logged',
|
||||
comment_added: 'Comment added',
|
||||
};
|
||||
|
||||
export function NotificationPrefs() {
|
||||
const [prefs, setPrefs] = useState<Record<string, boolean>>(defaultPrefs);
|
||||
|
||||
useEffect(() => {
|
||||
try {
|
||||
const stored = localStorage.getItem(STORAGE_KEY);
|
||||
if (stored) {
|
||||
setPrefs({ ...defaultPrefs, ...JSON.parse(stored) });
|
||||
}
|
||||
} catch {
|
||||
// Ignore parse errors
|
||||
}
|
||||
}, []);
|
||||
|
||||
function toggle(key: string) {
|
||||
const updated = { ...prefs, [key]: !prefs[key] };
|
||||
setPrefs(updated);
|
||||
try {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(updated));
|
||||
} catch {
|
||||
// Storage may be full
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
{Object.entries(prefLabels).map(([key, label]) => (
|
||||
<div key={key} className="flex items-center justify-between">
|
||||
<Label htmlFor={`notif-${key}`} className="text-sm font-normal">
|
||||
{label}
|
||||
</Label>
|
||||
<Switch
|
||||
id={`notif-${key}`}
|
||||
checked={prefs[key]}
|
||||
onCheckedChange={() => toggle(key)}
|
||||
aria-label={`Toggle ${label}`}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user