create-freakpunch 0.0.0-stage → 0.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 +24 -3
- package/bin/create-freakpunch.mjs +227 -0
- package/files/README.md +19 -0
- package/files/app.config.ts +50 -0
- package/files/locales.ts +10 -0
- package/files/registry.ts +17 -0
- package/package.json +23 -6
- package/template/.dockerignore +17 -0
- package/template/.oxlintrc.json +9 -0
- package/template/AGENTS.md +6 -0
- package/template/BACKEND.md +108 -0
- package/template/CLAUDE.md +297 -0
- package/template/Dockerfile +19 -0
- package/template/_gitignore +26 -0
- package/template/components.json +27 -0
- package/template/design/COMPONENTS.md +145 -0
- package/template/design/DESIGN.md +212 -0
- package/template/design/PATTERNS.md +110 -0
- package/template/index.html +25 -0
- package/template/nginx.conf +32 -0
- package/template/package-lock.json +6484 -0
- package/template/package.json +51 -0
- package/template/public/favicon.svg +1 -0
- package/template/public/robots.txt +2 -0
- package/template/src/app.config.ts +50 -0
- package/template/src/app.roles.ts +24 -0
- package/template/src/components/ui/alert-dialog.tsx +181 -0
- package/template/src/components/ui/avatar.tsx +116 -0
- package/template/src/components/ui/badge.tsx +57 -0
- package/template/src/components/ui/breadcrumb.tsx +130 -0
- package/template/src/components/ui/button.tsx +58 -0
- package/template/src/components/ui/calendar.tsx +277 -0
- package/template/src/components/ui/card.tsx +99 -0
- package/template/src/components/ui/chart.tsx +370 -0
- package/template/src/components/ui/checkbox.tsx +28 -0
- package/template/src/components/ui/combobox.tsx +329 -0
- package/template/src/components/ui/command.tsx +191 -0
- package/template/src/components/ui/dialog.tsx +162 -0
- package/template/src/components/ui/dropdown-menu.tsx +271 -0
- package/template/src/components/ui/empty.tsx +103 -0
- package/template/src/components/ui/field.tsx +236 -0
- package/template/src/components/ui/input-group.tsx +263 -0
- package/template/src/components/ui/input.tsx +45 -0
- package/template/src/components/ui/kbd.tsx +31 -0
- package/template/src/components/ui/label.tsx +17 -0
- package/template/src/components/ui/pagination.tsx +134 -0
- package/template/src/components/ui/popover.tsx +87 -0
- package/template/src/components/ui/radio-group.tsx +35 -0
- package/template/src/components/ui/select.tsx +204 -0
- package/template/src/components/ui/separator.tsx +25 -0
- package/template/src/components/ui/sheet.tsx +139 -0
- package/template/src/components/ui/sidebar.tsx +741 -0
- package/template/src/components/ui/skeleton.tsx +13 -0
- package/template/src/components/ui/sonner.tsx +78 -0
- package/template/src/components/ui/spinner.tsx +42 -0
- package/template/src/components/ui/switch.tsx +29 -0
- package/template/src/components/ui/table.tsx +121 -0
- package/template/src/components/ui/tabs.tsx +191 -0
- package/template/src/components/ui/textarea.tsx +17 -0
- package/template/src/components/ui/toggle-group.tsx +94 -0
- package/template/src/components/ui/toggle.tsx +48 -0
- package/template/src/components/ui/tooltip.tsx +91 -0
- package/template/src/core/api/demo.ts +8 -0
- package/template/src/core/api/http.ts +76 -0
- package/template/src/core/api/mock.ts +88 -0
- package/template/src/core/api/rest.ts +67 -0
- package/template/src/core/api/types.ts +21 -0
- package/template/src/core/audit/audit.service.ts +94 -0
- package/template/src/core/audit/hooks.ts +19 -0
- package/template/src/core/auth/auth-store.ts +52 -0
- package/template/src/core/auth/auth.service.ts +86 -0
- package/template/src/core/auth/can.tsx +39 -0
- package/template/src/core/auth/dev-role-switcher.tsx +64 -0
- package/template/src/core/auth/local-credentials.ts +46 -0
- package/template/src/core/auth/permissions.ts +115 -0
- package/template/src/core/auth/require-auth.tsx +16 -0
- package/template/src/core/auth/require-permission.tsx +24 -0
- package/template/src/core/auth/roles.ts +9 -0
- package/template/src/core/auth/types.ts +20 -0
- package/template/src/core/auth/use-auth.ts +19 -0
- package/template/src/core/company/company.service.ts +94 -0
- package/template/src/core/company/hooks.ts +40 -0
- package/template/src/core/company/password-policy.ts +40 -0
- package/template/src/core/company/types.ts +46 -0
- package/template/src/core/company/use-app-name.ts +7 -0
- package/template/src/core/components/button-link.tsx +14 -0
- package/template/src/core/components/confirm-dialog.tsx +116 -0
- package/template/src/core/components/data-table/data-table.tsx +297 -0
- package/template/src/core/components/data-table/features.ts +24 -0
- package/template/src/core/components/data-table/table-header-cell.tsx +13 -0
- package/template/src/core/components/data-table/toolbar.tsx +100 -0
- package/template/src/core/components/data-table/use-list-url-state.ts +108 -0
- package/template/src/core/components/date-picker.tsx +71 -0
- package/template/src/core/components/file-attachments.tsx +84 -0
- package/template/src/core/components/form-error.tsx +9 -0
- package/template/src/core/components/form-page.tsx +93 -0
- package/template/src/core/components/image-upload.tsx +86 -0
- package/template/src/core/components/page.tsx +75 -0
- package/template/src/core/components/phone-input.tsx +58 -0
- package/template/src/core/components/search-select.tsx +57 -0
- package/template/src/core/components/segmented.tsx +41 -0
- package/template/src/core/components/states.tsx +97 -0
- package/template/src/core/components/status-badge.tsx +26 -0
- package/template/src/core/components/user-avatar.tsx +23 -0
- package/template/src/core/config/runtime.ts +16 -0
- package/template/src/core/config/types.ts +37 -0
- package/template/src/core/i18n/i18n.ts +69 -0
- package/template/src/core/i18n/i18next.d.ts +12 -0
- package/template/src/core/i18n/keys.ts +37 -0
- package/template/src/core/i18n/language-switcher.tsx +45 -0
- package/template/src/core/i18n/types.ts +17 -0
- package/template/src/core/i18n/use-format.ts +31 -0
- package/template/src/core/layout/app-shell.tsx +50 -0
- package/template/src/core/layout/app-sidebar.tsx +285 -0
- package/template/src/core/layout/command-menu.tsx +117 -0
- package/template/src/core/layout/top-bar.tsx +100 -0
- package/template/src/core/lib/csv.ts +27 -0
- package/template/src/core/lib/format.ts +87 -0
- package/template/src/core/lib/phone.ts +50 -0
- package/template/src/core/lib/storage.ts +27 -0
- package/template/src/core/modules/lazy-page.ts +9 -0
- package/template/src/core/modules/navigation.ts +39 -0
- package/template/src/core/modules/types.ts +55 -0
- package/template/src/core/notifications/hooks.ts +84 -0
- package/template/src/core/notifications/notification-center.tsx +251 -0
- package/template/src/core/notifications/notifications.service.ts +132 -0
- package/template/src/core/notifications/types.ts +70 -0
- package/template/src/core/preferences/preferences-store.ts +70 -0
- package/template/src/core/setup/setup-gate.tsx +20 -0
- package/template/src/core/setup/setup.service.ts +101 -0
- package/template/src/core/theme/brand-context.tsx +53 -0
- package/template/src/core/theme/brand.ts +29 -0
- package/template/src/core/theme/theme-context.tsx +62 -0
- package/template/src/core/theme/theme-options.ts +8 -0
- package/template/src/core/theme/theme-toggle.tsx +45 -0
- package/template/src/core/users/hooks.ts +51 -0
- package/template/src/core/users/types.ts +37 -0
- package/template/src/core/users/users.service.ts +167 -0
- package/template/src/hooks/use-mobile.ts +19 -0
- package/template/src/index.css +321 -0
- package/template/src/lib/utils.ts +1 -0
- package/template/src/locales/en/account.ts +180 -0
- package/template/src/locales/en/auth.ts +18 -0
- package/template/src/locales/en/common.ts +151 -0
- package/template/src/locales/en/company.ts +380 -0
- package/template/src/locales/en/dashboard.ts +46 -0
- package/template/src/locales/en/errors.ts +18 -0
- package/template/src/locales/en/notifications.ts +43 -0
- package/template/src/locales/en/settings.ts +25 -0
- package/template/src/locales/en/setup.ts +45 -0
- package/template/src/locales/index.ts +58 -0
- package/template/src/locales/tr/account.ts +184 -0
- package/template/src/locales/tr/auth.ts +22 -0
- package/template/src/locales/tr/common.ts +154 -0
- package/template/src/locales/tr/company.ts +384 -0
- package/template/src/locales/tr/dashboard.ts +50 -0
- package/template/src/locales/tr/errors.ts +22 -0
- package/template/src/locales/tr/notifications.ts +47 -0
- package/template/src/locales/tr/settings.ts +29 -0
- package/template/src/locales/tr/setup.ts +49 -0
- package/template/src/main.tsx +16 -0
- package/template/src/modules/locales.ts +10 -0
- package/template/src/modules/registry.ts +17 -0
- package/template/src/pages/dashboard/dashboard-page.tsx +55 -0
- package/template/src/pages/dashboard/quick-actions.tsx +37 -0
- package/template/src/pages/login-page.tsx +152 -0
- package/template/src/pages/no-access-page.tsx +11 -0
- package/template/src/pages/not-found-page.tsx +61 -0
- package/template/src/pages/settings/account/account.service.ts +128 -0
- package/template/src/pages/settings/account/components/mock-qr.tsx +50 -0
- package/template/src/pages/settings/account/components/password-strength.tsx +38 -0
- package/template/src/pages/settings/account/components/two-factor-dialog.tsx +140 -0
- package/template/src/pages/settings/account/hooks.ts +73 -0
- package/template/src/pages/settings/account/notifications-page.tsx +103 -0
- package/template/src/pages/settings/account/preferences-page.tsx +157 -0
- package/template/src/pages/settings/account/profile-page.tsx +242 -0
- package/template/src/pages/settings/account/security-page.tsx +364 -0
- package/template/src/pages/settings/account/types.ts +37 -0
- package/template/src/pages/settings/company/audit-log-page.tsx +126 -0
- package/template/src/pages/settings/company/branding-page.tsx +278 -0
- package/template/src/pages/settings/company/components/invite-dialog.tsx +106 -0
- package/template/src/pages/settings/company/components/read-only-notice.tsx +13 -0
- package/template/src/pages/settings/company/danger-zone-page.tsx +127 -0
- package/template/src/pages/settings/company/general-page.tsx +234 -0
- package/template/src/pages/settings/company/integrations/api-keys-panel.tsx +170 -0
- package/template/src/pages/settings/company/integrations/hooks.ts +37 -0
- package/template/src/pages/settings/company/integrations/integrations-page.tsx +57 -0
- package/template/src/pages/settings/company/integrations/integrations.service.ts +153 -0
- package/template/src/pages/settings/company/integrations/settings-forms.tsx +299 -0
- package/template/src/pages/settings/company/integrations/webhooks-panel.tsx +179 -0
- package/template/src/pages/settings/company/modules-page.tsx +65 -0
- package/template/src/pages/settings/company/roles-page.tsx +116 -0
- package/template/src/pages/settings/company/security-policies-page.tsx +164 -0
- package/template/src/pages/settings/company/users-page.tsx +262 -0
- package/template/src/pages/settings/settings-layout.tsx +57 -0
- package/template/src/pages/settings/settings-nav.ts +69 -0
- package/template/src/pages/settings/settings-routes.tsx +49 -0
- package/template/src/pages/setup-page.tsx +387 -0
- package/template/src/providers.tsx +68 -0
- package/template/src/router.tsx +59 -0
- package/template/tools/check-design.mjs +73 -0
- package/template/tools/new-module.mjs +90 -0
- package/template/tools/templates/module/api/__id__.mock.ts.tpl +17 -0
- package/template/tools/templates/module/api/__id__.service.ts.tpl +51 -0
- package/template/tools/templates/module/hooks.ts.tpl +57 -0
- package/template/tools/templates/module/index.ts.tpl +44 -0
- package/template/tools/templates/module/locales/en.ts.tpl +51 -0
- package/template/tools/templates/module/locales/tr.ts.tpl +55 -0
- package/template/tools/templates/module/pages/__id__-detail-page.tsx.tpl +103 -0
- package/template/tools/templates/module/pages/__id__-form-page.tsx.tpl +121 -0
- package/template/tools/templates/module/pages/__id__-list-page.tsx.tpl +234 -0
- package/template/tools/templates/module/types.ts.tpl +32 -0
- package/template/tsconfig.app.json +32 -0
- package/template/tsconfig.json +12 -0
- package/template/tsconfig.node.json +23 -0
- package/template/vite.config.ts +47 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react'
|
|
2
|
+
import { useTranslation } from 'react-i18next'
|
|
3
|
+
import { Link, useNavigate } from 'react-router'
|
|
4
|
+
import { createColumnHelper, type RowSelectionState } from '@tanstack/react-table'
|
|
5
|
+
import { Download, MoreHorizontal, Pencil, Plus, Trash2 } from 'lucide-react'
|
|
6
|
+
import { toast } from 'sonner'
|
|
7
|
+
|
|
8
|
+
import { Button } from '@/components/ui/button'
|
|
9
|
+
import {
|
|
10
|
+
DropdownMenu,
|
|
11
|
+
DropdownMenuContent,
|
|
12
|
+
DropdownMenuItem,
|
|
13
|
+
DropdownMenuSeparator,
|
|
14
|
+
DropdownMenuTrigger,
|
|
15
|
+
} from '@/components/ui/dropdown-menu'
|
|
16
|
+
import { Can, usePermissions } from '@/core/auth/can'
|
|
17
|
+
import { ButtonLink } from '@/core/components/button-link'
|
|
18
|
+
import { useConfirm } from '@/core/components/confirm-dialog'
|
|
19
|
+
import { DataTable } from '@/core/components/data-table/data-table'
|
|
20
|
+
import type { DataTableFeatures } from '@/core/components/data-table/features'
|
|
21
|
+
import { ClearFiltersButton, FilterSelect, TableSearch } from '@/core/components/data-table/toolbar'
|
|
22
|
+
import { useListUrlState } from '@/core/components/data-table/use-list-url-state'
|
|
23
|
+
import { Page } from '@/core/components/page'
|
|
24
|
+
import { EmptyState } from '@/core/components/states'
|
|
25
|
+
import { StatusBadge, type StatusTone } from '@/core/components/status-badge'
|
|
26
|
+
import { useFormat } from '@/core/i18n/use-format'
|
|
27
|
+
import { downloadCsv } from '@/core/lib/csv'
|
|
28
|
+
import { useDelete__Name__, useExport__Name__, use__Name__List } from '../hooks'
|
|
29
|
+
import { __id__Statuses, type __Name__Record, type __Name__Status } from '../types'
|
|
30
|
+
|
|
31
|
+
const FILTER_KEYS = ['status'] as const
|
|
32
|
+
const DEFAULT_SORT = { id: 'updatedAt', desc: true }
|
|
33
|
+
const helper = createColumnHelper<DataTableFeatures, __Name__Record>()
|
|
34
|
+
const tones: Record<__Name__Status, StatusTone> = { active: 'success', draft: 'neutral', archived: 'warning' }
|
|
35
|
+
|
|
36
|
+
export default function __Name__ListPage() {
|
|
37
|
+
const list = useListUrlState({ filterKeys: FILTER_KEYS, defaultSort: DEFAULT_SORT })
|
|
38
|
+
const query = use__Name__List(list.listParams)
|
|
39
|
+
const exportRows = useExport__Name__(list.listParams)
|
|
40
|
+
const { mutateAsync: deleteAsync } = useDelete__Name__()
|
|
41
|
+
const confirm = useConfirm()
|
|
42
|
+
const navigate = useNavigate()
|
|
43
|
+
const { t } = useTranslation(['__id__', 'common'])
|
|
44
|
+
const fmt = useFormat()
|
|
45
|
+
const { can } = usePermissions()
|
|
46
|
+
const [selected, setSelected] = useState<RowSelectionState>({})
|
|
47
|
+
|
|
48
|
+
async function onExport() {
|
|
49
|
+
downloadCsv(
|
|
50
|
+
'__id__',
|
|
51
|
+
[
|
|
52
|
+
{ header: t('list.columns.name'), value: (r: __Name__Record) => r.name },
|
|
53
|
+
{ header: t('list.columns.status'), value: (r: __Name__Record) => t(`status.${r.status}`) },
|
|
54
|
+
{ header: t('list.columns.updated'), value: (r: __Name__Record) => fmt.date(r.updatedAt) },
|
|
55
|
+
],
|
|
56
|
+
await exportRows(),
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function onBulkDelete() {
|
|
61
|
+
const ids = Object.keys(selected).filter((id) => selected[id])
|
|
62
|
+
const ok = await confirm({
|
|
63
|
+
title: t('delete.bulkTitle', { count: ids.length }),
|
|
64
|
+
description: t('delete.description'),
|
|
65
|
+
confirmLabel: t('common:actions.delete'),
|
|
66
|
+
destructive: true,
|
|
67
|
+
})
|
|
68
|
+
if (!ok) return
|
|
69
|
+
toast.promise(Promise.all(ids.map((id) => deleteAsync(id))), {
|
|
70
|
+
loading: t('delete.deleting'),
|
|
71
|
+
success: () => {
|
|
72
|
+
setSelected({})
|
|
73
|
+
return t('delete.bulkDeleted', { count: ids.length })
|
|
74
|
+
},
|
|
75
|
+
error: (e: Error) => e.message,
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const columns = useMemo(() => {
|
|
80
|
+
async function onDelete(record: __Name__Record) {
|
|
81
|
+
const ok = await confirm({
|
|
82
|
+
title: t('delete.title', { name: record.name }),
|
|
83
|
+
description: t('delete.description'),
|
|
84
|
+
confirmLabel: t('common:actions.delete'),
|
|
85
|
+
destructive: true,
|
|
86
|
+
})
|
|
87
|
+
if (!ok) return
|
|
88
|
+
toast.promise(deleteAsync(record.id), {
|
|
89
|
+
loading: t('delete.deleting'),
|
|
90
|
+
success: t('delete.deleted', { name: record.name }),
|
|
91
|
+
error: (e: Error) => e.message,
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return helper.columns([
|
|
96
|
+
helper.accessor('name', {
|
|
97
|
+
header: t('list.columns.name'),
|
|
98
|
+
cell: ({ row }) => (
|
|
99
|
+
<Link to={row.original.id} className="font-medium outline-none hover:underline focus-visible:underline">
|
|
100
|
+
{row.original.name}
|
|
101
|
+
</Link>
|
|
102
|
+
),
|
|
103
|
+
}),
|
|
104
|
+
helper.accessor('status', {
|
|
105
|
+
header: t('list.columns.status'),
|
|
106
|
+
cell: ({ getValue }) => <StatusBadge tone={tones[getValue()]}>{t(`status.${getValue()}`)}</StatusBadge>,
|
|
107
|
+
}),
|
|
108
|
+
helper.accessor('updatedAt', {
|
|
109
|
+
header: t('list.columns.updated'),
|
|
110
|
+
meta: { hideOnMobile: true, className: 'text-muted-foreground' },
|
|
111
|
+
cell: ({ getValue }) => fmt.date(getValue()),
|
|
112
|
+
}),
|
|
113
|
+
helper.display({
|
|
114
|
+
id: 'actions',
|
|
115
|
+
header: () => <span className="sr-only">{t('common:table.actions')}</span>,
|
|
116
|
+
meta: { align: 'right', className: 'w-12' },
|
|
117
|
+
cell: ({ row }) =>
|
|
118
|
+
(can('__id__.edit') || can('__id__.delete')) && (
|
|
119
|
+
<DropdownMenu>
|
|
120
|
+
<DropdownMenuTrigger
|
|
121
|
+
render={
|
|
122
|
+
<Button variant="ghost" size="icon-sm" aria-label={t('common:table.actionsFor', { name: row.original.name })}>
|
|
123
|
+
<MoreHorizontal />
|
|
124
|
+
</Button>
|
|
125
|
+
}
|
|
126
|
+
/>
|
|
127
|
+
<DropdownMenuContent align="end" className="w-44">
|
|
128
|
+
{can('__id__.edit') && (
|
|
129
|
+
<DropdownMenuItem onClick={() => navigate(`${row.original.id}/edit`)}>
|
|
130
|
+
<Pencil />
|
|
131
|
+
{t('common:actions.edit')}
|
|
132
|
+
</DropdownMenuItem>
|
|
133
|
+
)}
|
|
134
|
+
{can('__id__.delete') && (
|
|
135
|
+
<>
|
|
136
|
+
<DropdownMenuSeparator />
|
|
137
|
+
<DropdownMenuItem variant="destructive" onClick={() => onDelete(row.original)}>
|
|
138
|
+
<Trash2 />
|
|
139
|
+
{t('common:actions.delete')}
|
|
140
|
+
</DropdownMenuItem>
|
|
141
|
+
</>
|
|
142
|
+
)}
|
|
143
|
+
</DropdownMenuContent>
|
|
144
|
+
</DropdownMenu>
|
|
145
|
+
),
|
|
146
|
+
}),
|
|
147
|
+
])
|
|
148
|
+
}, [confirm, deleteAsync, navigate, t, fmt, can])
|
|
149
|
+
|
|
150
|
+
const statusOptions = __id__Statuses.map((s) => ({ value: s, label: t(`status.${s}`) }))
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<Page
|
|
154
|
+
title={t('list.title')}
|
|
155
|
+
description={t('list.description')}
|
|
156
|
+
actions={
|
|
157
|
+
<>
|
|
158
|
+
<Button variant="outline" onClick={onExport}>
|
|
159
|
+
<Download data-icon="inline-start" />
|
|
160
|
+
{t('list.export')}
|
|
161
|
+
</Button>
|
|
162
|
+
<Can permission="__id__.create">
|
|
163
|
+
<ButtonLink to="new">
|
|
164
|
+
<Plus data-icon="inline-start" />
|
|
165
|
+
{t('list.new')}
|
|
166
|
+
</ButtonLink>
|
|
167
|
+
</Can>
|
|
168
|
+
</>
|
|
169
|
+
}
|
|
170
|
+
>
|
|
171
|
+
<DataTable
|
|
172
|
+
columns={columns}
|
|
173
|
+
data={query.data?.items}
|
|
174
|
+
total={query.data?.total ?? 0}
|
|
175
|
+
getRowId={(r) => r.id}
|
|
176
|
+
pagination={list.pagination}
|
|
177
|
+
onPaginationChange={list.onPaginationChange}
|
|
178
|
+
sorting={list.sorting}
|
|
179
|
+
onSortingChange={list.onSortingChange}
|
|
180
|
+
isLoading={query.isPending}
|
|
181
|
+
isFetching={query.isFetching}
|
|
182
|
+
error={query.error}
|
|
183
|
+
onRetry={() => query.refetch()}
|
|
184
|
+
noun={t('noun')}
|
|
185
|
+
selection={
|
|
186
|
+
can('__id__.delete')
|
|
187
|
+
? {
|
|
188
|
+
value: selected,
|
|
189
|
+
onChange: setSelected,
|
|
190
|
+
actions: (
|
|
191
|
+
<Button variant="destructive" size="sm" onClick={onBulkDelete}>
|
|
192
|
+
<Trash2 data-icon="inline-start" />
|
|
193
|
+
{t('common:actions.delete')}
|
|
194
|
+
</Button>
|
|
195
|
+
),
|
|
196
|
+
}
|
|
197
|
+
: undefined
|
|
198
|
+
}
|
|
199
|
+
toolbar={
|
|
200
|
+
<>
|
|
201
|
+
<TableSearch value={list.search} onChange={list.setSearch} placeholder={t('list.search')} />
|
|
202
|
+
<FilterSelect
|
|
203
|
+
label={t('list.filterStatus')}
|
|
204
|
+
allLabel={t('list.allStatuses')}
|
|
205
|
+
value={list.filters.status}
|
|
206
|
+
options={statusOptions}
|
|
207
|
+
onChange={(v) => list.setFilter('status', v)}
|
|
208
|
+
/>
|
|
209
|
+
{list.hasActiveFilters && <ClearFiltersButton onClick={list.clearAll} />}
|
|
210
|
+
</>
|
|
211
|
+
}
|
|
212
|
+
empty={
|
|
213
|
+
list.hasActiveFilters ? (
|
|
214
|
+
<EmptyState
|
|
215
|
+
title={t('list.noMatchesTitle')}
|
|
216
|
+
description={t('list.noMatchesDescription')}
|
|
217
|
+
action={<ClearFiltersButton onClick={list.clearAll} />}
|
|
218
|
+
/>
|
|
219
|
+
) : (
|
|
220
|
+
<EmptyState
|
|
221
|
+
title={t('list.emptyTitle')}
|
|
222
|
+
description={t('list.emptyDescription')}
|
|
223
|
+
action={
|
|
224
|
+
<Can permission="__id__.create">
|
|
225
|
+
<ButtonLink to="new">{t('list.new')}</ButtonLink>
|
|
226
|
+
</Can>
|
|
227
|
+
}
|
|
228
|
+
/>
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
/>
|
|
232
|
+
</Page>
|
|
233
|
+
)
|
|
234
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
|
|
3
|
+
import { vmsg } from '@/core/i18n/keys'
|
|
4
|
+
|
|
5
|
+
export const __id__Statuses = ['active', 'draft', 'archived'] as const
|
|
6
|
+
export type __Name__Status = (typeof __id__Statuses)[number]
|
|
7
|
+
|
|
8
|
+
export type __Name__Record = {
|
|
9
|
+
id: string
|
|
10
|
+
name: string
|
|
11
|
+
status: __Name__Status
|
|
12
|
+
notes: string
|
|
13
|
+
createdAt: string
|
|
14
|
+
updatedAt: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type __Name__Filters = {
|
|
18
|
+
status?: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Validation for create/edit. Shared with the service so mock and real APIs agree. */
|
|
22
|
+
export const __id__FormSchema = z.object({
|
|
23
|
+
name: z
|
|
24
|
+
.string()
|
|
25
|
+
.trim()
|
|
26
|
+
.min(2, vmsg('validation.minChars', { min: 2 }))
|
|
27
|
+
.max(80, vmsg('validation.maxChars', { max: 80 })),
|
|
28
|
+
status: z.enum(__id__Statuses),
|
|
29
|
+
notes: z.string().trim().max(500, vmsg('validation.maxChars', { max: 500 })),
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
export type __Name__Input = z.infer<typeof __id__FormSchema>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
+
"target": "es2023",
|
|
5
|
+
"lib": ["ES2023", "DOM"],
|
|
6
|
+
"module": "esnext",
|
|
7
|
+
"types": ["vite/client"],
|
|
8
|
+
"allowArbitraryExtensions": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
|
|
11
|
+
/* Bundler mode */
|
|
12
|
+
"moduleResolution": "bundler",
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"verbatimModuleSyntax": true,
|
|
15
|
+
"moduleDetection": "force",
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"jsx": "react-jsx",
|
|
18
|
+
|
|
19
|
+
/* Linting */
|
|
20
|
+
"strict": true,
|
|
21
|
+
"noUnusedLocals": true,
|
|
22
|
+
"noUnusedParameters": true,
|
|
23
|
+
"erasableSyntaxOnly": true,
|
|
24
|
+
"noFallthroughCasesInSwitch": true,
|
|
25
|
+
|
|
26
|
+
/* Path aliases */
|
|
27
|
+
"paths": {
|
|
28
|
+
"@/*": ["./src/*"]
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"include": ["src"]
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
+
"target": "es2023",
|
|
5
|
+
"lib": ["ES2023"],
|
|
6
|
+
"types": ["node"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"verbatimModuleSyntax": true,
|
|
13
|
+
"moduleDetection": "force",
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
|
|
16
|
+
/* Linting */
|
|
17
|
+
"noUnusedLocals": true,
|
|
18
|
+
"noUnusedParameters": true,
|
|
19
|
+
"erasableSyntaxOnly": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["vite.config.ts"]
|
|
23
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
3
|
+
import react from '@vitejs/plugin-react'
|
|
4
|
+
import { defineConfig, loadEnv } from 'vite'
|
|
5
|
+
|
|
6
|
+
/** Long-lived vendor chunks so app deploys don't bust the library cache. */
|
|
7
|
+
const vendorChunks: [name: string, pattern: RegExp][] = [
|
|
8
|
+
['react', /node_modules[\\/](react|react-dom|react-router|scheduler)[\\/]/],
|
|
9
|
+
['ui', /node_modules[\\/](@base-ui|@floating-ui|cmdk|sonner|lucide-react)[\\/]/],
|
|
10
|
+
['data', /node_modules[\\/](@tanstack|zod|react-hook-form|@hookform)[\\/]/],
|
|
11
|
+
['charts', /node_modules[\\/](recharts|d3-[^\\/]+|victory-vendor|es-toolkit|immer|redux|@reduxjs)[\\/]/],
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
// https://vite.dev/config/
|
|
15
|
+
export default defineConfig(({ mode }) => {
|
|
16
|
+
const env = loadEnv(mode, import.meta.dirname, '')
|
|
17
|
+
return {
|
|
18
|
+
/** Where the panel is served from, e.g. /admin/ (keep the trailing slash). */
|
|
19
|
+
base: env.VITE_BASE_PATH || '/',
|
|
20
|
+
plugins: [react(), tailwindcss()],
|
|
21
|
+
/** Dev only: forward API calls to the project's backend, e.g. VITE_DEV_API_PROXY=http://localhost:8000 */
|
|
22
|
+
server: {
|
|
23
|
+
port: Number(env.VITE_DEV_PORT) || undefined,
|
|
24
|
+
proxy: env.VITE_DEV_API_PROXY
|
|
25
|
+
? { [env.VITE_API_URL || '/api']: { target: env.VITE_DEV_API_PROXY, changeOrigin: true } }
|
|
26
|
+
: undefined,
|
|
27
|
+
},
|
|
28
|
+
resolve: {
|
|
29
|
+
alias: {
|
|
30
|
+
'@': path.resolve(import.meta.dirname, './src'),
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
build: {
|
|
34
|
+
rolldownOptions: {
|
|
35
|
+
output: {
|
|
36
|
+
codeSplitting: {
|
|
37
|
+
groups: [
|
|
38
|
+
{
|
|
39
|
+
name: (id: string) => vendorChunks.find(([, pattern]) => pattern.test(id))?.[0] ?? null,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
}
|
|
47
|
+
})
|