'use client'; import clsx from 'clsx'; import { useEffect, useRef, useState } from 'react'; import { BiDownload } from 'react-icons/bi'; import { toast } from 'react-toastify'; import Button from '@/components/Common/Button'; import Checkbox from '@/components/Common/Checkbox'; import Label from '@/components/Common/Label'; import MiniButton from '@/components/Common/MiniButton'; import Overlay from '@/components/Common/Overlay'; import SubmitButton from '@/components/Common/SubmitButton'; import TextArea from '@/components/Common/TextArea'; import TextInput from '@/components/Common/TextInput'; import InfoError from '@/components/InfoError'; import RequireAuth from '@/components/RequireAuth'; import { useLibrary } from '@/context/LibraryContext'; import { useConceptNavigation } from '@/context/NavigationContext'; import { LibraryItemType } from '@/models/library'; import { IRSFormCreateData } from '@/models/rsform'; import { classnames, EXTEOR_TRS_FILE, limits, patterns } from '@/utils/constants'; function CreateRSFormPage() { const router = useConceptNavigation(); const { createItem, error, setError, processing } = useLibrary(); const [title, setTitle] = useState(''); const [alias, setAlias] = useState(''); const [comment, setComment] = useState(''); const [common, setCommon] = useState(false); const [fileName, setFileName] = useState(''); const [file, setFile] = useState(); const inputRef = useRef(null); useEffect(() => { setError(undefined); }, [title, alias, setError]); function handleCancel() { if (router.canBack()) { router.back(); } else { router.push('/library'); } } function handleSubmit(event: React.FormEvent) { event.preventDefault(); if (processing) { return; } const data: IRSFormCreateData = { item_type: LibraryItemType.RSFORM, title: title, alias: alias, comment: comment, is_common: common, is_canonical: false, file: file, fileName: file?.name }; createItem(data, newSchema => { toast.success('Схема успешно создана'); router.push(`/rsforms/${newSchema.id}`); }); } function handleFileChange(event: React.ChangeEvent) { if (event.target.files && event.target.files.length > 0) { setFileName(event.target.files[0].name); setFile(event.target.files[0]); } else { setFileName(''); setFile(undefined); } } return (

Создание концептуальной схемы

} onClick={() => inputRef.current?.click()} /> {fileName ?