feat: bulk test case creation (#346)
This commit is contained in:
committed by
GitHub
parent
8585976d38
commit
92d6340ddc
@@ -1,12 +1,22 @@
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
import { Button, Input, Textarea, Modal, ModalContent, ModalHeader, ModalBody, ModalFooter } from '@heroui/react';
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
Textarea,
|
||||
Modal,
|
||||
ModalContent,
|
||||
ModalHeader,
|
||||
ModalBody,
|
||||
ModalFooter,
|
||||
Switch,
|
||||
} from '@heroui/react';
|
||||
import { CasesMessages } from '@/types/case';
|
||||
|
||||
type Props = {
|
||||
isOpen: boolean;
|
||||
onCancel: () => void;
|
||||
onSubmit: (title: string, description: string) => void;
|
||||
onSubmit: (title: string, description: string, createMore: boolean) => void;
|
||||
messages: CasesMessages;
|
||||
};
|
||||
|
||||
@@ -23,6 +33,8 @@ export default function CaseDialog({ isOpen, onCancel, onSubmit, messages }: Pro
|
||||
errorMessage: '',
|
||||
});
|
||||
|
||||
const [createMore, setCreateMore] = useState(false);
|
||||
|
||||
const clear = () => {
|
||||
setCaseName({
|
||||
isValid: false,
|
||||
@@ -47,8 +59,23 @@ export default function CaseDialog({ isOpen, onCancel, onSubmit, messages }: Pro
|
||||
return;
|
||||
}
|
||||
|
||||
onSubmit(caseTitle.text, caseDescription.text);
|
||||
clear();
|
||||
onSubmit(caseTitle.text, caseDescription.text, createMore);
|
||||
|
||||
if (!createMore) {
|
||||
clear();
|
||||
} else {
|
||||
// Reset form fields but keep dialog open
|
||||
setCaseName({
|
||||
isValid: false,
|
||||
text: 'Untitled Case',
|
||||
errorMessage: '',
|
||||
});
|
||||
setCaseDescription({
|
||||
isValid: false,
|
||||
text: '',
|
||||
errorMessage: '',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -88,9 +115,9 @@ export default function CaseDialog({ isOpen, onCancel, onSubmit, messages }: Pro
|
||||
/>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button variant="light" onPress={onCancel}>
|
||||
{messages.close}
|
||||
</Button>
|
||||
<Switch size="sm" isSelected={createMore} onValueChange={setCreateMore}>
|
||||
{messages.createMore}
|
||||
</Switch>
|
||||
<Button color="primary" onPress={validate}>
|
||||
{messages.create}
|
||||
</Button>
|
||||
|
||||
@@ -112,10 +112,12 @@ export default function CasesPane({
|
||||
|
||||
const closeDialog = () => setIsCaseDialogOpen(false);
|
||||
|
||||
const onSubmit = async (title: string, description: string) => {
|
||||
const onSubmit = async (title: string, description: string, createMore: boolean) => {
|
||||
const newCase = await createCase(context.token.access_token, folderId, title, description);
|
||||
setCases([...cases, newCase]);
|
||||
closeDialog();
|
||||
if (!createMore) {
|
||||
closeDialog();
|
||||
}
|
||||
};
|
||||
|
||||
const closeDeleteConfirmDialog = () => {
|
||||
|
||||
@@ -57,6 +57,7 @@ export default function Page({ params }: { params: { projectId: string; folderId
|
||||
orDragAndDrop: t('or_drag_and_drop'),
|
||||
maxFileSize: t('max_file_size'),
|
||||
casesImported: t('cases_imported'),
|
||||
createMore: t('create_more'),
|
||||
};
|
||||
|
||||
const priorityTranslation = useTranslations('Priority');
|
||||
|
||||
Reference in New Issue
Block a user