Skip to content

Commit

Permalink
Clear cache on change business area (#4217)
Browse files Browse the repository at this point in the history
  • Loading branch information
patryk-dabrowski authored Sep 12, 2024
1 parent 71024fe commit 43c91f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def setUpTestData(cls) -> None:
parent=cash_plan,
currency="PLN",
)
super().setUpTestData()

@parameterized.expand(
[
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/containers/BusinessAreaSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useNavigate } from 'react-router-dom';
import styled from 'styled-components';
import { useCachedMe } from '@hooks/useCachedMe';
import { useBaseUrl } from '@hooks/useBaseUrl';
import { useApolloClient } from '@apollo/client';

const CountrySelect = styled(Select)`
&& {
Expand Down Expand Up @@ -46,9 +47,13 @@ export function BusinessAreaSelect(): React.ReactElement {
const { data } = useCachedMe();
const { businessArea } = useBaseUrl();
const navigate = useNavigate();
const onChange = (e): void => {
const client = useApolloClient();

const onChange = async (e): Promise<void> => {
await client.cache.reset();
navigate(`/${e.target.value}/programs/all/list`);
};

if (!data) {
return null;
}
Expand Down

0 comments on commit 43c91f7

Please sign in to comment.