fix атрибутов создания шаблона
This commit is contained in:
@@ -118,7 +118,7 @@ interface TemplateFormProps {
|
||||
attributeValues: AttributeValue[]
|
||||
onAttributeValuesChange: (values: AttributeValue[]) => void
|
||||
attributesLoading: boolean
|
||||
onSubmit: () => void
|
||||
onSubmit: () => void | Promise<void>
|
||||
onCancel: () => void
|
||||
submitText: string
|
||||
submitIcon: React.ReactNode
|
||||
@@ -229,7 +229,14 @@ const TemplateForm: React.FC<TemplateFormProps> = ({
|
||||
<Button variant="outline">Отмена</Button>
|
||||
</DialogClose>
|
||||
<Button
|
||||
onClick={onSubmit}
|
||||
onClick={() => {
|
||||
const result = onSubmit()
|
||||
if (result instanceof Promise) {
|
||||
result.catch(error => {
|
||||
console.error('Ошибка при выполнении операции:', error)
|
||||
})
|
||||
}
|
||||
}}
|
||||
disabled={isSubmitDisabled}
|
||||
className="min-w-[130px]"
|
||||
>
|
||||
@@ -319,18 +326,27 @@ export const TemplatesOverviewPage = () => {
|
||||
setSelectionMode(false)
|
||||
}
|
||||
|
||||
const handleCreate = () => {
|
||||
const handleCreate = async () => {
|
||||
if (newName.trim()) {
|
||||
addTemplate({
|
||||
name: newName,
|
||||
elements: [],
|
||||
description: newDescription,
|
||||
mergedCells: [],
|
||||
})
|
||||
setNewName('')
|
||||
setNewDescription('')
|
||||
setNewAttributeValues([])
|
||||
setIsDialogOpen(false)
|
||||
try {
|
||||
// Создаем шаблон с атрибутами сразу
|
||||
await addTemplate(
|
||||
{
|
||||
name: newName,
|
||||
elements: [],
|
||||
description: newDescription,
|
||||
mergedCells: [],
|
||||
},
|
||||
newAttributeValues.length > 0 ? newAttributeValues : undefined
|
||||
)
|
||||
|
||||
setNewName('')
|
||||
setNewDescription('')
|
||||
setNewAttributeValues([])
|
||||
setIsDialogOpen(false)
|
||||
} catch (error) {
|
||||
console.error('Ошибка при создании шаблона:', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user