From 43c91f782709de73ebab432c97e59755673f4fe3 Mon Sep 17 00:00:00 2001 From: Patryk Dabrowski Date: Thu, 12 Sep 2024 10:45:11 +0200 Subject: [PATCH] Clear cache on change business area (#4217) --- .../tests/test_grievance_create_complaint_ticket.py | 1 + frontend/src/containers/BusinessAreaSelect.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/hct_mis_api/apps/grievance/tests/test_grievance_create_complaint_ticket.py b/backend/hct_mis_api/apps/grievance/tests/test_grievance_create_complaint_ticket.py index 9cf4f100b2..bb09773fb3 100644 --- a/backend/hct_mis_api/apps/grievance/tests/test_grievance_create_complaint_ticket.py +++ b/backend/hct_mis_api/apps/grievance/tests/test_grievance_create_complaint_ticket.py @@ -83,6 +83,7 @@ def setUpTestData(cls) -> None: parent=cash_plan, currency="PLN", ) + super().setUpTestData() @parameterized.expand( [ diff --git a/frontend/src/containers/BusinessAreaSelect.tsx b/frontend/src/containers/BusinessAreaSelect.tsx index 264c8fa8cc..d288db5283 100644 --- a/frontend/src/containers/BusinessAreaSelect.tsx +++ b/frontend/src/containers/BusinessAreaSelect.tsx @@ -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)` && { @@ -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 => { + await client.cache.reset(); navigate(`/${e.target.value}/programs/all/list`); }; + if (!data) { return null; }