feature/IO-2566-2567-Time-Tickets-Caching - Fix
This commit is contained in:
@@ -29,6 +29,9 @@ export function TimeTicketModalContainer({ timeTicketModal, toggleModalVisible,
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const [enterAgain, setEnterAgain] = useState(false);
|
||||
|
||||
const [lineTicketRefreshKey, setLineTicketRefreshKey] = useState(0);
|
||||
|
||||
const [insertTicket] = useMutation(INSERT_NEW_TIME_TICKET);
|
||||
const [updateTicket] = useMutation(UPDATE_TIME_TICKET);
|
||||
const {
|
||||
@@ -85,11 +88,17 @@ export function TimeTicketModalContainer({ timeTicketModal, toggleModalVisible,
|
||||
notification["success"]({
|
||||
message: t("timetickets.successes.created")
|
||||
});
|
||||
if (timeTicketModal.actions.refetch) timeTicketModal.actions.refetch();
|
||||
if (enterAgain) {
|
||||
//Capture the existing information and repopulate it.
|
||||
|
||||
const prev = form.getFieldsValue(["date", "employeeid", "flat_rate"]);
|
||||
// Refresh parent screens (Job Labor tab, etc.)
|
||||
if (timeTicketModal.actions.refetch) timeTicketModal.actions.refetch();
|
||||
|
||||
// Refresh the modal "bottom section" (allocations + embedded ticket list) for the current job
|
||||
setLineTicketRefreshKey((k) => k + 1);
|
||||
|
||||
if (enterAgain) {
|
||||
// Capture existing information and repopulate it.
|
||||
// (Include jobid so Save & New stays on the same RO if it was selected in-form.)
|
||||
const prev = form.getFieldsValue(["jobid", "date", "employeeid", "flat_rate"]);
|
||||
|
||||
form.resetFields();
|
||||
|
||||
@@ -229,6 +238,7 @@ export function TimeTicketModalContainer({ timeTicketModal, toggleModalVisible,
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
|
||||
<TimeTicketModalComponent
|
||||
isEdit={timeTicketModal.context.id}
|
||||
form={form}
|
||||
@@ -238,6 +248,8 @@ export function TimeTicketModalContainer({ timeTicketModal, toggleModalVisible,
|
||||
timeTicketModal.context?.timeticket?.committed_at ||
|
||||
(timeTicketModal.context?.timeticket?.employeeid && !timeTicketModal.context.id ? true : false)
|
||||
}
|
||||
lineTicketRefreshKey={lineTicketRefreshKey}
|
||||
isOpen={timeTicketModal.open}
|
||||
/>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user