Skip to content

Commit

Permalink
Trigger unlock on main and also handle 422
Browse files Browse the repository at this point in the history
  • Loading branch information
rorre committed Oct 8, 2023
1 parent ff9e6cf commit 7e30d12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/module/dashboard/main/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ function ServiceRow({ chall }: ServiceRowProps) {

export default function MainPage() {
const { isLoading, error, data } = useUserChallenges();
useQuery({
queryKey: ["unlocked"],
queryFn: () => getUser<number[]>("my/solves"),
});
const [flag, setFlag] = useState("");
const submitFlag = useMutation({
mutationFn: (flag: string) =>
Expand Down
5 changes: 4 additions & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export default function App({ Component, pageProps }: AppPropsWithLayout) {
queryCache: new QueryCache({
onError(error, query) {
if (error instanceof HTTPError) {
if (error.response.status === 403) {
if (
error.response.status === 403 ||
error.response.status === 422
) {
const jotaiStore = getDefaultStore();
jotaiStore.set(authTokenAtom, "");
}
Expand Down

0 comments on commit 7e30d12

Please sign in to comment.