Skip to content

Commit

Permalink
fix: invalidate listProfiles on register
Browse files Browse the repository at this point in the history
  • Loading branch information
naumovski-filip committed Sep 11, 2023
1 parent 2b6cc37 commit f3b9473
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/containers/AccountModal/forms/Registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react';
import { object, string, SchemaOf } from 'yup';
import { useTranslation } from 'react-i18next';
import { useLocation, useNavigate } from 'react-router';
import { useQuery } from 'react-query';
import { useQuery, useQueryClient } from 'react-query';

import useForm, { UseFormOnSubmitHandler } from '#src/hooks/useForm';
import RegistrationForm from '#components/RegistrationForm/RegistrationForm';
Expand All @@ -21,6 +21,8 @@ const Registration = () => {
const { data, isLoading: publisherConsentsLoading } = useQuery(['consents'], getPublisherConsents);
const publisherConsents = useMemo(() => data?.consents || [], [data]);

const queryClient = useQueryClient();

const handleChangeConsent = (event: React.ChangeEvent<HTMLInputElement>) => {
setConsentValues((current) => ({ ...current, [event.target.name]: event.target.checked }));

Expand Down Expand Up @@ -50,6 +52,8 @@ const Registration = () => {
// error caught while updating the consents, but continue the registration flow
});

await queryClient.invalidateQueries('listProfiles');

navigate(addQueryParam(location, 'u', 'personal-details'));
} catch (error: unknown) {
if (error instanceof Error) {
Expand Down

0 comments on commit f3b9473

Please sign in to comment.