create-reactivite 1.0.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -98
- package/index.js +33 -1
- package/package.json +4 -3
- package/template/README.md +73 -73
- package/template/_gitignore +24 -0
- package/template/components.json +22 -22
- package/template/eslint.config.js +30 -23
- package/template/index.html +13 -13
- package/template/package.json +53 -53
- package/template/pnpm-lock.yaml +1281 -1856
- package/template/src/App.tsx +27 -27
- package/template/src/components/home-page-components/header.tsx +2 -2
- package/template/src/components/ui/accordion.tsx +64 -64
- package/template/src/components/ui/alert.tsx +66 -66
- package/template/src/components/ui/avatar.tsx +51 -51
- package/template/src/components/ui/badge.tsx +46 -46
- package/template/src/components/ui/button-group.tsx +83 -83
- package/template/src/components/ui/button.tsx +60 -60
- package/template/src/components/ui/calendar.tsx +210 -211
- package/template/src/components/ui/card.tsx +92 -92
- package/template/src/components/ui/checkbox.tsx +30 -30
- package/template/src/components/ui/collapsible.tsx +31 -31
- package/template/src/components/ui/dialog.tsx +141 -141
- package/template/src/components/ui/input.tsx +21 -21
- package/template/src/components/ui/select.tsx +185 -185
- package/template/src/components/ui/separator.tsx +26 -26
- package/template/src/components/ui/sonner.tsx +38 -38
- package/template/src/components/ui/spinner.tsx +16 -16
- package/template/src/components/ui/table.tsx +114 -114
- package/template/src/components/ui/toggle.tsx +45 -45
- package/template/src/components/ui/tooltip.tsx +59 -59
- package/template/src/lib/utils.ts +6 -6
- package/template/src/main.tsx +10 -10
- package/template/tsconfig.app.json +31 -28
- package/template/tsconfig.json +2 -4
- package/template/tsconfig.node.json +26 -26
- package/template2/.env.example +8 -0
- package/template2/.husky/pre-commit +4 -0
- package/template2/.prettierrc +5 -0
- package/template2/README.md +73 -0
- package/template2/__tests__/example.test.ts +20 -0
- package/template2/_gitignore +37 -0
- package/template2/app/[locale]/(private)/dashboard/page.tsx +52 -0
- package/template2/app/[locale]/(public)/login/page.tsx +83 -0
- package/template2/app/[locale]/layout.tsx +56 -0
- package/template2/app/[locale]/locales.ts +10 -0
- package/template2/app/[locale]/page.tsx +38 -0
- package/template2/app/api/clear-session/route.ts +10 -0
- package/template2/app/globals.css +127 -0
- package/template2/app/layout.tsx +7 -0
- package/template2/app/page.tsx +6 -0
- package/template2/components/AuthEventListener.tsx +22 -0
- package/template2/components/theme-provider.tsx +78 -0
- package/template2/components/ui/button.tsx +60 -0
- package/template2/components/ui/card.tsx +92 -0
- package/template2/components/ui/input.tsx +21 -0
- package/template2/components/ui/label.tsx +24 -0
- package/template2/components/ui/sonner.tsx +40 -0
- package/template2/components.json +22 -0
- package/template2/config/constants.ts +7 -0
- package/template2/config/env.ts +5 -0
- package/template2/contexts/translation-context.tsx +70 -0
- package/template2/eslint.config.mjs +18 -0
- package/template2/hoc/provider.tsx +27 -0
- package/template2/lib/paramsSerializer.ts +40 -0
- package/template2/lib/utils.ts +6 -0
- package/template2/locales/az.json +20 -0
- package/template2/locales/en.json +20 -0
- package/template2/next-env.d.ts +6 -0
- package/template2/next.config.ts +17 -0
- package/template2/orval.config.ts +66 -0
- package/template2/package.json +62 -0
- package/template2/pnpm-lock.yaml +6804 -0
- package/template2/postcss.config.mjs +7 -0
- package/template2/public/.gitkeep +0 -0
- package/template2/scripts/fix-generated-types.mjs +13 -0
- package/template2/services/generated/.gitkeep +2 -0
- package/template2/services/httpClient/httpClient.ts +70 -0
- package/template2/services/httpClient/orvalMutator.ts +10 -0
- package/template2/store/example-store.tsx +16 -0
- package/template2/store/user-store.tsx +29 -0
- package/template2/testing/msw/handlers/index.ts +6 -0
- package/template2/testing/msw/server.ts +4 -0
- package/template2/tsconfig.json +34 -0
- package/template2/tsconfig.tsbuildinfo +1 -0
- package/template2/vitest.config.ts +17 -0
- package/template2/vitest.setup.ts +7 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Nextivite
|
|
2
|
+
|
|
3
|
+
Next.js 16 (App Router) boilerplate scaffolded by **create-reactivite**.
|
|
4
|
+
|
|
5
|
+
## Stack
|
|
6
|
+
|
|
7
|
+
- **Next.js 16** + React 19 (App Router, `output: "standalone"`)
|
|
8
|
+
- **Tailwind CSS v4** (`@tailwindcss/postcss`, config-less) + shadcn/ui (new-york)
|
|
9
|
+
- **i18n** — `app/[locale]` routing with a lightweight `TranslationProvider` + `locales/*.json`
|
|
10
|
+
- **TanStack Query** (+ Devtools) via `hoc/provider.tsx`
|
|
11
|
+
- **axios** httpClient with interceptors + **orval** for type-safe API hooks
|
|
12
|
+
- **Zustand** stores (`store/`)
|
|
13
|
+
- **react-hook-form** + **zod** forms
|
|
14
|
+
- **Vitest** + **MSW** + Testing Library
|
|
15
|
+
- **husky** pre-commit (lint + format + tests), **prettier**, **eslint-config-next**
|
|
16
|
+
|
|
17
|
+
## Getting started
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pnpm install # or npm install
|
|
21
|
+
pnpm dev # http://localhost:3000 → redirects to /az
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Structure
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
app/
|
|
28
|
+
layout.tsx # root passthrough
|
|
29
|
+
page.tsx # redirects to /{DEFAULT_LOCALE}
|
|
30
|
+
globals.css # Tailwind v4 theme tokens
|
|
31
|
+
api/clear-session/ # cookie-clearing route
|
|
32
|
+
[locale]/
|
|
33
|
+
layout.tsx # html/body shell + all providers
|
|
34
|
+
locales.ts # server-only dictionary loader
|
|
35
|
+
page.tsx # Home
|
|
36
|
+
(public)/login/ # login (react-hook-form + zod)
|
|
37
|
+
(private)/dashboard/ # guarded page
|
|
38
|
+
components/
|
|
39
|
+
ui/ # shadcn/ui components
|
|
40
|
+
theme-provider.tsx
|
|
41
|
+
AuthEventListener.tsx
|
|
42
|
+
config/ # env + constants (LOCALES, timeouts)
|
|
43
|
+
contexts/ # translation-context
|
|
44
|
+
hoc/ # QueryProvider
|
|
45
|
+
lib/ # utils, paramsSerializer
|
|
46
|
+
services/
|
|
47
|
+
httpClient/ # axios instance + orval mutator
|
|
48
|
+
generated/ # orval output (git-ignored content)
|
|
49
|
+
store/ # zustand stores
|
|
50
|
+
locales/ # az.json, en.json
|
|
51
|
+
testing/msw/ # mock server + handlers
|
|
52
|
+
__tests__/ # vitest specs
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## API codegen (orval)
|
|
56
|
+
|
|
57
|
+
1. Point `orval.config.ts` `input.target` at your OpenAPI schema (or set `OPENAPI_TARGET`).
|
|
58
|
+
2. `pnpm generate:api` → writes react-query hooks + models to `services/generated/`.
|
|
59
|
+
|
|
60
|
+
## Scripts
|
|
61
|
+
|
|
62
|
+
- `pnpm dev` / `pnpm build` / `pnpm start`
|
|
63
|
+
- `pnpm lint` / `pnpm format`
|
|
64
|
+
- `pnpm test` / `pnpm test:run`
|
|
65
|
+
- `pnpm generate` / `pnpm generate:api`
|
|
66
|
+
|
|
67
|
+
## Adding components
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx shadcn@latest add <name>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`components.json` points `css` at `app/globals.css`.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { paramsSerializer } from '@/lib/paramsSerializer';
|
|
3
|
+
|
|
4
|
+
describe('paramsSerializer', () => {
|
|
5
|
+
it('flattens nested objects', () => {
|
|
6
|
+
expect(paramsSerializer({ pageable: { page: 0, size: 10 } })).toBe(
|
|
7
|
+
'page=0&size=10',
|
|
8
|
+
);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('repeats array values', () => {
|
|
12
|
+
expect(paramsSerializer({ sort: ['name,asc', 'id,desc'] })).toBe(
|
|
13
|
+
'sort=name%2Casc&sort=id%2Cdesc',
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('omits null and undefined', () => {
|
|
18
|
+
expect(paramsSerializer({ a: 1, b: null, c: undefined })).toBe('a=1');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
/node_modules
|
|
5
|
+
/.pnp
|
|
6
|
+
.pnp.*
|
|
7
|
+
.yarn/*
|
|
8
|
+
|
|
9
|
+
# testing
|
|
10
|
+
/coverage
|
|
11
|
+
|
|
12
|
+
# next.js
|
|
13
|
+
/.next/
|
|
14
|
+
/out/
|
|
15
|
+
|
|
16
|
+
# production
|
|
17
|
+
/build
|
|
18
|
+
|
|
19
|
+
# misc
|
|
20
|
+
.DS_Store
|
|
21
|
+
*.pem
|
|
22
|
+
|
|
23
|
+
# debug
|
|
24
|
+
npm-debug.log*
|
|
25
|
+
yarn-debug.log*
|
|
26
|
+
yarn-error.log*
|
|
27
|
+
.pnpm-debug.log*
|
|
28
|
+
|
|
29
|
+
# env files (can opt-in for committing if needed)
|
|
30
|
+
.env*
|
|
31
|
+
|
|
32
|
+
# vercel
|
|
33
|
+
.vercel
|
|
34
|
+
|
|
35
|
+
# typescript
|
|
36
|
+
*.tsbuildinfo
|
|
37
|
+
next-env.d.ts
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { useRouter, useParams } from 'next/navigation';
|
|
5
|
+
import { Button } from '@/components/ui/button';
|
|
6
|
+
import {
|
|
7
|
+
Card,
|
|
8
|
+
CardContent,
|
|
9
|
+
CardDescription,
|
|
10
|
+
CardHeader,
|
|
11
|
+
CardTitle,
|
|
12
|
+
} from '@/components/ui/card';
|
|
13
|
+
import { useTranslations } from '@/contexts/translation-context';
|
|
14
|
+
import { useUserStore } from '@/store/user-store';
|
|
15
|
+
|
|
16
|
+
export default function DashboardPage() {
|
|
17
|
+
const t = useTranslations('dashboard');
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
const { locale } = useParams<{ locale: string }>();
|
|
20
|
+
const user = useUserStore((s) => s.user);
|
|
21
|
+
const clearUser = useUserStore((s) => s.clearUser);
|
|
22
|
+
|
|
23
|
+
// Client-side guard. For a real app prefer a server check via cookies.
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!user) router.replace(`/${locale}/login`);
|
|
26
|
+
}, [user, router, locale]);
|
|
27
|
+
|
|
28
|
+
if (!user) return null;
|
|
29
|
+
|
|
30
|
+
const logout = () => {
|
|
31
|
+
clearUser();
|
|
32
|
+
router.replace(`/${locale}/login`);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<main className="flex min-h-screen items-center justify-center p-6">
|
|
37
|
+
<Card className="w-full max-w-xl">
|
|
38
|
+
<CardHeader>
|
|
39
|
+
<CardTitle>{t('title')}</CardTitle>
|
|
40
|
+
<CardDescription>
|
|
41
|
+
{t('welcome')}, {user.email}
|
|
42
|
+
</CardDescription>
|
|
43
|
+
</CardHeader>
|
|
44
|
+
<CardContent>
|
|
45
|
+
<Button variant="outline" onClick={logout}>
|
|
46
|
+
{t('logout')}
|
|
47
|
+
</Button>
|
|
48
|
+
</CardContent>
|
|
49
|
+
</Card>
|
|
50
|
+
</main>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useForm } from 'react-hook-form';
|
|
4
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { useRouter, useParams } from 'next/navigation';
|
|
7
|
+
import { toast } from 'sonner';
|
|
8
|
+
import { Button } from '@/components/ui/button';
|
|
9
|
+
import { Input } from '@/components/ui/input';
|
|
10
|
+
import { Label } from '@/components/ui/label';
|
|
11
|
+
import {
|
|
12
|
+
Card,
|
|
13
|
+
CardContent,
|
|
14
|
+
CardHeader,
|
|
15
|
+
CardTitle,
|
|
16
|
+
} from '@/components/ui/card';
|
|
17
|
+
import { useTranslations } from '@/contexts/translation-context';
|
|
18
|
+
import { useUserStore } from '@/store/user-store';
|
|
19
|
+
|
|
20
|
+
const schema = z.object({
|
|
21
|
+
email: z.string().email(),
|
|
22
|
+
password: z.string().min(6),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
type FormValues = z.infer<typeof schema>;
|
|
26
|
+
|
|
27
|
+
export default function LoginPage() {
|
|
28
|
+
const t = useTranslations('login');
|
|
29
|
+
const router = useRouter();
|
|
30
|
+
const { locale } = useParams<{ locale: string }>();
|
|
31
|
+
const setUser = useUserStore((s) => s.setUser);
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
register,
|
|
35
|
+
handleSubmit,
|
|
36
|
+
formState: { errors, isSubmitting },
|
|
37
|
+
} = useForm<FormValues>({ resolver: zodResolver(schema) });
|
|
38
|
+
|
|
39
|
+
// Demo only: replace with a real orval-generated mutation.
|
|
40
|
+
const onSubmit = async (values: FormValues) => {
|
|
41
|
+
setUser({ id: 'demo', email: values.email });
|
|
42
|
+
toast.success(t('success'));
|
|
43
|
+
router.push(`/${locale}/dashboard`);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<main className="flex min-h-screen items-center justify-center p-6">
|
|
48
|
+
<Card className="w-full max-w-sm">
|
|
49
|
+
<CardHeader>
|
|
50
|
+
<CardTitle>{t('title')}</CardTitle>
|
|
51
|
+
</CardHeader>
|
|
52
|
+
<CardContent>
|
|
53
|
+
<form
|
|
54
|
+
onSubmit={handleSubmit(onSubmit)}
|
|
55
|
+
className="flex flex-col gap-4"
|
|
56
|
+
>
|
|
57
|
+
<div className="flex flex-col gap-2">
|
|
58
|
+
<Label htmlFor="email">{t('email')}</Label>
|
|
59
|
+
<Input id="email" type="email" {...register('email')} />
|
|
60
|
+
{errors.email && (
|
|
61
|
+
<p className="text-destructive text-sm">
|
|
62
|
+
{errors.email.message}
|
|
63
|
+
</p>
|
|
64
|
+
)}
|
|
65
|
+
</div>
|
|
66
|
+
<div className="flex flex-col gap-2">
|
|
67
|
+
<Label htmlFor="password">{t('password')}</Label>
|
|
68
|
+
<Input id="password" type="password" {...register('password')} />
|
|
69
|
+
{errors.password && (
|
|
70
|
+
<p className="text-destructive text-sm">
|
|
71
|
+
{errors.password.message}
|
|
72
|
+
</p>
|
|
73
|
+
)}
|
|
74
|
+
</div>
|
|
75
|
+
<Button type="submit" disabled={isSubmitting}>
|
|
76
|
+
{t('submit')}
|
|
77
|
+
</Button>
|
|
78
|
+
</form>
|
|
79
|
+
</CardContent>
|
|
80
|
+
</Card>
|
|
81
|
+
</main>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { Metadata } from 'next';
|
|
3
|
+
import { Geist } from 'next/font/google';
|
|
4
|
+
import { Suspense } from 'react';
|
|
5
|
+
import { notFound } from 'next/navigation';
|
|
6
|
+
import '../globals.css';
|
|
7
|
+
import { ThemeProvider } from '@/components/theme-provider';
|
|
8
|
+
import { TranslationProvider } from '@/contexts/translation-context';
|
|
9
|
+
import { Toaster } from '@/components/ui/sonner';
|
|
10
|
+
import { QueryProvider } from '@/hoc/provider';
|
|
11
|
+
import { AuthEventListener } from '@/components/AuthEventListener';
|
|
12
|
+
import { LOCALES, type Locale } from '@/config/constants';
|
|
13
|
+
import { getDictionary } from './locales';
|
|
14
|
+
|
|
15
|
+
const geist = Geist({ subsets: ['latin'] });
|
|
16
|
+
|
|
17
|
+
export const metadata: Metadata = {
|
|
18
|
+
title: 'Nextivite',
|
|
19
|
+
description: 'Next.js boilerplate scaffolded by create-reactivite.',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function generateStaticParams() {
|
|
23
|
+
return LOCALES.map((locale) => ({ locale }));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default async function LocaleLayout({
|
|
27
|
+
children,
|
|
28
|
+
params,
|
|
29
|
+
}: Readonly<{
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
params: Promise<{ locale: string }>;
|
|
32
|
+
}>) {
|
|
33
|
+
const { locale } = await params;
|
|
34
|
+
|
|
35
|
+
if (!LOCALES.includes(locale as Locale)) {
|
|
36
|
+
notFound();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const messages = await getDictionary(locale as Locale);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<html lang={locale} suppressHydrationWarning>
|
|
43
|
+
<body className={`${geist.className} font-sans antialiased`}>
|
|
44
|
+
<QueryProvider>
|
|
45
|
+
<ThemeProvider defaultMode="light" storageKey="app-theme">
|
|
46
|
+
<TranslationProvider locale={locale} messages={messages}>
|
|
47
|
+
<AuthEventListener />
|
|
48
|
+
<Suspense fallback={null}>{children}</Suspense>
|
|
49
|
+
</TranslationProvider>
|
|
50
|
+
<Toaster />
|
|
51
|
+
</ThemeProvider>
|
|
52
|
+
</QueryProvider>
|
|
53
|
+
</body>
|
|
54
|
+
</html>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
import type { Locale } from '@/config/constants';
|
|
3
|
+
|
|
4
|
+
const locales = {
|
|
5
|
+
az: () => import('../../locales/az.json').then((m) => m.default),
|
|
6
|
+
en: () => import('../../locales/en.json').then((m) => m.default),
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const getDictionary = async (locale: Locale) =>
|
|
10
|
+
locales[locale]?.() ?? locales.az();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Link from 'next/link';
|
|
2
|
+
import { Button } from '@/components/ui/button';
|
|
3
|
+
import {
|
|
4
|
+
Card,
|
|
5
|
+
CardContent,
|
|
6
|
+
CardDescription,
|
|
7
|
+
CardHeader,
|
|
8
|
+
CardTitle,
|
|
9
|
+
} from '@/components/ui/card';
|
|
10
|
+
import { getDictionary } from './locales';
|
|
11
|
+
import type { Locale } from '@/config/constants';
|
|
12
|
+
|
|
13
|
+
export default async function HomePage({
|
|
14
|
+
params,
|
|
15
|
+
}: Readonly<{ params: Promise<{ locale: Locale }> }>) {
|
|
16
|
+
const { locale } = await params;
|
|
17
|
+
const dict = await getDictionary(locale);
|
|
18
|
+
const t = dict.home;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<main className="flex min-h-screen items-center justify-center p-6">
|
|
22
|
+
<Card className="w-full max-w-xl">
|
|
23
|
+
<CardHeader>
|
|
24
|
+
<CardTitle className="text-2xl">{t.title}</CardTitle>
|
|
25
|
+
<CardDescription>{t.subtitle}</CardDescription>
|
|
26
|
+
</CardHeader>
|
|
27
|
+
<CardContent className="flex flex-wrap gap-3">
|
|
28
|
+
<Button asChild>
|
|
29
|
+
<Link href={`/${locale}/login`}>{t.login}</Link>
|
|
30
|
+
</Button>
|
|
31
|
+
<Button asChild variant="outline">
|
|
32
|
+
<Link href={`/${locale}/dashboard`}>{t.dashboard}</Link>
|
|
33
|
+
</Button>
|
|
34
|
+
</CardContent>
|
|
35
|
+
</Card>
|
|
36
|
+
</main>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
|
|
3
|
+
// Clears the auth cookie(s) when the backend logout call fails or is skipped.
|
|
4
|
+
// Add the cookie names your backend sets.
|
|
5
|
+
export async function POST() {
|
|
6
|
+
const res = NextResponse.json({ ok: true });
|
|
7
|
+
res.cookies.delete('access_token');
|
|
8
|
+
res.cookies.delete('refresh_token');
|
|
9
|
+
return res;
|
|
10
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@import "tw-animate-css";
|
|
3
|
+
|
|
4
|
+
@custom-variant dark (&:is(.dark *));
|
|
5
|
+
|
|
6
|
+
:root,
|
|
7
|
+
.default {
|
|
8
|
+
--background: oklch(0.99 0 0);
|
|
9
|
+
--foreground: oklch(0.15 0 0);
|
|
10
|
+
--card: oklch(1 0 0);
|
|
11
|
+
--card-foreground: oklch(0.15 0 0);
|
|
12
|
+
--popover: oklch(1 0 0);
|
|
13
|
+
--popover-foreground: oklch(0.15 0 0);
|
|
14
|
+
--primary: oklch(0.55 0.18 250);
|
|
15
|
+
--primary-foreground: oklch(0.99 0 0);
|
|
16
|
+
--secondary: oklch(0.96 0 0);
|
|
17
|
+
--secondary-foreground: oklch(0.15 0 0);
|
|
18
|
+
--muted: oklch(0.96 0.01 250);
|
|
19
|
+
--muted-foreground: oklch(0.5 0 0);
|
|
20
|
+
--accent: oklch(0.65 0.2 30);
|
|
21
|
+
--accent-foreground: oklch(0.99 0 0);
|
|
22
|
+
--destructive: oklch(0.577 0.245 27.325);
|
|
23
|
+
--destructive-foreground: oklch(0.99 0 0);
|
|
24
|
+
--border: oklch(0.9 0 0);
|
|
25
|
+
--input: oklch(0.9 0 0);
|
|
26
|
+
--ring: oklch(0.55 0.18 250);
|
|
27
|
+
--chart-1: oklch(0.55 0.18 250);
|
|
28
|
+
--chart-2: oklch(0.65 0.2 30);
|
|
29
|
+
--chart-3: oklch(0.6 0.15 180);
|
|
30
|
+
--chart-4: oklch(0.7 0.18 320);
|
|
31
|
+
--chart-5: oklch(0.65 0.16 140);
|
|
32
|
+
--radius: 0.75rem;
|
|
33
|
+
--sidebar: oklch(0.99 0 0);
|
|
34
|
+
--sidebar-foreground: oklch(0.15 0 0);
|
|
35
|
+
--sidebar-primary: oklch(0.55 0.18 250);
|
|
36
|
+
--sidebar-primary-foreground: oklch(0.99 0 0);
|
|
37
|
+
--sidebar-accent: oklch(0.96 0 0);
|
|
38
|
+
--sidebar-accent-foreground: oklch(0.15 0 0);
|
|
39
|
+
--sidebar-border: oklch(0.9 0 0);
|
|
40
|
+
--sidebar-ring: oklch(0.55 0.18 250);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.dark {
|
|
44
|
+
--background: oklch(0.12 0 0);
|
|
45
|
+
--foreground: oklch(0.98 0 0);
|
|
46
|
+
--card: oklch(0.15 0 0);
|
|
47
|
+
--card-foreground: oklch(0.98 0 0);
|
|
48
|
+
--popover: oklch(0.15 0 0);
|
|
49
|
+
--popover-foreground: oklch(0.98 0 0);
|
|
50
|
+
--primary: oklch(0.65 0.2 250);
|
|
51
|
+
--primary-foreground: oklch(0.12 0 0);
|
|
52
|
+
--secondary: oklch(0.2 0 0);
|
|
53
|
+
--secondary-foreground: oklch(0.98 0 0);
|
|
54
|
+
--muted: oklch(0.2 0.01 250);
|
|
55
|
+
--muted-foreground: oklch(0.6 0 0);
|
|
56
|
+
--accent: oklch(0.7 0.22 30);
|
|
57
|
+
--accent-foreground: oklch(0.12 0 0);
|
|
58
|
+
--destructive: oklch(0.5 0.2 27);
|
|
59
|
+
--destructive-foreground: oklch(0.98 0 0);
|
|
60
|
+
--border: oklch(0.25 0 0);
|
|
61
|
+
--input: oklch(0.25 0 0);
|
|
62
|
+
--ring: oklch(0.65 0.2 250);
|
|
63
|
+
--chart-1: oklch(0.65 0.2 250);
|
|
64
|
+
--chart-2: oklch(0.7 0.22 30);
|
|
65
|
+
--chart-3: oklch(0.6 0.15 180);
|
|
66
|
+
--chart-4: oklch(0.7 0.18 320);
|
|
67
|
+
--chart-5: oklch(0.65 0.16 140);
|
|
68
|
+
--sidebar: oklch(0.15 0 0);
|
|
69
|
+
--sidebar-foreground: oklch(0.98 0 0);
|
|
70
|
+
--sidebar-primary: oklch(0.65 0.2 250);
|
|
71
|
+
--sidebar-primary-foreground: oklch(0.12 0 0);
|
|
72
|
+
--sidebar-accent: oklch(0.2 0 0);
|
|
73
|
+
--sidebar-accent-foreground: oklch(0.98 0 0);
|
|
74
|
+
--sidebar-border: oklch(0.25 0 0);
|
|
75
|
+
--sidebar-ring: oklch(0.65 0.2 250);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@theme inline {
|
|
79
|
+
--font-sans: "Geist", "Geist Fallback";
|
|
80
|
+
--font-mono: "Geist Mono", "Geist Mono Fallback";
|
|
81
|
+
--color-background: var(--background);
|
|
82
|
+
--color-foreground: var(--foreground);
|
|
83
|
+
--color-card: var(--card);
|
|
84
|
+
--color-card-foreground: var(--card-foreground);
|
|
85
|
+
--color-popover: var(--popover);
|
|
86
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
87
|
+
--color-primary: var(--primary);
|
|
88
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
89
|
+
--color-secondary: var(--secondary);
|
|
90
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
91
|
+
--color-muted: var(--muted);
|
|
92
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
93
|
+
--color-accent: var(--accent);
|
|
94
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
95
|
+
--color-destructive: var(--destructive);
|
|
96
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
97
|
+
--color-border: var(--border);
|
|
98
|
+
--color-input: var(--input);
|
|
99
|
+
--color-ring: var(--ring);
|
|
100
|
+
--color-chart-1: var(--chart-1);
|
|
101
|
+
--color-chart-2: var(--chart-2);
|
|
102
|
+
--color-chart-3: var(--chart-3);
|
|
103
|
+
--color-chart-4: var(--chart-4);
|
|
104
|
+
--color-chart-5: var(--chart-5);
|
|
105
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
106
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
107
|
+
--radius-lg: var(--radius);
|
|
108
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
109
|
+
--color-sidebar: var(--sidebar);
|
|
110
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
111
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
112
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
113
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
114
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
115
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
116
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@layer base {
|
|
120
|
+
* {
|
|
121
|
+
@apply border-border outline-ring/50;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
body {
|
|
125
|
+
@apply bg-background text-foreground;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
// Root layout is a passthrough — the real <html>/<body> shell lives in
|
|
4
|
+
// app/[locale]/layout.tsx so every page is locale-scoped.
|
|
5
|
+
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
6
|
+
return children;
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { usePathname } from 'next/navigation';
|
|
5
|
+
|
|
6
|
+
// Listens for the `auth:unauthorized` event dispatched by the axios interceptor
|
|
7
|
+
// (see services/httpClient/httpClient.ts) and bounces the user to /login.
|
|
8
|
+
export function AuthEventListener() {
|
|
9
|
+
const pathname = usePathname();
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
const locale = pathname.split('/')[1] || 'az';
|
|
13
|
+
const handler = async () => {
|
|
14
|
+
await fetch('/api/clear-session', { method: 'POST' }).catch(() => {});
|
|
15
|
+
window.location.href = `/${locale}/login`;
|
|
16
|
+
};
|
|
17
|
+
window.addEventListener('auth:unauthorized', handler);
|
|
18
|
+
return () => window.removeEventListener('auth:unauthorized', handler);
|
|
19
|
+
}, [pathname]);
|
|
20
|
+
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
type Mode = "dark" | "light";
|
|
6
|
+
|
|
7
|
+
type ThemeProviderProps = {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
defaultMode?: Mode;
|
|
10
|
+
storageKey?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type ThemeProviderState = {
|
|
14
|
+
mode: Mode;
|
|
15
|
+
setMode: (mode: Mode) => void;
|
|
16
|
+
toggleMode: () => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const initialState: ThemeProviderState = {
|
|
20
|
+
mode: "light",
|
|
21
|
+
setMode: () => null,
|
|
22
|
+
toggleMode: () => null,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const ThemeProviderContext =
|
|
26
|
+
React.createContext<ThemeProviderState>(initialState);
|
|
27
|
+
|
|
28
|
+
export function ThemeProvider({
|
|
29
|
+
children,
|
|
30
|
+
defaultMode = "light",
|
|
31
|
+
storageKey = "app-theme",
|
|
32
|
+
...props
|
|
33
|
+
}: Readonly<ThemeProviderProps>) {
|
|
34
|
+
const [mode, setModeState] = React.useState<Mode>(() => {
|
|
35
|
+
if (typeof window !== "undefined") {
|
|
36
|
+
return (localStorage.getItem(`${storageKey}-mode`) as Mode) || defaultMode;
|
|
37
|
+
}
|
|
38
|
+
return defaultMode;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
const root = window.document.documentElement;
|
|
43
|
+
root.classList.remove("light", "dark");
|
|
44
|
+
root.classList.add(mode);
|
|
45
|
+
}, [mode]);
|
|
46
|
+
|
|
47
|
+
const setMode = React.useCallback(
|
|
48
|
+
(next: Mode) => {
|
|
49
|
+
localStorage.setItem(`${storageKey}-mode`, next);
|
|
50
|
+
setModeState(next);
|
|
51
|
+
},
|
|
52
|
+
[storageKey],
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const value = React.useMemo<ThemeProviderState>(
|
|
56
|
+
() => ({
|
|
57
|
+
mode,
|
|
58
|
+
setMode,
|
|
59
|
+
toggleMode: () => setMode(mode === "dark" ? "light" : "dark"),
|
|
60
|
+
}),
|
|
61
|
+
[mode, setMode],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<ThemeProviderContext.Provider {...props} value={value}>
|
|
66
|
+
{children}
|
|
67
|
+
</ThemeProviderContext.Provider>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const useTheme = () => {
|
|
72
|
+
const context = React.useContext(ThemeProviderContext);
|
|
73
|
+
|
|
74
|
+
if (context === undefined)
|
|
75
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
76
|
+
|
|
77
|
+
return context;
|
|
78
|
+
};
|