From 6691926b56229c78f5af591da93e9f286cc5932d Mon Sep 17 00:00:00 2001 From: matthewsavelev Date: Wed, 1 Dec 2021 20:43:51 +0500 Subject: [PATCH] DOMA-376 Clean state on logout (cherry picked from commit 3369e553a8e53443ea9427ff7755f855ea432e69) --- packages/@core.next/organization.jsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/@core.next/organization.jsx b/packages/@core.next/organization.jsx index ded0d1a3906..ef320d76b3a 100644 --- a/packages/@core.next/organization.jsx +++ b/packages/@core.next/organization.jsx @@ -67,6 +67,12 @@ const OrganizationProvider = ({ children, initialLinkValue }) => { const [linkIdState, setLinkIdState] = useState(initialLinkValue && initialLinkValue.id || cookieOrganizationEmployee) const [link, setLink] = useState(initialLinkValue) + useEffect(() => { + if (!(initialLinkValue && initialLinkValue.id || cookieOrganizationEmployee)) { + setLinkIdState(null) + } + }, [initialLinkValue, cookieOrganizationEmployee]) + const { loading: linkLoading, refetch } = useQuery(GET_ORGANIZATION_TO_USER_LINK_BY_ID_QUERY, { variables: { id: linkIdState }, skip: auth.isLoading || !auth.user || !linkIdState,