From 5737e3738629b5cd1758a36cfc1fd9495557b10d Mon Sep 17 00:00:00 2001 From: tlartem Date: Mon, 21 Jul 2025 17:07:03 +0300 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 8 +- shared/types.ts | 1 + src/app/App.tsx | 53 ++-- .../BasicElements/ButtonGroupElement.tsx | 4 +- .../CalibrationConditionsElement.tsx | 52 ++-- src/component/BasicElements/DateElement.tsx | 6 +- src/component/BasicElements/NumberElement.tsx | 4 +- src/component/BasicElements/RadioElement.tsx | 4 +- src/component/BasicElements/SelectElement.tsx | 6 +- src/component/BasicElements/TextElement.tsx | 4 +- .../BasicElements/TextareaElement.tsx | 4 +- .../StandardsElement/StandardsDialog.tsx | 18 +- .../StandardsElement/StandardsEditor.tsx | 6 +- .../StandardsElement/StandardsPreview.tsx | 38 +-- .../StandardsElement/StandardsSelector.tsx | 253 +++++++++--------- .../{TemplateManager => }/TemplateCard.tsx | 8 +- .../TemplateManager/ExcelUploadPanel.tsx | 2 +- .../TemplateManager/FormattingToolbar.tsx | 4 +- src/component/TemplateManager/HeaderBar.tsx | 2 +- .../TemplateManager/SpreadsheetViewer.tsx | 2 +- .../TemplateManager/TemplateEditor.tsx | 2 +- .../TemplateManager/TemplateManager.tsx | 96 +++---- src/context/TemplateContext.tsx | 235 ---------------- .../template/api}/templateApiService.ts | 18 +- .../template/model/TemplateContext.tsx | 143 ++++++++++ src/lib/element-registry-init.ts | 4 +- src/page/ElementsCreation/Page.tsx | 6 +- src/page/ProtocolCreation/Page.tsx | 22 +- src/page/TemplateEditPage.tsx | 17 ++ src/page/TemplateSetup/Page.tsx | 20 -- src/page/TemplateSetup/index.ts | 1 - src/page/TemplatesOverviewPage.tsx | 46 ++++ src/page/index.ts | 2 +- src/type/imports.d.ts | 6 +- tsconfig.json | 8 +- 35 files changed, 526 insertions(+), 579 deletions(-) create mode 100644 shared/types.ts rename src/component/{TemplateManager => }/TemplateCard.tsx (92%) delete mode 100644 src/context/TemplateContext.tsx rename src/{service => entitiy/template/api}/templateApiService.ts (94%) create mode 100644 src/entitiy/template/model/TemplateContext.tsx create mode 100644 src/page/TemplateEditPage.tsx delete mode 100644 src/page/TemplateSetup/Page.tsx delete mode 100644 src/page/TemplateSetup/index.ts create mode 100644 src/page/TemplatesOverviewPage.tsx 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 })} />