feat(admin-ui): minimal React+Vite+TanStack scaffolding
- Vite 7 + React 19 + TanStack Router (file-based) + TanStack Query - Tailwind v4 (CSS-first config, OKLCH brand colors) - i18next + react-i18next с RU/EN switcher в header - Axios client с Accept-Language interceptor + JWT placeholder - 2 pages: /dictionaries (list cards) + /dictionaries/$name (records table) - Dockerfile (node build + nginx serving + API proxy) - README + .gitignore Backend: - Новый GET /api/v1/dictionaries в read-api (DictionaryListController), фильтрует по доступному scope через ScopeContext - DictionaryListItem DTO без heavy schema_json routeTree.gen.ts — stub; реальное содержимое генерится Vite plugin'ом при первом 'pnpm dev'.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { useQuery, queryOptions } from '@tanstack/react-query'
|
||||
import { apiClient, type DictionaryDefinition, type FlattenedRecord } from './client'
|
||||
|
||||
export const dictionariesQuery = queryOptions({
|
||||
queryKey: ['dictionaries'],
|
||||
queryFn: async (): Promise<DictionaryDefinition[]> => {
|
||||
const { data } = await apiClient.get<DictionaryDefinition[]>('/dictionaries')
|
||||
return data
|
||||
},
|
||||
})
|
||||
|
||||
export const recordsQuery = (dictionaryName: string, scopeCsv: string) =>
|
||||
queryOptions({
|
||||
queryKey: ['records', dictionaryName, scopeCsv],
|
||||
queryFn: async (): Promise<FlattenedRecord[]> => {
|
||||
const { data } = await apiClient.get<FlattenedRecord[]>(
|
||||
`/${dictionaryName}/records`,
|
||||
{ params: { as_scope: scopeCsv } },
|
||||
)
|
||||
return data
|
||||
},
|
||||
})
|
||||
|
||||
export const useDictionaries = () => useQuery(dictionariesQuery)
|
||||
export const useRecords = (dictionaryName: string, scopeCsv: string) =>
|
||||
useQuery(recordsQuery(dictionaryName, scopeCsv))
|
||||
Reference in New Issue
Block a user