Refactor; add, edit and delete contract forms logic and api calls

This commit is contained in:
Ayobami
2025-07-06 23:10:29 +01:00
parent b7bbcc50c6
commit e9f51d6ea0
13 changed files with 197 additions and 102 deletions
@@ -7,7 +7,7 @@ import { Label } from 'Components/Label';
import { TextBox } from 'Components/TextBox';
import { CheckBox } from 'Components/CheckBox';
import { TextArea } from 'Components/TextArea';
import { ContractFormsSuccessToast } from '../ContractFormsSuccessToast';
import { ContractFormsToast } from '../ContractFormsToast';
import classes from './contractFormsModal.module.css';
@@ -35,6 +35,7 @@ interface Props {
submitText: string;
showToast: boolean;
toastMessage: string;
toastType?: string;
onFormSubmit: (e: any) => void;
onClickClose: (e: any) => void;
handleChange: (e: any) => void;
@@ -51,6 +52,7 @@ const ContractFormsModal = ({
formErrors,
showToast,
toastMessage,
toastType = 'success',
onFormSubmit,
onClickClose,
handleChange,
@@ -66,7 +68,7 @@ const ContractFormsModal = ({
leftHeaderIcon="projects"
modalHeader
modalCloseClick={onClickClose}
toast={<ContractFormsSuccessToast showToast={showToast} message={toastMessage} />}
toast={<ContractFormsToast type={toastType as 'success' | 'error'} showToast={showToast} message={toastMessage} />}
>
<form className={classes.form} onSubmit={onFormSubmit}>
<ValidateBackGround isValid={!formErrors?.name.length}>
@@ -139,6 +141,10 @@ const ContractFormsModal = ({
</Modal>
);
ContractFormsModal.defaultProps = {
toastType: 'success',
};
const ContractFormsModalMemo = memo(ContractFormsModal, areEqual);
export { ContractFormsModalMemo as ContractFormsModal };