Merged in feature/IO-3558-Reynolds-Part-2 (pull request #2990)
feature/IO-3558-Reynolds-Part-2 - Admin Panel
This commit is contained in:
@@ -38,6 +38,7 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO, insertAuditTr
|
|||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [earlyRoCreated, setEarlyRoCreated] = useState(!!job?.dms_id); // Track early RO creation state
|
const [earlyRoCreated, setEarlyRoCreated] = useState(!!job?.dms_id); // Track early RO creation state
|
||||||
|
const [earlyRoCreatedThisSession, setEarlyRoCreatedThisSession] = useState(false); // Track if created in THIS modal session
|
||||||
const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO);
|
const [mutationConvertJob] = useMutation(CONVERT_JOB_TO_RO);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -58,9 +59,6 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO, insertAuditTr
|
|||||||
const dmsMode = getDmsMode(bodyshop, Fortellis.treatment);
|
const dmsMode = getDmsMode(bodyshop, Fortellis.treatment);
|
||||||
const isReynoldsMode = dmsMode === DMS_MAP.reynolds;
|
const isReynoldsMode = dmsMode === DMS_MAP.reynolds;
|
||||||
|
|
||||||
console.log(`2309-829038721093820938290382903`);
|
|
||||||
console.log(isReynoldsMode);
|
|
||||||
|
|
||||||
const handleConvert = async ({ employee_csr, category, ...values }) => {
|
const handleConvert = async ({ employee_csr, category, ...values }) => {
|
||||||
if (parentFormIsFieldsTouched()) {
|
if (parentFormIsFieldsTouched()) {
|
||||||
alert(t("jobs.labels.savebeforeconversion"));
|
alert(t("jobs.labels.savebeforeconversion"));
|
||||||
@@ -105,8 +103,8 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO, insertAuditTr
|
|||||||
const submitDisabled = useCallback(() => some(allFormValues, (v) => v === undefined), [allFormValues]);
|
const submitDisabled = useCallback(() => some(allFormValues, (v) => v === undefined), [allFormValues]);
|
||||||
|
|
||||||
const handleEarlyROSuccess = (result) => {
|
const handleEarlyROSuccess = (result) => {
|
||||||
console.log("Early RO Success - result:", result);
|
|
||||||
setEarlyRoCreated(true); // Mark early RO as created
|
setEarlyRoCreated(true); // Mark early RO as created
|
||||||
|
setEarlyRoCreatedThisSession(true); // Mark as created in this session
|
||||||
notification.success({
|
notification.success({
|
||||||
title: t("jobs.successes.early_ro_created", "Early RO Created"),
|
title: t("jobs.successes.early_ro_created", "Early RO Created"),
|
||||||
message: `RO Number: ${result.roNumber || "N/A"}`
|
message: `RO Number: ${result.roNumber || "N/A"}`
|
||||||
@@ -133,6 +131,7 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO, insertAuditTr
|
|||||||
loading={loading}
|
loading={loading}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setEarlyRoCreated(!!job?.dms_id); // Initialize state based on current job
|
setEarlyRoCreated(!!job?.dms_id); // Initialize state based on current job
|
||||||
|
setEarlyRoCreatedThisSession(false); // Reset session state when opening modal
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -143,8 +142,8 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO, insertAuditTr
|
|||||||
<Modal
|
<Modal
|
||||||
open={open}
|
open={open}
|
||||||
onCancel={handleModalClose}
|
onCancel={handleModalClose}
|
||||||
closable={!(earlyRoCreated && !job.converted)} // Disable X button if early RO created but not converted
|
closable={!(earlyRoCreatedThisSession && !job.converted)} // Only restrict if created in THIS session
|
||||||
maskClosable={!(earlyRoCreated && !job.converted)} // Disable clicking outside to close
|
maskClosable={!(earlyRoCreatedThisSession && !job.converted)} // Only restrict if created in THIS session
|
||||||
title={t("jobs.actions.convert")}
|
title={t("jobs.actions.convert")}
|
||||||
footer={null}
|
footer={null}
|
||||||
width={700}
|
width={700}
|
||||||
@@ -317,10 +316,7 @@ export function JobsConvertButton({ bodyshop, job, refetch, jobRO, insertAuditTr
|
|||||||
>
|
>
|
||||||
{t("jobs.actions.convert")}
|
{t("jobs.actions.convert")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button onClick={handleModalClose} disabled={earlyRoCreatedThisSession && !job.converted}>
|
||||||
onClick={handleModalClose}
|
|
||||||
disabled={earlyRoCreated && !job.converted}
|
|
||||||
>
|
|
||||||
{t("general.actions.close")}
|
{t("general.actions.close")}
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
|
|||||||
Reference in New Issue
Block a user