Ручные правки
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Plus, Wrench } from 'lucide-react'
|
||||
import { FC, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { FC, useEffect, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { ElementConstructor } from '../../../../components/TemplateManager/ElementConstructor'
|
||||
import { Button } from '../../../../components/ui/button'
|
||||
import {
|
||||
@@ -19,11 +19,25 @@ import {
|
||||
|
||||
export const ElementsCreation: FC = () => {
|
||||
const navigate = useNavigate()
|
||||
const { templateId } = useParams<{ templateId: string }>()
|
||||
const { templates, updateTemplate } = useTemplateContext()
|
||||
const [selectedTemplate, setSelectedTemplate] = useState<Template | null>(
|
||||
null,
|
||||
)
|
||||
|
||||
// Автоматически выбираем шаблон, если передан templateId
|
||||
useEffect(() => {
|
||||
if (templateId) {
|
||||
const template = templates.find((t) => t.id === templateId)
|
||||
if (template) {
|
||||
setSelectedTemplate(template)
|
||||
} else {
|
||||
// Если шаблон не найден, перенаправляем на страницу со списком шаблонов
|
||||
navigate('/templates', { replace: true })
|
||||
}
|
||||
}
|
||||
}, [templateId, templates, navigate])
|
||||
|
||||
const handleTemplateSelect = (template: Template) => {
|
||||
setSelectedTemplate(template)
|
||||
}
|
||||
@@ -112,10 +126,6 @@ export const ElementsCreation: FC = () => {
|
||||
setSelectedTemplate(updatedTemplate)
|
||||
}
|
||||
|
||||
const handleBack = () => {
|
||||
setSelectedTemplate(null)
|
||||
}
|
||||
|
||||
// Настройки отображения по умолчанию
|
||||
const defaultLayoutSettings: FormLayoutSettings = {
|
||||
gridSize: 20,
|
||||
@@ -128,7 +138,7 @@ export const ElementsCreation: FC = () => {
|
||||
<div className="sticky top-0 z-50 border-b border-gray-200 bg-white p-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<Button variant="ghost" onClick={handleBack}>
|
||||
<Button variant="ghost" onClick={() => navigate(`/templates`)}>
|
||||
← Назад
|
||||
</Button>
|
||||
<div>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
import Home from "./ui/Page/Page";
|
||||
|
||||
export { Home };
|
||||
@@ -1,18 +0,0 @@
|
||||
import { FC } from "react";
|
||||
import { DualSpreadsheet } from "../../../../components";
|
||||
// import { exampleCalculationsData, exampleTemplateData } from "../../../../lib/template-data";
|
||||
|
||||
const Home: FC = () => {
|
||||
const initialData = {
|
||||
Report: {},
|
||||
Calculations: {}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="h-screen bg-gray-50">
|
||||
<DualSpreadsheet templateData={initialData} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Home;
|
||||
@@ -8,8 +8,8 @@ import {
|
||||
Settings,
|
||||
Wrench,
|
||||
} from 'lucide-react'
|
||||
import { FC, useMemo, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { FC, useEffect, useMemo, useState } from 'react'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { StandardsSelector } from '../../../../components/StandardsElement/StandardsSelector'
|
||||
import { Badge } from '../../../../components/ui/badge'
|
||||
import { Button } from '../../../../components/ui/button'
|
||||
@@ -525,24 +525,39 @@ const ProtocolForm: FC<ProtocolFormProps> = ({ template, onSave, onBack }) => {
|
||||
|
||||
export const ProtocolCreation: FC = () => {
|
||||
const navigate = useNavigate()
|
||||
const { templateId } = useParams<{ templateId?: string }>()
|
||||
const { templates } = useTemplateContext()
|
||||
const [selectedTemplate, setSelectedTemplate] = useState<Template | null>(
|
||||
null,
|
||||
)
|
||||
|
||||
// Автоматически выбираем шаблон если передан ID в URL
|
||||
useEffect(() => {
|
||||
if (templateId && templates.length > 0) {
|
||||
const template = templates.find((t) => t.id === templateId)
|
||||
if (template) {
|
||||
setSelectedTemplate(template)
|
||||
}
|
||||
}
|
||||
}, [templateId, templates])
|
||||
|
||||
const handleTemplateSelect = (template: Template) => {
|
||||
setSelectedTemplate(template)
|
||||
// Обновляем URL с ID выбранного шаблона
|
||||
navigate(`/create-protocol/${template.id}`)
|
||||
}
|
||||
|
||||
const handleProtocolSave = (data: Record<string, any>) => {
|
||||
console.log('Сохранение протокола:', data)
|
||||
// Здесь будет логика сохранения протокола
|
||||
alert(`Протокол "${data.protocolName}" сохранен!`)
|
||||
navigate('/')
|
||||
navigate('/templates')
|
||||
}
|
||||
|
||||
const handleBack = () => {
|
||||
setSelectedTemplate(null)
|
||||
// Возвращаемся к списку шаблонов
|
||||
navigate('/templates')
|
||||
}
|
||||
|
||||
if (selectedTemplate) {
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
import { FC } from 'react';
|
||||
import { TemplateManager } from '../../../../components/TemplateManager/TemplateManager';
|
||||
import { FC, useEffect } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
import { TemplateManager } from '../../../../components/TemplateManager/TemplateManager'
|
||||
import { useTemplateContext } from '../../../../contexts/TemplateContext'
|
||||
|
||||
export const TemplateSetup: FC = () => {
|
||||
return <TemplateManager />;
|
||||
};
|
||||
const { templateId } = useParams<{ templateId: string }>()
|
||||
const { templates } = useTemplateContext()
|
||||
|
||||
useEffect(() => {
|
||||
if (templateId) {
|
||||
const template = templates.find((t) => t.id === templateId)
|
||||
if (template) {
|
||||
console.log('Opening template for editing:', template)
|
||||
}
|
||||
}
|
||||
}, [templateId, templates])
|
||||
|
||||
return <TemplateManager templateId={templateId} />
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { ElementsCreation } from "./ElementsCreation";
|
||||
import { Home } from "./Home";
|
||||
import { NoMatch } from "./NoMatch";
|
||||
import { ProtocolCreation } from "./ProtocolCreation";
|
||||
import { TemplateSetup } from "./TemplateSetup";
|
||||
|
||||
export { ElementsCreation, Home, NoMatch, ProtocolCreation, TemplateSetup };
|
||||
import { ElementsCreation } from './ElementsCreation'
|
||||
import { NoMatch } from './NoMatch'
|
||||
import { ProtocolCreation } from './ProtocolCreation'
|
||||
import { TemplateSetup } from './TemplateSetup'
|
||||
|
||||
export { ElementsCreation, NoMatch, ProtocolCreation, TemplateSetup }
|
||||
|
||||
Reference in New Issue
Block a user