diff --git a/.eslintrc.js b/.eslintrc.js index bcc3420..b744197 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -31,10 +31,10 @@ module.exports = { pathGroups: [ { pattern: 'react', group: 'builtin' }, { pattern: '~shared/**', group: 'internal', position: 'before' }, - { pattern: '~entities/**', group: 'internal', position: 'before' }, - { pattern: '~features/**', group: 'internal', position: 'before' }, - { pattern: '~widgets/**', group: 'internal', position: 'before' }, - { pattern: '~pages/**', group: 'internal', position: 'before' }, + { pattern: '~entitiy/**', group: 'internal', position: 'before' }, + { pattern: '~feature/**', group: 'internal', position: 'before' }, + { pattern: '~widget/**', group: 'internal', position: 'before' }, + { pattern: '~page/**', group: 'internal', position: 'before' }, ], pathGroupsExcludedImportTypes: ['builtin'], groups: [ diff --git a/shared/types.ts b/shared/types.ts new file mode 100644 index 0000000..84ddb97 --- /dev/null +++ b/shared/types.ts @@ -0,0 +1 @@ +type UUID = string diff --git a/src/app/App.tsx b/src/app/App.tsx index d5a9368..7ae64f3 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -2,34 +2,39 @@ import { FC } from 'react' import { Navigate, Route, Routes } from 'react-router-dom' -import { TemplateProvider } from '../context/TemplateContext' -import { ElementsCreation } from '../page/ElementsCreation' -import { ProtocolCreation } from '../page/ProtocolCreation' -import { TemplateSetup } from '../page/TemplateSetup' +import { TemplateProvider } from '@/entitiy/template/model/TemplateContext' +import { ElementsCreation } from '@/page/ElementsCreation' +import { ProtocolCreation } from '@/page/ProtocolCreation' +import { TemplateEditPage } from '@/page/TemplateEditPage' +import { TemplatesOverviewPage } from '@/page/TemplatesOverviewPage' +import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { Layout } from './Layout' +const queryClient = new QueryClient() const App: FC = () => { return ( - - - }> - } /> - } /> - } - /> - } - /> - } - /> - - - + + + + }> + } /> + } /> + } + /> + } + /> + } + /> + + + + ) } diff --git a/src/component/BasicElements/ButtonGroupElement.tsx b/src/component/BasicElements/ButtonGroupElement.tsx index 40c1464..90a2453 100644 --- a/src/component/BasicElements/ButtonGroupElement.tsx +++ b/src/component/BasicElements/ButtonGroupElement.tsx @@ -1,5 +1,5 @@ -import { Button } from '@/components/ui/button' -import { Input } from '@/components/ui/input' +import { Button } from '@/component/ui/button' +import { Input } from '@/component/ui/input' import { ElementDefinition } from '@/lib/element-registry' import { ElementOption } from '@/type/template' import { Plus, Square, Trash2 } from 'lucide-react' diff --git a/src/component/BasicElements/CalibrationConditionsElement.tsx b/src/component/BasicElements/CalibrationConditionsElement.tsx index 62bebcb..7d7cbc1 100644 --- a/src/component/BasicElements/CalibrationConditionsElement.tsx +++ b/src/component/BasicElements/CalibrationConditionsElement.tsx @@ -1,8 +1,8 @@ -import { Badge } from '@/components/ui/badge' -import { Button } from '@/components/ui/button' -import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' -import { Input } from '@/components/ui/input' -import { Label } from '@/components/ui/label' +import { Badge } from '@/component/ui/badge' +import { Button } from '@/component/ui/button' +import { Card, CardContent, CardHeader, CardTitle } from '@/component/ui/card' +import { Input } from '@/component/ui/input' +import { Label } from '@/component/ui/label' import { ElementDefinition } from '@/lib/element-registry' import { AlertCircle, @@ -91,7 +91,7 @@ const formatLastUpdated = (dateString: string) => { const monthShortRu = date .toLocaleString('ru-RU', { month: 'short' }) .replace(/\./, '') - .replace(/^./, (s) => s.toUpperCase()) + .replace(/^./, s => s.toUpperCase()) const day = date.getDate() const time: string = date.toLocaleString('ru-RU', { hour: '2-digit', @@ -103,8 +103,8 @@ const formatLastUpdated = (dateString: string) => { } else if (date.toDateString() === yesterday.toDateString()) { return `Вчера в ${time}` } else { - return `${weekdayRu.replace(/^./, (s) => - s.toUpperCase(), + return `${weekdayRu.replace(/^./, s => + s.toUpperCase() )} ${day} ${monthShortRu} ${time}` } } @@ -136,10 +136,10 @@ function CalibrationCondInfo({ 'frequency', ] - fields.forEach((field) => { + fields.forEach(field => { const validation = validateField( field, - tempConditions[field as keyof CalibrationConditions] as string, + tempConditions[field as keyof CalibrationConditions] as string ) if (!validation.isValid && validation.message) { errors[field] = validation.message @@ -151,11 +151,11 @@ function CalibrationCondInfo({ } const handleFieldChange = (field: string, value: string) => { - setTempConditions((prev) => ({ ...prev, [field]: value })) + setTempConditions(prev => ({ ...prev, [field]: value })) // Валидация в реальном времени const validation = validateField(field, value) - setValidationErrors((prev) => ({ + setValidationErrors(prev => ({ ...prev, [field]: validation.isValid ? '' : validation.message || '', })) @@ -187,7 +187,7 @@ function CalibrationCondInfo({ // Устанавливаем фокус на первое поле через небольшую задержку setTimeout(() => { const firstInput = document.getElementById( - 'modal-temperature', + 'modal-temperature' ) as HTMLInputElement if (firstInput) { firstInput.focus() @@ -199,7 +199,7 @@ function CalibrationCondInfo({ const handleKeyDown = (e: React.KeyboardEvent) => { if ( e.key === 'Enter' && - !Object.keys(validationErrors).some((key) => validationErrors[key]) + !Object.keys(validationErrors).some(key => validationErrors[key]) ) { handleSave() } @@ -321,10 +321,10 @@ function CalibrationCondInfo({ key as keyof CalibrationConditions ] as string } - onChange={(e) => + onChange={e => handleFieldChange(key, e.target.value) } - onKeyDown={(e) => { + onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault() handleSave() @@ -334,8 +334,8 @@ function CalibrationCondInfo({ hasError ? 'border-destructive focus-visible:ring-destructive' : isValid - ? 'border-green-500 focus-visible:ring-green-500' - : '' + ? 'border-green-500 focus-visible:ring-green-500' + : '' }`} placeholder={placeholder} type="number" @@ -361,7 +361,7 @@ function CalibrationCondInfo({ ) - }, + } )} @@ -385,7 +385,7 @@ function CalibrationCondInfo({ disabled={ isLoading || Object.keys(validationErrors).some( - (key) => validationErrors[key], + key => validationErrors[key] ) } > @@ -463,7 +463,7 @@ export const calibrationConditionsDefinition: ElementDefinition< + onChange={e => onChange({ ...config, defaultConditions: { @@ -489,7 +489,7 @@ export const calibrationConditionsDefinition: ElementDefinition< + onChange={e => onChange({ ...config, defaultConditions: { @@ -515,7 +515,7 @@ export const calibrationConditionsDefinition: ElementDefinition< + onChange={e => onChange({ ...config, defaultConditions: { @@ -541,7 +541,7 @@ export const calibrationConditionsDefinition: ElementDefinition< + onChange={e => onChange({ ...config, defaultConditions: { @@ -567,7 +567,7 @@ export const calibrationConditionsDefinition: ElementDefinition< + onChange={e => onChange({ ...config, defaultConditions: { @@ -632,7 +632,7 @@ export const calibrationConditionsDefinition: ElementDefinition< { + onUpdate={async newConditions => { onChange?.(newConditions) return true }} diff --git a/src/component/BasicElements/DateElement.tsx b/src/component/BasicElements/DateElement.tsx index 69c21b7..b0bab50 100644 --- a/src/component/BasicElements/DateElement.tsx +++ b/src/component/BasicElements/DateElement.tsx @@ -1,4 +1,4 @@ -import { Input } from '@/components/ui/input' +import { Input } from '@/component/ui/input' import { ElementDefinition } from '@/lib/element-registry' import { Calendar } from 'lucide-react' @@ -22,7 +22,7 @@ export const dateDefinition: ElementDefinition = { type="checkbox" id="required" checked={config.required} - onChange={(e) => onChange({ ...config, required: e.target.checked })} + onChange={e => onChange({ ...config, required: e.target.checked })} />