@@ -49,10 +49,8 @@ const CreateModal = ({ setShowModal, caseData }) => {
|
||||
return hasErrors ? null : objectMap(({ value }) => value, newData);
|
||||
};
|
||||
|
||||
async function saveCaseData() {
|
||||
const dataValues = validateData();
|
||||
|
||||
if (dataValues === null) {
|
||||
async function saveCaseData(dataValues) {
|
||||
if (isBusy) {
|
||||
return;
|
||||
}
|
||||
setIsBusy(true);
|
||||
@@ -90,10 +88,20 @@ const CreateModal = ({ setShowModal, caseData }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreate = () => {
|
||||
if (!isBusy) {
|
||||
void saveCaseData();
|
||||
const handleCreateCase = (e) => {
|
||||
e.preventDefault();
|
||||
const dataValues = validateData();
|
||||
|
||||
if (dataValues === null) {
|
||||
return;
|
||||
} else {
|
||||
try {
|
||||
saveCaseData(dataValues);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
|
||||
navigate("/dashboard");
|
||||
};
|
||||
|
||||
@@ -528,7 +536,7 @@ const CreateModal = ({ setShowModal, caseData }) => {
|
||||
<Button
|
||||
className="primary-button"
|
||||
disabled={isBusy}
|
||||
onClick={handleCreate}
|
||||
onClick={handleCreateCase}
|
||||
labelText="Save Case"
|
||||
/>
|
||||
</Modal.Footer>
|
||||
|
||||
@@ -180,7 +180,6 @@ const SignupPage = () => {
|
||||
<Row key={`row${j}`}>
|
||||
{names.map((name, i) => (
|
||||
<Col key={`${name}${i + fieldsChunkSize * j}`} className="mb-3">
|
||||
{console.log("data, name", data, name)}
|
||||
<TextInput
|
||||
name={name}
|
||||
value={data[name].value}
|
||||
|
||||
@@ -96,8 +96,10 @@ export const handleFormDataChange = (e, name, data, fields) => {
|
||||
return null;
|
||||
};
|
||||
|
||||
export const isFormDataHasErrors = (data) =>
|
||||
Object.values(data).reduce(
|
||||
export const isFormDataHasErrors = (data) => {
|
||||
console.log("data", data);
|
||||
return Object.values(data).reduce(
|
||||
(hasErrors, { error }) => hasErrors || error,
|
||||
false
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user