Кнопка create_task открывает CreateTaskDialog вместо несуществующего маршрута
This commit is contained in:
@@ -4,6 +4,7 @@ import { useQuery, useMutation } from '@tanstack/react-query';
|
||||
import Layout from '@/components/Layout';
|
||||
import { Sidebar } from '@/components/Sidebar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { CreateTaskDialog } from '@/components/CreateTaskDialog';
|
||||
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '@/components/ui/dialog';
|
||||
import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from '@/components/ui/accordion';
|
||||
@@ -315,13 +316,13 @@ function TableValueDisplay({ tableId, displayColumn, rowId }: { tableId: number;
|
||||
|
||||
// Компонент для рендеринга кнопки с действием
|
||||
function ButtonField({ field, taskId }: { field: FormFieldData; taskId?: number }) {
|
||||
const [, setLocation] = useLocation();
|
||||
const [createDialogOpen, setCreateDialogOpen] = useState(false);
|
||||
|
||||
const handleButtonClick = () => {
|
||||
if (field.buttonActionType === 'open_url' && field.buttonUrl) {
|
||||
window.open(field.buttonUrl, '_blank', 'noopener,noreferrer');
|
||||
} else if (field.buttonActionType === 'create_task' && field.buttonFormId) {
|
||||
setLocation(`/forms/${field.buttonFormId}/tasks/new`);
|
||||
setCreateDialogOpen(true);
|
||||
} else if (field.buttonActionType === 'generate_document' && taskId) {
|
||||
const opts = (field.options || {}) as {
|
||||
documentTemplateId?: number;
|
||||
@@ -356,6 +357,13 @@ function ButtonField({ field, taskId }: { field: FormFieldData; taskId?: number
|
||||
{field.buttonActionType === 'generate_document' && <FileText className="w-4 h-4 mr-2" />}
|
||||
{field.name}
|
||||
</Button>
|
||||
{field.buttonActionType === 'create_task' && field.buttonFormId && (
|
||||
<CreateTaskDialog
|
||||
formId={field.buttonFormId}
|
||||
open={createDialogOpen}
|
||||
onOpenChange={setCreateDialogOpen}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user