create-reactivite 1.4.0 → 1.6.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 +326 -290
- package/index.js +1 -1
- package/package.json +4 -2
- package/template/package.json +22 -22
- package/template/pnpm-lock.yaml +3274 -3274
- package/template/src/components/author-credit.tsx +25 -25
- package/template2/.env.example +8 -8
- package/template2/.husky/pre-commit +4 -4
- package/template2/.prettierrc +5 -5
- package/template2/README.md +73 -73
- package/template2/__tests__/example.test.ts +20 -20
- package/template2/_gitignore +37 -37
- package/template2/app/[locale]/(private)/dashboard/page.tsx +52 -52
- package/template2/app/[locale]/(public)/login/page.tsx +83 -83
- package/template2/app/[locale]/layout.tsx +58 -58
- package/template2/app/[locale]/locales.ts +10 -10
- package/template2/app/[locale]/page.tsx +38 -38
- package/template2/app/api/clear-session/route.ts +10 -10
- package/template2/app/globals.css +127 -127
- package/template2/app/layout.tsx +7 -7
- package/template2/app/page.tsx +6 -6
- package/template2/components/AuthEventListener.tsx +22 -22
- package/template2/components/author-credit.tsx +25 -25
- package/template2/components/theme-provider.tsx +78 -78
- package/template2/components/ui/button.tsx +60 -60
- package/template2/components/ui/card.tsx +92 -92
- package/template2/components/ui/input.tsx +21 -21
- package/template2/components/ui/label.tsx +24 -24
- package/template2/components/ui/sonner.tsx +40 -40
- package/template2/components.json +22 -22
- package/template2/config/constants.ts +7 -7
- package/template2/config/env.ts +5 -5
- package/template2/contexts/translation-context.tsx +70 -70
- package/template2/eslint.config.mjs +18 -18
- package/template2/hoc/provider.tsx +27 -27
- package/template2/lib/paramsSerializer.ts +40 -40
- package/template2/lib/utils.ts +6 -6
- package/template2/locales/az.json +20 -20
- package/template2/locales/en.json +20 -20
- package/template2/next-env.d.ts +1 -1
- package/template2/next.config.ts +17 -17
- package/template2/orval.config.ts +66 -66
- package/template2/package.json +62 -62
- package/template2/postcss.config.mjs +7 -7
- package/template2/scripts/fix-generated-types.mjs +13 -13
- package/template2/services/generated/.gitkeep +2 -2
- package/template2/services/httpClient/httpClient.ts +70 -70
- package/template2/services/httpClient/orvalMutator.ts +10 -10
- package/template2/store/example-store.tsx +16 -16
- package/template2/store/user-store.tsx +29 -29
- package/template2/testing/msw/handlers/index.ts +6 -6
- package/template2/testing/msw/server.ts +4 -4
- package/template2/tsconfig.json +34 -34
- package/template2/vitest.config.ts +17 -17
- package/template2/vitest.setup.ts +7 -7
- package/template3/README.md +34 -34
- package/template3/_gitignore +16 -16
- package/template3/components.json +21 -0
- package/template3/index.html +8 -2
- package/template3/package-lock.json +3934 -0
- package/template3/package.json +48 -22
- package/template3/postcss.config.mjs +5 -0
- package/template3/rspack.config.mjs +59 -51
- package/template3/src/App.tsx +16 -11
- package/template3/src/components/author-credit.tsx +42 -42
- package/template3/src/components/layout.tsx +59 -0
- package/template3/src/components/matrix-rain.tsx +71 -0
- package/template3/src/components/ui/accordion.tsx +64 -0
- package/template3/src/components/ui/alert-dialog.tsx +196 -0
- package/template3/src/components/ui/alert.tsx +66 -0
- package/template3/src/components/ui/aspect-ratio.tsx +11 -0
- package/template3/src/components/ui/avatar.tsx +107 -0
- package/template3/src/components/ui/badge.tsx +48 -0
- package/template3/src/components/ui/breadcrumb.tsx +109 -0
- package/template3/src/components/ui/button-group.tsx +83 -0
- package/template3/src/components/ui/button.tsx +64 -0
- package/template3/src/components/ui/calendar.tsx +218 -0
- package/template3/src/components/ui/card.tsx +92 -0
- package/template3/src/components/ui/carousel.tsx +241 -0
- package/template3/src/components/ui/chart.tsx +372 -0
- package/template3/src/components/ui/checkbox.tsx +32 -0
- package/template3/src/components/ui/collapsible.tsx +31 -0
- package/template3/src/components/ui/combobox.tsx +310 -0
- package/template3/src/components/ui/command.tsx +184 -0
- package/template3/src/components/ui/context-menu.tsx +252 -0
- package/template3/src/components/ui/dialog.tsx +156 -0
- package/template3/src/components/ui/direction.tsx +22 -0
- package/template3/src/components/ui/drawer.tsx +133 -0
- package/template3/src/components/ui/dropdown-menu.tsx +257 -0
- package/template3/src/components/ui/empty.tsx +104 -0
- package/template3/src/components/ui/field.tsx +248 -0
- package/template3/src/components/ui/form.tsx +165 -0
- package/template3/src/components/ui/hover-card.tsx +42 -0
- package/template3/src/components/ui/input-group.tsx +168 -0
- package/template3/src/components/ui/input-otp.tsx +77 -0
- package/template3/src/components/ui/input.tsx +21 -0
- package/template3/src/components/ui/item.tsx +193 -0
- package/template3/src/components/ui/kbd.tsx +28 -0
- package/template3/src/components/ui/label.tsx +22 -0
- package/template3/src/components/ui/menubar.tsx +276 -0
- package/template3/src/components/ui/native-select.tsx +62 -0
- package/template3/src/components/ui/navigation-menu.tsx +168 -0
- package/template3/src/components/ui/pagination.tsx +127 -0
- package/template3/src/components/ui/popover.tsx +87 -0
- package/template3/src/components/ui/progress.tsx +31 -0
- package/template3/src/components/ui/radio-group.tsx +43 -0
- package/template3/src/components/ui/resizable.tsx +53 -0
- package/template3/src/components/ui/scroll-area.tsx +56 -0
- package/template3/src/components/ui/select.tsx +190 -0
- package/template3/src/components/ui/separator.tsx +26 -0
- package/template3/src/components/ui/sheet.tsx +143 -0
- package/template3/src/components/ui/sidebar.tsx +724 -0
- package/template3/src/components/ui/skeleton.tsx +13 -0
- package/template3/src/components/ui/slider.tsx +61 -0
- package/template3/src/components/ui/sonner.tsx +40 -0
- package/template3/src/components/ui/spinner.tsx +16 -0
- package/template3/src/components/ui/switch.tsx +33 -0
- package/template3/src/components/ui/table.tsx +116 -0
- package/template3/src/components/ui/tabs.tsx +89 -0
- package/template3/src/components/ui/textarea.tsx +18 -0
- package/template3/src/components/ui/toggle-group.tsx +83 -0
- package/template3/src/components/ui/toggle.tsx +47 -0
- package/template3/src/components/ui/tooltip.tsx +55 -0
- package/template3/src/hooks/use-mobile.ts +19 -0
- package/template3/src/index.css +175 -32
- package/template3/src/lib/utils.ts +6 -0
- package/template3/src/main.tsx +10 -10
- package/template3/src/pages/about.tsx +113 -0
- package/template3/src/pages/contact.tsx +111 -0
- package/template3/src/pages/home.tsx +81 -0
- package/template3/tsconfig.json +24 -20
- package/template2/tsconfig.tsbuildinfo +0 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
const links = [
|
|
2
|
-
{ label: "GitHub", href: "https://github.com/javidselimov" },
|
|
3
|
-
{ label: "LinkedIn", href: "https://www.linkedin.com/in/javidsalim/" },
|
|
4
|
-
{ label: "npm", href: "https://www.npmjs.com/~ubuligan" },
|
|
5
|
-
];
|
|
6
|
-
|
|
7
|
-
export function AuthorCredit() {
|
|
8
|
-
return (
|
|
9
|
-
<div className="fixed bottom-4 right-4 z-50 flex items-center gap-3 rounded-full border bg-background/80 px-4 py-2 text-sm shadow-lg backdrop-blur">
|
|
10
|
-
<span className="font-medium">Javid Salimov</span>
|
|
11
|
-
<span className="text-muted-foreground">·</span>
|
|
12
|
-
{links.map((l) => (
|
|
13
|
-
<a
|
|
14
|
-
key={l.label}
|
|
15
|
-
href={l.href}
|
|
16
|
-
target="_blank"
|
|
17
|
-
rel="noreferrer"
|
|
18
|
-
className="text-muted-foreground transition-colors hover:text-foreground"
|
|
19
|
-
>
|
|
20
|
-
{l.label}
|
|
21
|
-
</a>
|
|
22
|
-
))}
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
1
|
+
const links = [
|
|
2
|
+
{ label: "GitHub", href: "https://github.com/javidselimov" },
|
|
3
|
+
{ label: "LinkedIn", href: "https://www.linkedin.com/in/javidsalim/" },
|
|
4
|
+
{ label: "npm", href: "https://www.npmjs.com/~ubuligan" },
|
|
5
|
+
];
|
|
6
|
+
|
|
7
|
+
export function AuthorCredit() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="fixed bottom-4 right-4 z-50 flex items-center gap-3 rounded-full border bg-background/80 px-4 py-2 text-sm shadow-lg backdrop-blur">
|
|
10
|
+
<span className="font-medium">Javid Salimov</span>
|
|
11
|
+
<span className="text-muted-foreground">·</span>
|
|
12
|
+
{links.map((l) => (
|
|
13
|
+
<a
|
|
14
|
+
key={l.label}
|
|
15
|
+
href={l.href}
|
|
16
|
+
target="_blank"
|
|
17
|
+
rel="noreferrer"
|
|
18
|
+
className="text-muted-foreground transition-colors hover:text-foreground"
|
|
19
|
+
>
|
|
20
|
+
{l.label}
|
|
21
|
+
</a>
|
|
22
|
+
))}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
package/template2/.env.example
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Public API base URL used by the browser (axios httpClient).
|
|
2
|
-
NEXT_PUBLIC_API_BASE_URL=/api/backend
|
|
3
|
-
|
|
4
|
-
# Server-side backend URL proxied via next.config.ts rewrites.
|
|
5
|
-
API_BASE_URL=http://localhost:8080/api
|
|
6
|
-
|
|
7
|
-
# OpenAPI schema used by orval (npm run generate:api).
|
|
8
|
-
OPENAPI_TARGET=http://localhost:8080/v3/api-docs
|
|
1
|
+
# Public API base URL used by the browser (axios httpClient).
|
|
2
|
+
NEXT_PUBLIC_API_BASE_URL=/api/backend
|
|
3
|
+
|
|
4
|
+
# Server-side backend URL proxied via next.config.ts rewrites.
|
|
5
|
+
API_BASE_URL=http://localhost:8080/api
|
|
6
|
+
|
|
7
|
+
# OpenAPI schema used by orval (npm run generate:api).
|
|
8
|
+
OPENAPI_TARGET=http://localhost:8080/v3/api-docs
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
npx figlet "Nextivite"
|
|
2
|
-
echo "Pre-commit: lint + format + tests"
|
|
3
|
-
|
|
4
|
-
npm run lint && npm run format && npm run test:run
|
|
1
|
+
npx figlet "Nextivite"
|
|
2
|
+
echo "Pre-commit: lint + format + tests"
|
|
3
|
+
|
|
4
|
+
npm run lint && npm run format && npm run test:run
|
package/template2/.prettierrc
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
{
|
|
2
|
-
"singleQuote": true,
|
|
3
|
-
"trailingComma": "all",
|
|
4
|
-
"printWidth": 80
|
|
5
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"singleQuote": true,
|
|
3
|
+
"trailingComma": "all",
|
|
4
|
+
"printWidth": 80
|
|
5
|
+
}
|
package/template2/README.md
CHANGED
|
@@ -1,73 +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`.
|
|
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`.
|
|
@@ -1,20 +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
|
-
});
|
|
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
|
+
});
|
package/template2/_gitignore
CHANGED
|
@@ -1,37 +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
|
|
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
|
|
@@ -1,52 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,83 +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
|
-
}
|
|
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
|
+
}
|