mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 10:28:59 +00:00
refactor(workorders): extract slide-over open-tab effect to meet function size cap
This commit is contained in:
parent
f9b5d3e0ea
commit
e6548ffa17
1 changed files with 24 additions and 8 deletions
|
|
@ -77,6 +77,29 @@ function useSlideOverInitialization({
|
||||||
}, [row?.id, editMode]);
|
}, [row?.id, editMode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Re-apply the requested tab on every open, including a second notification for the work order
|
||||||
|
// already on screen (same row id) where the identity effect does not re-run. Tab-only so an
|
||||||
|
// in-flight edit draft is never discarded.
|
||||||
|
function useSlideOverOpenRequestTab({
|
||||||
|
row,
|
||||||
|
editMode,
|
||||||
|
initialTab,
|
||||||
|
setTab,
|
||||||
|
openRequestKey,
|
||||||
|
}: {
|
||||||
|
row: WorkOrderTableRow | null;
|
||||||
|
editMode: boolean;
|
||||||
|
initialTab: SlideOverTab;
|
||||||
|
setTab: (tab: SlideOverTab) => void;
|
||||||
|
openRequestKey: number;
|
||||||
|
}) {
|
||||||
|
useEffect(() => {
|
||||||
|
if (!row) return;
|
||||||
|
setTab(editMode ? "info" : initialTab);
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- openRequestKey gates each open
|
||||||
|
}, [openRequestKey]);
|
||||||
|
}
|
||||||
|
|
||||||
export function useSlideOverEditState({
|
export function useSlideOverEditState({
|
||||||
row,
|
row,
|
||||||
editMode,
|
editMode,
|
||||||
|
|
@ -109,14 +132,7 @@ export function useSlideOverEditState({
|
||||||
setUnsavedIntent,
|
setUnsavedIntent,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Re-apply the requested tab on every open, including a second notification for the work order
|
useSlideOverOpenRequestTab({ row, editMode, initialTab, setTab, openRequestKey });
|
||||||
// already on screen (same row id) where the identity effect above does not re-run. Tab-only so
|
|
||||||
// an in-flight edit draft is never discarded.
|
|
||||||
useEffect(() => {
|
|
||||||
if (!row) return;
|
|
||||||
setTab(editMode ? "info" : initialTab);
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- openRequestKey gates each open
|
|
||||||
}, [openRequestKey]);
|
|
||||||
|
|
||||||
const lockStatus = infoSource?.status ?? row?.status;
|
const lockStatus = infoSource?.status ?? row?.status;
|
||||||
const isInfoLocked = isSlideOverInfoLocked(lockStatus);
|
const isInfoLocked = isSlideOverInfoLocked(lockStatus);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue