Browse Source

fix(assessment): remove shimmer on finish, use button 3-dots loader and update form-overview cache on submit

master
mortezaei 1 day ago
parent
commit
10aa7b67ea
  1. 11
      src/components/Componentes/test-questions-flow.tsx
  2. 5
      src/hooks/marriage/use-cattell.ts
  3. 10
      src/hooks/marriage/use-glasser.ts

11
src/components/Componentes/test-questions-flow.tsx

@ -12,7 +12,6 @@ import NavigationButton from "./navigation-button";
import { PageBackground } from "./page-background"; import { PageBackground } from "./page-background";
import StickyHeader from "./sticky-header"; import StickyHeader from "./sticky-header";
import TestExitSheet from "./test-exit-sheet"; import TestExitSheet from "./test-exit-sheet";
import TestLoadingScreen from "./test-loading-screen";
export type QuestionOption = { export type QuestionOption = {
id: string; id: string;
@ -225,15 +224,6 @@ export default function TestQuestionsFlow({
} }
}; };
if (isSubmitting) {
return (
<TestLoadingScreen
title="Analyzing and submitting responses"
subtitle="Please wait a moment while your answers are reviewed and registered."
/>
);
}
if (!currentQuestion) { if (!currentQuestion) {
return null; return null;
} }
@ -426,6 +416,7 @@ export default function TestQuestionsFlow({
!areAllQuestionsAnswered || !areAllQuestionsAnswered ||
isSubmitting isSubmitting
} }
isLoading={isSubmitting}
onClick={handleFinishSubmit} onClick={handleFinishSubmit}
> >
{finishLabel} {finishLabel}

5
src/hooks/marriage/use-cattell.ts

@ -86,9 +86,12 @@ export function useSubmitCattellAssessmentMutation(
queryKey: marriageQueryKeys.cattellResult(), queryKey: marriageQueryKeys.cattellResult(),
}); });
queryClient.setQueriesData<FormSchemaResponse>( queryClient.setQueriesData<FormSchemaResponse>(
{ queryKey: ["marriage", "form-schema", "profile"] },
{ queryKey: [...marriageQueryKeys.all, "form-overview"] },
(schema) => markAssessmentCompleted(schema, "personality_test"), (schema) => markAssessmentCompleted(schema, "personality_test"),
); );
await queryClient.invalidateQueries({
queryKey: [...marriageQueryKeys.all, "form-overview"],
});
await options?.onSuccess?.(data, variables, onMutateResult, context); await options?.onSuccess?.(data, variables, onMutateResult, context);
}, },
}); });

10
src/hooks/marriage/use-glasser.ts

@ -61,7 +61,7 @@ export function useSubmitGlasserAssessmentMutation(
queryKey: marriageQueryKeys.glasserResult(), queryKey: marriageQueryKeys.glasserResult(),
}); });
queryClient.setQueriesData<FormSchemaResponse>( queryClient.setQueriesData<FormSchemaResponse>(
{ queryKey: ["marriage", "form-schema", "profile"] },
{ queryKey: [...marriageQueryKeys.all, "form-overview"] },
(schema) => { (schema) => {
if (!schema) return schema; if (!schema) return schema;
const slug = "glasser_5_needs_test"; const slug = "glasser_5_needs_test";
@ -84,11 +84,19 @@ export function useSubmitGlasserAssessmentMutation(
total_steps: 1, total_steps: 1,
completion_percent: 100, completion_percent: 100,
}, },
glasser: {
current_step: 1,
total_steps: 1,
completion_percent: 100,
},
}, },
}, },
}; };
}, },
); );
await queryClient.invalidateQueries({
queryKey: [...marriageQueryKeys.all, "form-overview"],
});
await options?.onSuccess?.(data, variables, onMutateResult, context); await options?.onSuccess?.(data, variables, onMutateResult, context);
}, },
}); });

Loading…
Cancel
Save