Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

adding queryClient.invalidateQueries for challenge-solutions (#1642)

Amanuel Odicho1c92fff18bd1
diff --git a/apps/aot/src/app/events/[year]/[day]/right-wrapper.tsx b/apps/aot/src/app/events/[year]/[day]/right-wrapper.tsx
index acb4c550..8a7340f6 100644
--- a/apps/aot/src/app/events/[year]/[day]/right-wrapper.tsx
+++ b/apps/aot/src/app/events/[year]/[day]/right-wrapper.tsx
@@ -6,12 +6,14 @@ import type { Challenge } from './_components/types';
import { SubmissionOverview } from './submissions/[[...catchAll]]/_components/overview';
import { saveSubmission } from './submissions/[[...catchAll]]/save-submission.action';
import { SettingsElements } from './SettingsElements';
+import { useQueryClient } from '@tanstack/react-query';
interface Props {
challenge: Challenge;
}
export function RightWrapper({ challenge }: Props) {
+ const queryClient = useQueryClient();
const router = useRouter();
const { year, day } = useParams();
const segments = useSelectedLayoutSegments();
@@ -44,6 +46,12 @@ export function RightWrapper({ challenge }: Props) {
isSuccessful,
});
+ if (submission.isSuccessful) {
+ queryClient.invalidateQueries({
+ queryKey: ['challenge-solutions', challenge.slug],
+ });
+ }
+
return handleSuccessfulSubmission(submission.isSuccessful, submission.id, '');
}}
submissionDisabled={!session?.user}
diff --git a/apps/web/src/app/challenge/[slug]/right-wrapper.tsx b/apps/web/src/app/challenge/[slug]/right-wrapper.tsx
index f876e844..86d21c09 100644
--- a/apps/web/src/app/challenge/[slug]/right-wrapper.tsx
+++ b/apps/web/src/app/challenge/[slug]/right-wrapper.tsx
@@ -11,6 +11,7 @@ import type { ChallengeRouteData } from './getChallengeRouteData';
import { SubmissionOverview } from './submissions/[[...catchAll]]/_components/overview';
import { saveSubmission } from './submissions/[[...catchAll]]/save-submission.action';
import SwapPanelButton from '../_components/swap-panel-button';
+import { useQueryClient } from '@tanstack/react-query';
interface Props {
challenge: ChallengeRouteData['challenge'];
@@ -19,6 +20,7 @@ interface Props {
}
export function RightWrapper({ track, challenge, toggleDirection }: Props) {
+ const queryClient = useQueryClient();
const router = useRouter();
const segments = useSelectedLayoutSegments();
const { data: session } = useSession();
@@ -54,6 +56,12 @@ export function RightWrapper({ track, challenge, toggleDirection }: Props) {
isSuccessful,
});
+ if (submission.isSuccessful) {
+ queryClient.invalidateQueries({
+ queryKey: ['challenge-solutions', challenge.slug],
+ });
+ }
+
return handleSuccessfulSubmission(submission.isSuccessful, submission.id, track?.slug);
}}
submissionDisabled={!session?.user}