Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix in Upload Again #44

Merged
merged 3 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: Made ReactQuery cache clear on upload reset
  • Loading branch information
chavda-bhavik committed Nov 9, 2022
commit 85ddc867f8039f161efdb8578d4332a2cdc46a75
8 changes: 7 additions & 1 deletion apps/widget/src/components/widget/Widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { PromptModal } from './Phases/PromptModal';
import { Phase4 } from './Phases/Phase4';
import { ParentWindow } from '@util';
import { PhasesEum, PromptModalTypesEnum } from '@types';
import { useQueryClient } from '@tanstack/react-query';

export function Widget() {
const queryClient = useQueryClient();
const [phase, setPhase] = useState<PhasesEum>(PhasesEum.UPLOAD);
const [showConfirmModal, setShowConfirmModal] = useState(false);
const [promptContinueAction, setPromptContinueAction] = useState<PromptModalTypesEnum>();
Expand All @@ -24,7 +26,7 @@ export function Widget() {
const onPromptConfirm = () => {
setPromptContinueAction(undefined);
if (promptContinueAction === PromptModalTypesEnum.CLOSE) closeWidget();
else if (promptContinueAction === PromptModalTypesEnum.UPLOAD_AGAIN) setPhase(PhasesEum.UPLOAD);
else if (promptContinueAction === PromptModalTypesEnum.UPLOAD_AGAIN) resetProgress();
};
const onPromptCancel = () => {
setPromptContinueAction(undefined);
Expand All @@ -36,6 +38,10 @@ export function Widget() {
const closeWidget = () => {
ParentWindow.Close();
};
const resetProgress = () => {
queryClient.clear();
setPhase(PhasesEum.UPLOAD);
};

const PhaseView = {
[PhasesEum.UPLOAD]: <Phase1 onNextClick={() => setPhase(PhasesEum.MAPPING)} />,
Expand Down
2 changes: 1 addition & 1 deletion apps/widget/src/store/app.context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const AppContextProvider = ({ children }: AppContextProviderProps) => {

export function useAppState() {
const context = useContext(AppContext);
if (!context) throw new Error('API Context must be used within APIContextProvider');
if (!context) throw new Error('App Context must be used within AppContextProvider');

return context;
}
Expand Down