added copy job list refresh and reset functionality

This commit is contained in:
Bikram Choudhury
2025-10-23 18:37:23 +05:30
parent 7b437b62ce
commit 6483bd146d
8 changed files with 80 additions and 27 deletions

View File

@@ -34,7 +34,7 @@ function navigationReducer(state: NavigationState, action: Action): NavigationSt
}
export function useCopyJobNavigation() {
const { copyJobState } = useCopyJobContext();
const { copyJobState, resetCopyJobState } = useCopyJobContext();
const screens = useCreateCopyJobScreensList();
const { validationCache: cache } = useCopyJobPrerequisitesCache();
const [state, dispatch] = useReducer(navigationReducer, { screenHistory: [SCREEN_KEYS.SelectAccount] });
@@ -58,6 +58,12 @@ export function useCopyJobNavigation() {
const isPreviousDisabled = state.screenHistory.length <= 1;
const handleCancel = useCallback(() => {
dispatch({ type: "RESET" });
resetCopyJobState();
useSidePanel.getState().closeSidePanel();
}, []);
const handlePrimary = useCallback(() => {
const transitions = {
[SCREEN_KEYS.SelectAccount]: SCREEN_KEYS.AssignPermissions,
@@ -69,7 +75,7 @@ export function useCopyJobNavigation() {
if (nextScreen) {
dispatch({ type: "NEXT", nextScreen });
} else if (currentScreenKey === SCREEN_KEYS.PreviewCopyJob) {
submitCreateCopyJob(copyJobState);
submitCreateCopyJob(copyJobState, handleCancel);
}
}, [currentScreenKey, copyJobState]);
@@ -77,11 +83,6 @@ export function useCopyJobNavigation() {
dispatch({ type: "PREVIOUS" });
}, []);
const handleCancel = useCallback(() => {
dispatch({ type: "RESET" });
useSidePanel.getState().closeSidePanel();
}, []);
return {
currentScreen,
isPrimaryDisabled,