Skip to content

Commit

Permalink
fix widget undefined calls (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
chavda-bhavik authored Aug 21, 2024
2 parents 8e1e313 + ae15bc0 commit 2413edc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export function useAutoImportPhase2({ goNext }: IUseAutoImportPhase2Props) {
})),
});
},
enabled: !!jobsInfo?._id,
});

const { mutate: createJobMapping } = useMutation<IUserJobMapping[], IErrorObject, IUserJobMapping[]>(
Expand Down
12 changes: 6 additions & 6 deletions apps/widget/src/components/widget/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ export function Widget() {
setPromptContinueAction(undefined);
};
const onClose = () => {
if ([PhasesEnum.VALIDATE, PhasesEnum.IMAGE_UPLOAD, PhasesEnum.UPLOAD, PhasesEnum.COMPLETE].includes(phase))
closeWidget(true);
else setPromptContinueAction(PromptModalTypesEnum.CLOSE);
if ([PhasesEnum.VALIDATE, PhasesEnum.IMAGE_UPLOAD, PhasesEnum.UPLOAD, PhasesEnum.COMPLETE].includes(phase)) {
setPhase(PhasesEnum.VALIDATE);
resetAppState();
closeWidget();
} else setPromptContinueAction(PromptModalTypesEnum.CLOSE);
};
const closeWidget = (resetPhase?: boolean) => {
const closeWidget = () => {
setShowWidget(false);
resetAmplitude();
resetAppState();
if (resetPhase) setPhase(PhasesEnum.VALIDATE);
setTimeout(() => {
ParentWindow.Close();
}, variables.closeDelayInMS);
Expand Down
1 change: 1 addition & 0 deletions apps/widget/src/hooks/Phase2/usePhase2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function usePhase2({ goNext }: IUsePhase2Props) {
onError(error: IErrorObject) {
notifier.showError({ message: error.message, title: error.error });
},
enabled: !!uploadInfo?._id,
}
);
const { isLoading: isMappingFinalizing, mutate: finalizeMapping } = useMutation<
Expand Down
2 changes: 2 additions & 0 deletions apps/widget/src/hooks/Phase3/usePhase3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export function usePhase3({ onNext }: IUsePhase3Props) {
setColumnDefs(newColumnDefs);
setFrozenColumns(updatedFrozenColumns);
},
enabled: !!uploadInfo?._id,
}
);
const { refetch: fetchUploadInfo } = useQuery<IUpload, IErrorObject, IUpload, [string]>(
Expand Down Expand Up @@ -192,6 +193,7 @@ export function usePhase3({ onNext }: IUsePhase3Props) {
>([`review`, uploadInfo._id], () => api.doReivewData(uploadInfo._id), {
cacheTime: 0,
staleTime: 0,
enabled: !!uploadInfo._id,
onSuccess() {
fetchUploadInfo();
refetchReviewData([page, type]);
Expand Down
83 changes: 0 additions & 83 deletions apps/widget/src/hooks/useEventSource.ts

This file was deleted.

0 comments on commit 2413edc

Please sign in to comment.