feat: Sprint 4 complete — frontend MVP (admin dashboard + member portal)
Shadboard starter-kit (Next.js 15 + React 19 + shadcn/ui + Tailwind 4) Sprint 4.a — Admin Dashboard: - Auth: NextAuth.js v5, login page, middleware, token rotation - Dashboard: KPI cards, Recharts stock chart, quick actions - Members: TanStack Table (search/sort/paginate), add/edit forms - Distributions: multi-step form, real-time quota check, history - Stock: batch management, recall dialog, bar chart - Reports: monthly/member-list/recall, PDF/CSV download, preview Sprint 4.b — Member Portal: - Separate route group with top-nav layout (mobile-first) - Quota dashboard with radial SVG progress indicators - Distribution history with month filter - Profile/settings with password change Cross-cutting: - i18n: German (default) + English via next-intl - Dark + light mode (next-themes, user-togglable) - Playwright E2E tests (6/6 green) - Docker multi-stage build (node:22-alpine) - API proxy via Next.js rewrites Tech: Next.js 15.2.8, React 19, Tailwind 4, NextAuth v5, TanStack Table, Recharts, Zod, React Hook Form, Playwright
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
"use client"
|
||||
|
||||
import { createContext, useCallback, useEffect, useState } from "react"
|
||||
import { useCookie } from "react-use"
|
||||
|
||||
import type { LocaleType, SettingsType } from "@/types"
|
||||
import type { ReactNode } from "react"
|
||||
|
||||
export const defaultSettings: SettingsType = {
|
||||
theme: "zinc",
|
||||
mode: "dark",
|
||||
radius: 0.5,
|
||||
layout: "vertical",
|
||||
locale: "de",
|
||||
}
|
||||
|
||||
export const SettingsContext = createContext<
|
||||
| {
|
||||
settings: SettingsType
|
||||
updateSettings: (newSettings: SettingsType) => void
|
||||
resetSettings: () => void
|
||||
}
|
||||
| undefined
|
||||
>(undefined)
|
||||
|
||||
export function SettingsProvider({
|
||||
locale,
|
||||
children,
|
||||
}: {
|
||||
locale: LocaleType
|
||||
children: ReactNode
|
||||
}) {
|
||||
const [storedSettings, setStoredSettings, deleteStoredSettings] =
|
||||
useCookie("settings")
|
||||
const [settings, setSettings] = useState<SettingsType | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (storedSettings) {
|
||||
setSettings(JSON.parse(storedSettings))
|
||||
} else {
|
||||
setSettings({ ...defaultSettings, locale })
|
||||
}
|
||||
}, [storedSettings, locale])
|
||||
|
||||
const updateSettings = useCallback(
|
||||
(newSettings: SettingsType) => {
|
||||
setStoredSettings(JSON.stringify(newSettings))
|
||||
setSettings(newSettings)
|
||||
},
|
||||
[setStoredSettings]
|
||||
)
|
||||
|
||||
const resetSettings = useCallback(() => {
|
||||
deleteStoredSettings()
|
||||
setSettings(defaultSettings)
|
||||
}, [deleteStoredSettings])
|
||||
|
||||
// Render children only when settings are ready
|
||||
if (!settings) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<SettingsContext.Provider
|
||||
value={{ settings, updateSettings, resetSettings }}
|
||||
>
|
||||
{children}
|
||||
</SettingsContext.Provider>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user