implemented form rendering logic
This commit is contained in:
@@ -12,7 +12,7 @@ const ActionDialog = ({ open, type, rowData, onClose, mutate }) => {
|
|||||||
<Dialog open={open} fullWidth maxWidth="xs" onClose={onClose}>
|
<Dialog open={open} fullWidth maxWidth="xs" onClose={onClose}>
|
||||||
<DialogTitle>{actionLabel}</DialogTitle>
|
<DialogTitle>{actionLabel}</DialogTitle>
|
||||||
|
|
||||||
<RenderActionForm type={type} rowData={rowData} mutate={mutate} />
|
<RenderActionForm type={type} rowData={rowData} mutate={mutate} onClose={onClose} />
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,71 +6,27 @@ import ReferForm from "./Forms/ReferForm";
|
|||||||
import RejectFileForm from "./Forms/RejectFileForm";
|
import RejectFileForm from "./Forms/RejectFileForm";
|
||||||
import RejectRequestForm from "./Forms/RejectRequestForm";
|
import RejectRequestForm from "./Forms/RejectRequestForm";
|
||||||
|
|
||||||
export default function RenderActionForm({ type, rowData, mutate }) {
|
export default function RenderActionForm({ type, rowData, mutate, onClose }) {
|
||||||
const formType = `${type}_${rowData?.state_id}`;
|
const formType = `${type}_${rowData?.state_id}`;
|
||||||
|
|
||||||
console.log(formType);
|
|
||||||
|
|
||||||
function renderForm() {
|
function renderForm() {
|
||||||
switch (formType) {
|
switch (formType) {
|
||||||
case "refer_request_2":
|
case "refer_request_2":
|
||||||
return <ReferForm mutate={mutate} />;
|
return <ReferForm mutate={mutate} onClose={onClose} />;
|
||||||
case "reject_request_2":
|
case "reject_request_2":
|
||||||
return <RejectRequestForm mutate={mutate} />;
|
return <RejectRequestForm mutate={mutate} onClose={onClose} />;
|
||||||
case "reject_request_5":
|
case "reject_request_5":
|
||||||
return <RejectFileForm mutate={mutate} />;
|
return <RejectFileForm mutate={mutate} onClose={onClose} />;
|
||||||
case "confirm_request_2":
|
case "confirm_request_2":
|
||||||
return <ConfirmRequestForm mutate={mutate} />;
|
return <ConfirmRequestForm mutate={mutate} onClose={onClose} />;
|
||||||
case "confirm_request_5":
|
case "confirm_request_5":
|
||||||
return <ConfirmFileForm mutate={mutate} />;
|
return <ConfirmFileForm mutate={mutate} onClose={onClose} />;
|
||||||
case "confirm_request_13":
|
case "confirm_request_13":
|
||||||
return <ComputePaymentForm mutate={mutate} />;
|
return <ComputePaymentForm mutate={mutate} onClose={onClose} />;
|
||||||
default:
|
default:
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return <DialogContent>{renderForm(formType)}</DialogContent>;
|
return <DialogContent>{renderForm()}</DialogContent>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
<Box sx={{ display: "flex", flexDirection: "column", mt: 1 }}>
|
|
||||||
<Controller
|
|
||||||
name="expert_description"
|
|
||||||
control={control}
|
|
||||||
render={({ field }) => <TextField {...field} fullWidth multiline minRows={3} label="توضیحات" />}
|
|
||||||
/>
|
|
||||||
{type === "confirm_request" && (
|
|
||||||
<>
|
|
||||||
<Controller
|
|
||||||
name="need_payment"
|
|
||||||
control={control}
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormControlLabel
|
|
||||||
control={<Checkbox {...field} checked={field.value} />}
|
|
||||||
label="نیاز به پرداخت وجه خزانه"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Checkbox
|
|
||||||
checked={needsAccessRoad}
|
|
||||||
onChange={(e) => setNeedsAccessRoad(e.target.checked)}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label="نیاز به راه دسترسی"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<DialogActions>
|
|
||||||
<Button onClick={onClose} variant="outlined" disabled={isSubmitting}>
|
|
||||||
انصراف
|
|
||||||
</Button>
|
|
||||||
<Button variant="contained" onClick={handleSubmit(onSubmit)} disabled={isSubmitting}>
|
|
||||||
انجام عملیات
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
|
||||||
*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user