create-quadrokit 0.1.0 → 0.2.1

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.
Files changed (91) hide show
  1. package/README.md +10 -6
  2. package/biome.monorepo.json +67 -0
  3. package/dist/index.mjs +361 -0
  4. package/package.json +10 -4
  5. package/templates/README.md +39 -0
  6. package/templates/admin-shell/.cursor/rules/commitlint-conventional.mdc +47 -0
  7. package/templates/admin-shell/.env.example +2 -0
  8. package/templates/admin-shell/biome.json +12 -0
  9. package/templates/admin-shell/index.html +12 -0
  10. package/templates/admin-shell/package.json +46 -0
  11. package/templates/admin-shell/postcss.config.js +6 -0
  12. package/templates/admin-shell/src/components/AppShell.tsx +68 -0
  13. package/templates/admin-shell/src/i18n.ts +12 -0
  14. package/templates/admin-shell/src/lib/quadro-client.ts +4 -0
  15. package/templates/admin-shell/src/locales/en.json +15 -0
  16. package/templates/admin-shell/src/main.tsx +15 -0
  17. package/templates/admin-shell/src/pages/AgenciesPage.tsx +69 -0
  18. package/templates/admin-shell/src/pages/HomePage.tsx +67 -0
  19. package/templates/admin-shell/src/router.tsx +15 -0
  20. package/templates/admin-shell/src/stores/useSidebarHint.ts +12 -0
  21. package/templates/admin-shell/src/vite-env.d.ts +9 -0
  22. package/templates/admin-shell/tailwind.config.ts +7 -0
  23. package/templates/admin-shell/tsconfig.app.json +16 -0
  24. package/templates/admin-shell/tsconfig.json +4 -0
  25. package/templates/admin-shell/tsconfig.node.json +10 -0
  26. package/templates/admin-shell/vite.config.ts +25 -0
  27. package/templates/dashboard/.cursor/rules/commitlint-conventional.mdc +47 -0
  28. package/templates/dashboard/.env.example +2 -0
  29. package/templates/dashboard/biome.json +12 -0
  30. package/templates/dashboard/index.html +12 -0
  31. package/templates/dashboard/package.json +46 -0
  32. package/templates/dashboard/postcss.config.js +6 -0
  33. package/templates/dashboard/src/components/AppShell.tsx +44 -0
  34. package/templates/dashboard/src/i18n.ts +12 -0
  35. package/templates/dashboard/src/lib/quadro-client.ts +4 -0
  36. package/templates/dashboard/src/locales/en.json +15 -0
  37. package/templates/dashboard/src/main.tsx +15 -0
  38. package/templates/dashboard/src/pages/AgenciesPage.tsx +69 -0
  39. package/templates/dashboard/src/pages/HomePage.tsx +67 -0
  40. package/templates/dashboard/src/router.tsx +15 -0
  41. package/templates/dashboard/src/stores/useSidebarHint.ts +12 -0
  42. package/templates/dashboard/src/vite-env.d.ts +9 -0
  43. package/templates/dashboard/tailwind.config.ts +7 -0
  44. package/templates/dashboard/tsconfig.app.json +16 -0
  45. package/templates/dashboard/tsconfig.json +4 -0
  46. package/templates/dashboard/tsconfig.node.json +10 -0
  47. package/templates/dashboard/vite.config.ts +25 -0
  48. package/templates/ecommerce/.cursor/rules/commitlint-conventional.mdc +47 -0
  49. package/templates/ecommerce/.env.example +2 -0
  50. package/templates/ecommerce/biome.json +12 -0
  51. package/templates/ecommerce/index.html +12 -0
  52. package/templates/ecommerce/package.json +46 -0
  53. package/templates/ecommerce/postcss.config.js +6 -0
  54. package/templates/ecommerce/src/components/AppShell.tsx +44 -0
  55. package/templates/ecommerce/src/i18n.ts +12 -0
  56. package/templates/ecommerce/src/lib/quadro-client.ts +4 -0
  57. package/templates/ecommerce/src/locales/en.json +20 -0
  58. package/templates/ecommerce/src/main.tsx +15 -0
  59. package/templates/ecommerce/src/pages/AgenciesPage.tsx +69 -0
  60. package/templates/ecommerce/src/pages/HomePage.tsx +52 -0
  61. package/templates/ecommerce/src/router.tsx +15 -0
  62. package/templates/ecommerce/src/stores/useSidebarHint.ts +12 -0
  63. package/templates/ecommerce/src/vite-env.d.ts +9 -0
  64. package/templates/ecommerce/tailwind.config.ts +7 -0
  65. package/templates/ecommerce/tsconfig.app.json +16 -0
  66. package/templates/ecommerce/tsconfig.json +4 -0
  67. package/templates/ecommerce/tsconfig.node.json +10 -0
  68. package/templates/ecommerce/vite.config.ts +25 -0
  69. package/templates/website/.cursor/rules/commitlint-conventional.mdc +47 -0
  70. package/templates/website/.env.example +2 -0
  71. package/templates/website/biome.json +12 -0
  72. package/templates/website/index.html +12 -0
  73. package/templates/website/package.json +46 -0
  74. package/templates/website/postcss.config.js +6 -0
  75. package/templates/website/src/components/AppShell.tsx +44 -0
  76. package/templates/website/src/i18n.ts +12 -0
  77. package/templates/website/src/lib/quadro-client.ts +4 -0
  78. package/templates/website/src/locales/en.json +21 -0
  79. package/templates/website/src/main.tsx +15 -0
  80. package/templates/website/src/pages/AgenciesPage.tsx +69 -0
  81. package/templates/website/src/pages/HomePage.tsx +83 -0
  82. package/templates/website/src/router.tsx +15 -0
  83. package/templates/website/src/stores/useSidebarHint.ts +12 -0
  84. package/templates/website/src/vite-env.d.ts +9 -0
  85. package/templates/website/tailwind.config.ts +7 -0
  86. package/templates/website/tsconfig.app.json +16 -0
  87. package/templates/website/tsconfig.json +4 -0
  88. package/templates/website/tsconfig.node.json +10 -0
  89. package/templates/website/vite.config.ts +25 -0
  90. package/src/index.ts +0 -237
  91. package/tsconfig.json +0 -9
@@ -0,0 +1,68 @@
1
+ import { ThemeToolbar } from '@quadrokit/ui'
2
+ import { useTranslation } from 'react-i18next'
3
+ import { Link, NavLink, Outlet } from 'react-router-dom'
4
+
5
+ export function AppShell() {
6
+ const { t } = useTranslation()
7
+
8
+ return (
9
+ <div className="min-h-dvh bg-background text-foreground">
10
+ <div className="flex min-h-dvh">
11
+ <aside className="hidden w-56 shrink-0 border-r border-border bg-card/40 p-4 md:block">
12
+ <Link to="/" className="block text-lg font-semibold tracking-tight">
13
+ {t('app.title')}
14
+ </Link>
15
+ <nav className="mt-6 flex flex-col gap-2 text-sm text-muted-foreground">
16
+ <NavLink
17
+ to="/"
18
+ end
19
+ className={({ isActive }) =>
20
+ isActive ? 'font-medium text-foreground' : 'hover:text-foreground'
21
+ }
22
+ >
23
+ {t('app.nav_home')}
24
+ </NavLink>
25
+ <NavLink
26
+ to="/agencies"
27
+ className={({ isActive }) =>
28
+ isActive ? 'font-medium text-foreground' : 'hover:text-foreground'
29
+ }
30
+ >
31
+ {t('app.nav_agencies')}
32
+ </NavLink>
33
+ </nav>
34
+ </aside>
35
+ <div className="flex min-w-0 flex-1 flex-col">
36
+ <header className="border-b border-border bg-card/40 px-4 py-3 backdrop-blur md:hidden">
37
+ <div className="flex flex-wrap items-center justify-between gap-2">
38
+ <Link to="/" className="font-semibold">
39
+ {t('app.title')}
40
+ </Link>
41
+ <nav className="flex gap-3 text-sm text-muted-foreground">
42
+ <NavLink
43
+ to="/"
44
+ end
45
+ className={({ isActive }) => (isActive ? 'text-foreground' : '')}
46
+ >
47
+ {t('app.nav_home')}
48
+ </NavLink>
49
+ <NavLink
50
+ to="/agencies"
51
+ className={({ isActive }) => (isActive ? 'text-foreground' : '')}
52
+ >
53
+ {t('app.nav_agencies')}
54
+ </NavLink>
55
+ </nav>
56
+ </div>
57
+ </header>
58
+ <div className="border-b border-border px-4 py-3">
59
+ <ThemeToolbar />
60
+ </div>
61
+ <main className="mx-auto w-full max-w-5xl flex-1 px-4 py-8">
62
+ <Outlet />
63
+ </main>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ )
68
+ }
@@ -0,0 +1,12 @@
1
+ import i18n from 'i18next'
2
+ import { initReactI18next } from 'react-i18next'
3
+ import en from './locales/en.json'
4
+
5
+ void i18n.use(initReactI18next).init({
6
+ resources: { en: { translation: en } },
7
+ lng: 'en',
8
+ fallbackLng: 'en',
9
+ interpolation: { escapeValue: false },
10
+ })
11
+
12
+ export default i18n
@@ -0,0 +1,4 @@
1
+ import { createClient } from '@quadrokit/sample-client'
2
+
3
+ /** Same-origin `/rest` in dev (Vite proxy) and production (reverse proxy). */
4
+ export const quadro = createClient({ baseURL: '/rest' })
@@ -0,0 +1,15 @@
1
+ {
2
+ "app": {
3
+ "title": "QuadroKit",
4
+ "tagline": "Admin shell with sidebar — same stack, denser layout.",
5
+ "nav_home": "Home",
6
+ "nav_agencies": "Agencies",
7
+ "session_cookie": "Expected 4D session cookie: {{name}}"
8
+ },
9
+ "form": {
10
+ "demo_title": "react-hook-form + zod",
11
+ "label": "Label",
12
+ "placeholder": "Type something…",
13
+ "submit": "Submit"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import { RouterProvider } from 'react-router-dom'
4
+ import '@quadrokit/ui/styles.css'
5
+ import './i18n'
6
+ import { ThemeProvider } from '@quadrokit/ui'
7
+ import { router } from './router'
8
+
9
+ createRoot(document.getElementById('root')!).render(
10
+ <StrictMode>
11
+ <ThemeProvider>
12
+ <RouterProvider router={router} />
13
+ </ThemeProvider>
14
+ </StrictMode>
15
+ )
@@ -0,0 +1,69 @@
1
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@quadrokit/ui'
2
+ import { useEffect, useState } from 'react'
3
+ import { quadro } from '@/lib/quadro-client'
4
+
5
+ export function AgenciesPage() {
6
+ const [names, setNames] = useState<string[]>([])
7
+ const [error, setError] = useState<string | null>(null)
8
+
9
+ useEffect(() => {
10
+ let cancelled = false
11
+ ;(async () => {
12
+ try {
13
+ const list = quadro.Agency.all({
14
+ page: 1,
15
+ pageSize: 20,
16
+ select: ['name'],
17
+ })
18
+ const acc: string[] = []
19
+ for await (const a of list) {
20
+ acc.push(a.name ?? '')
21
+ }
22
+ if (!cancelled) {
23
+ setNames(acc)
24
+ }
25
+ } catch (e) {
26
+ if (!cancelled) {
27
+ setError(e instanceof Error ? e.message : String(e))
28
+ }
29
+ }
30
+ })()
31
+ return () => {
32
+ cancelled = true
33
+ }
34
+ }, [])
35
+
36
+ return (
37
+ <div className="space-y-6">
38
+ <div>
39
+ <h1 className="text-2xl font-semibold">Agencies</h1>
40
+ <p className="text-sm text-muted-foreground">
41
+ Sample list from 4D REST (requires running server + auth cookie).
42
+ </p>
43
+ </div>
44
+ {error && (
45
+ <Card className="border-destructive/50">
46
+ <CardHeader>
47
+ <CardTitle className="text-destructive">Request failed</CardTitle>
48
+ <CardDescription>{error}</CardDescription>
49
+ </CardHeader>
50
+ </Card>
51
+ )}
52
+ <Card>
53
+ <CardHeader>
54
+ <CardTitle>Names</CardTitle>
55
+ <CardDescription>
56
+ {names.length ? `${names.length} loaded` : 'No data yet'}
57
+ </CardDescription>
58
+ </CardHeader>
59
+ <CardContent>
60
+ <ul className="list-inside list-disc space-y-1 text-sm">
61
+ {names.map((n) => (
62
+ <li key={n}>{n || '(empty)'}</li>
63
+ ))}
64
+ </ul>
65
+ </CardContent>
66
+ </Card>
67
+ </div>
68
+ )
69
+ }
@@ -0,0 +1,67 @@
1
+ import { zodResolver } from '@hookform/resolvers/zod'
2
+ import {
3
+ Button,
4
+ Card,
5
+ CardContent,
6
+ CardDescription,
7
+ CardHeader,
8
+ CardTitle,
9
+ Input,
10
+ Label,
11
+ } from '@quadrokit/ui'
12
+ import { useForm } from 'react-hook-form'
13
+ import { useTranslation } from 'react-i18next'
14
+ import { z } from 'zod'
15
+ import { quadro } from '@/lib/quadro-client'
16
+ import { useSidebarHint } from '@/stores/useSidebarHint'
17
+
18
+ const schema = z.object({
19
+ label: z.string().min(1, 'Required'),
20
+ })
21
+
22
+ type FormValues = z.infer<typeof schema>
23
+
24
+ export function HomePage() {
25
+ const { t } = useTranslation()
26
+ const note = useSidebarHint((s) => s.note)
27
+ const setNote = useSidebarHint((s) => s.setNote)
28
+
29
+ const form = useForm<FormValues>({
30
+ resolver: zodResolver(schema),
31
+ defaultValues: { label: '' },
32
+ })
33
+
34
+ return (
35
+ <div className="space-y-8">
36
+ <div>
37
+ <h1 className="text-3xl font-semibold tracking-tight">{t('app.title')}</h1>
38
+ <p className="mt-2 max-w-2xl text-muted-foreground">{t('app.tagline')}</p>
39
+ <p className="mt-2 text-sm text-muted-foreground">
40
+ {t('app.session_cookie', { name: quadro.sessionCookieName })}
41
+ </p>
42
+ </div>
43
+
44
+ <Card>
45
+ <CardHeader>
46
+ <CardTitle>{t('form.demo_title')}</CardTitle>
47
+ <CardDescription>Zustand note: {note || '—'}</CardDescription>
48
+ </CardHeader>
49
+ <CardContent>
50
+ <form
51
+ className="flex max-w-md flex-col gap-4"
52
+ onSubmit={form.handleSubmit((v) => setNote(v.label))}
53
+ >
54
+ <div className="space-y-2">
55
+ <Label htmlFor="label">{t('form.label')}</Label>
56
+ <Input id="label" placeholder={t('form.placeholder')} {...form.register('label')} />
57
+ {form.formState.errors.label?.message && (
58
+ <p className="text-sm text-destructive">{form.formState.errors.label.message}</p>
59
+ )}
60
+ </div>
61
+ <Button type="submit">{t('form.submit')}</Button>
62
+ </form>
63
+ </CardContent>
64
+ </Card>
65
+ </div>
66
+ )
67
+ }
@@ -0,0 +1,15 @@
1
+ import { createBrowserRouter } from 'react-router-dom'
2
+ import { AppShell } from './components/AppShell'
3
+ import { AgenciesPage } from './pages/AgenciesPage'
4
+ import { HomePage } from './pages/HomePage'
5
+
6
+ export const router = createBrowserRouter([
7
+ {
8
+ path: '/',
9
+ element: <AppShell />,
10
+ children: [
11
+ { index: true, element: <HomePage /> },
12
+ { path: 'agencies', element: <AgenciesPage /> },
13
+ ],
14
+ },
15
+ ])
@@ -0,0 +1,12 @@
1
+ import { create } from 'zustand'
2
+
3
+ /** Minimal Zustand example — optional UI preference. */
4
+ interface SidebarHintState {
5
+ note: string
6
+ setNote: (s: string) => void
7
+ }
8
+
9
+ export const useSidebarHint = create<SidebarHintState>((set) => ({
10
+ note: '',
11
+ setNote: (note) => set({ note }),
12
+ }))
@@ -0,0 +1,9 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_4D_ORIGIN?: string
5
+ }
6
+
7
+ interface ImportMeta {
8
+ readonly env: ImportMetaEnv
9
+ }
@@ -0,0 +1,7 @@
1
+ import preset from '@quadrokit/ui/tailwind-preset'
2
+ import type { Config } from 'tailwindcss'
3
+
4
+ export default {
5
+ presets: [preset],
6
+ content: ['./index.html', './src/**/*.{ts,tsx}', '../../ui/src/**/*.{ts,tsx}'],
7
+ } satisfies Config
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
5
+ "useDefineForClassFields": true,
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "moduleDetection": "force",
8
+ "noEmit": true,
9
+ "jsx": "react-jsx",
10
+ "verbatimModuleSyntax": true,
11
+ "paths": {
12
+ "@/*": ["./src/*"]
13
+ }
14
+ },
15
+ "include": ["src/**/*.ts", "src/**/*.tsx"]
16
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "files": [],
3
+ "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
4
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
5
+ "noEmit": true,
6
+ "moduleDetection": "force",
7
+ "types": ["node"]
8
+ },
9
+ "include": ["vite.config.ts", "tailwind.config.ts"]
10
+ }
@@ -0,0 +1,25 @@
1
+ import path from 'node:path'
2
+ import react from '@vitejs/plugin-react'
3
+ import { defineConfig, loadEnv } from 'vite'
4
+
5
+ export default defineConfig(({ mode }) => {
6
+ const env = loadEnv(mode, process.cwd(), '')
7
+ const target4d = env.VITE_4D_ORIGIN ?? 'http://127.0.0.1:7080'
8
+
9
+ return {
10
+ plugins: [react()],
11
+ resolve: {
12
+ alias: {
13
+ '@': path.resolve(__dirname, 'src'),
14
+ },
15
+ },
16
+ server: {
17
+ proxy: {
18
+ '/rest': {
19
+ target: target4d,
20
+ changeOrigin: true,
21
+ },
22
+ },
23
+ },
24
+ }
25
+ })
@@ -0,0 +1,47 @@
1
+ ---
2
+ description: Commit messages must follow Conventional Commits (commitlint @commitlint/config-conventional)
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Git commits (Conventional Commits / commitlint)
7
+
8
+ When proposing or writing **commit messages** (including one-line suggestions, full messages, or PR squash titles), use **Conventional Commits** compatible with **@commitlint/config-conventional**.
9
+
10
+ ## Header format
11
+
12
+ ```
13
+ <type>(<optional-scope>): <short description>
14
+ ```
15
+
16
+ - **type** (pick one): `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
17
+ - **scope** (optional): lowercase, short package or area (e.g. `client`, `templates`, `ui`, `create-quadrokit`)
18
+ - **description**: imperative mood, **lowercase**, **no trailing period**, **≤ ~72 characters** for the subject line
19
+
20
+ ## Breaking changes
21
+
22
+ - Add `!` after type or scope: `feat(api)!: remove legacy login endpoint`
23
+ - Or explain in the body with a line starting with `BREAKING CHANGE:`
24
+
25
+ ## Body and footer (when needed)
26
+
27
+ - Separate body from subject with a blank line.
28
+ - Wrap body at ~100 chars.
29
+ - Footer: `Refs: #123` / `Fixes: #123` if applicable.
30
+
31
+ ## Examples
32
+
33
+ ```
34
+ feat(client): add entity set release helper
35
+
36
+ fix(templates): correct vite proxy target env var
37
+
38
+ chore: bump biome to 2.4.10
39
+
40
+ docs(readme): document ci:quick script
41
+ ```
42
+
43
+ ## Do not
44
+
45
+ - Vague subjects: `update`, `fix stuff`, `wip`
46
+ - End the subject line with a period
47
+ - Use title case for the description (use sentence case / lowercase)
@@ -0,0 +1,2 @@
1
+ # Origin of your 4D web server (REST). The Vite dev server proxies /rest here.
2
+ VITE_4D_ORIGIN=http://127.0.0.1:7080
@@ -0,0 +1,12 @@
1
+ {
2
+ "root": false,
3
+ "extends": "//",
4
+ "vcs": {
5
+ "enabled": true,
6
+ "clientKind": "git",
7
+ "useIgnoreFile": false
8
+ },
9
+ "files": {
10
+ "includes": ["**", "!**/node_modules", "!**/dist", "!**/.quadrokit"]
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>QuadroKit Dashboard</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@quadrokit/template-dashboard",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "quadrokit:generate": "node scripts/quadrokit-generate.mjs",
8
+ "dev": "vite",
9
+ "build": "tsc -b && vite build",
10
+ "preview": "vite preview",
11
+ "typecheck": "tsc -b --noEmit",
12
+ "format": "biome format --write .",
13
+ "lint": "biome lint .",
14
+ "lint:fix": "biome lint --write .",
15
+ "check": "biome check .",
16
+ "check:fix": "biome check --write .",
17
+ "biome:check": "biome check .",
18
+ "ci:quick": "bun run format && bun run lint:fix && bun run check:fix && bun run build"
19
+ },
20
+ "dependencies": {
21
+ "@hookform/resolvers": "^5.2.2",
22
+ "@quadrokit/client": "workspace:*",
23
+ "@quadrokit/sample-client": "workspace:*",
24
+ "@quadrokit/ui": "workspace:*",
25
+ "i18next": "^26.0.3",
26
+ "react": "^19.2.4",
27
+ "react-dom": "^19.2.4",
28
+ "react-hook-form": "^7.72.0",
29
+ "react-i18next": "^17.0.2",
30
+ "react-router-dom": "^7.13.2",
31
+ "zod": "^4.3.6",
32
+ "zustand": "^5.0.12"
33
+ },
34
+ "devDependencies": {
35
+ "@biomejs/biome": "2.4.10",
36
+ "@types/node": "^25.5.0",
37
+ "@types/react": "^19.2.14",
38
+ "@types/react-dom": "^19.2.3",
39
+ "@vitejs/plugin-react": "^6.0.1",
40
+ "autoprefixer": "^10.4.27",
41
+ "postcss": "^8.5.8",
42
+ "tailwindcss": "^3.4.17",
43
+ "typescript": "^5.9.3",
44
+ "vite": "^8.0.3"
45
+ }
46
+ }
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1,44 @@
1
+ import { ThemeToolbar } from '@quadrokit/ui'
2
+ import { useTranslation } from 'react-i18next'
3
+ import { Link, NavLink, Outlet } from 'react-router-dom'
4
+
5
+ export function AppShell() {
6
+ const { t } = useTranslation()
7
+
8
+ return (
9
+ <div className="min-h-dvh bg-background text-foreground">
10
+ <header className="border-b border-border bg-card/40 backdrop-blur">
11
+ <div className="mx-auto flex max-w-5xl flex-col gap-3 px-4 py-4 sm:flex-row sm:items-center sm:justify-between">
12
+ <div className="flex items-center gap-6">
13
+ <Link to="/" className="text-lg font-semibold tracking-tight">
14
+ {t('app.title')}
15
+ </Link>
16
+ <nav className="flex gap-3 text-sm text-muted-foreground">
17
+ <NavLink
18
+ to="/"
19
+ end
20
+ className={({ isActive }) =>
21
+ isActive ? 'font-medium text-foreground' : 'hover:text-foreground'
22
+ }
23
+ >
24
+ {t('app.nav_home')}
25
+ </NavLink>
26
+ <NavLink
27
+ to="/agencies"
28
+ className={({ isActive }) =>
29
+ isActive ? 'font-medium text-foreground' : 'hover:text-foreground'
30
+ }
31
+ >
32
+ {t('app.nav_agencies')}
33
+ </NavLink>
34
+ </nav>
35
+ </div>
36
+ <ThemeToolbar />
37
+ </div>
38
+ </header>
39
+ <main className="mx-auto max-w-5xl px-4 py-8">
40
+ <Outlet />
41
+ </main>
42
+ </div>
43
+ )
44
+ }
@@ -0,0 +1,12 @@
1
+ import i18n from 'i18next'
2
+ import { initReactI18next } from 'react-i18next'
3
+ import en from './locales/en.json'
4
+
5
+ void i18n.use(initReactI18next).init({
6
+ resources: { en: { translation: en } },
7
+ lng: 'en',
8
+ fallbackLng: 'en',
9
+ interpolation: { escapeValue: false },
10
+ })
11
+
12
+ export default i18n
@@ -0,0 +1,4 @@
1
+ import { createClient } from '@quadrokit/sample-client'
2
+
3
+ /** Same-origin `/rest` in dev (Vite proxy) and production (reverse proxy). */
4
+ export const quadro = createClient({ baseURL: '/rest' })
@@ -0,0 +1,15 @@
1
+ {
2
+ "app": {
3
+ "title": "QuadroKit",
4
+ "tagline": "Dashboard template — Vite, React, 4D REST, themes, i18n.",
5
+ "nav_home": "Home",
6
+ "nav_agencies": "Agencies",
7
+ "session_cookie": "Expected 4D session cookie: {{name}}"
8
+ },
9
+ "form": {
10
+ "demo_title": "react-hook-form + zod",
11
+ "label": "Label",
12
+ "placeholder": "Type something…",
13
+ "submit": "Submit"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import { RouterProvider } from 'react-router-dom'
4
+ import '@quadrokit/ui/styles.css'
5
+ import './i18n'
6
+ import { ThemeProvider } from '@quadrokit/ui'
7
+ import { router } from './router'
8
+
9
+ createRoot(document.getElementById('root')!).render(
10
+ <StrictMode>
11
+ <ThemeProvider>
12
+ <RouterProvider router={router} />
13
+ </ThemeProvider>
14
+ </StrictMode>
15
+ )
@@ -0,0 +1,69 @@
1
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@quadrokit/ui'
2
+ import { useEffect, useState } from 'react'
3
+ import { quadro } from '@/lib/quadro-client'
4
+
5
+ export function AgenciesPage() {
6
+ const [names, setNames] = useState<string[]>([])
7
+ const [error, setError] = useState<string | null>(null)
8
+
9
+ useEffect(() => {
10
+ let cancelled = false
11
+ ;(async () => {
12
+ try {
13
+ const list = quadro.Agency.all({
14
+ page: 1,
15
+ pageSize: 20,
16
+ select: ['name'],
17
+ })
18
+ const acc: string[] = []
19
+ for await (const a of list) {
20
+ acc.push(a.name ?? '')
21
+ }
22
+ if (!cancelled) {
23
+ setNames(acc)
24
+ }
25
+ } catch (e) {
26
+ if (!cancelled) {
27
+ setError(e instanceof Error ? e.message : String(e))
28
+ }
29
+ }
30
+ })()
31
+ return () => {
32
+ cancelled = true
33
+ }
34
+ }, [])
35
+
36
+ return (
37
+ <div className="space-y-6">
38
+ <div>
39
+ <h1 className="text-2xl font-semibold">Agencies</h1>
40
+ <p className="text-sm text-muted-foreground">
41
+ Sample list from 4D REST (requires running server + auth cookie).
42
+ </p>
43
+ </div>
44
+ {error && (
45
+ <Card className="border-destructive/50">
46
+ <CardHeader>
47
+ <CardTitle className="text-destructive">Request failed</CardTitle>
48
+ <CardDescription>{error}</CardDescription>
49
+ </CardHeader>
50
+ </Card>
51
+ )}
52
+ <Card>
53
+ <CardHeader>
54
+ <CardTitle>Names</CardTitle>
55
+ <CardDescription>
56
+ {names.length ? `${names.length} loaded` : 'No data yet'}
57
+ </CardDescription>
58
+ </CardHeader>
59
+ <CardContent>
60
+ <ul className="list-inside list-disc space-y-1 text-sm">
61
+ {names.map((n) => (
62
+ <li key={n}>{n || '(empty)'}</li>
63
+ ))}
64
+ </ul>
65
+ </CardContent>
66
+ </Card>
67
+ </div>
68
+ )
69
+ }