diff --git a/src/components/UserUpdate/UserUpdate.test.tsx b/src/components/UserUpdate/UserUpdate.test.tsx index aca8a579a2..e10f4a5b4e 100644 --- a/src/components/UserUpdate/UserUpdate.test.tsx +++ b/src/components/UserUpdate/UserUpdate.test.tsx @@ -81,6 +81,7 @@ describe('Testing User Update', () => { const props = { key: '123', id: '1', + toggleStateValue: jest.fn(), }; const formData = { diff --git a/src/components/UserUpdate/UserUpdate.tsx b/src/components/UserUpdate/UserUpdate.tsx index e445db77aa..a58740b965 100644 --- a/src/components/UserUpdate/UserUpdate.tsx +++ b/src/components/UserUpdate/UserUpdate.tsx @@ -16,11 +16,13 @@ import Loader from 'components/Loader/Loader'; interface InterfaceUserUpdateProps { id: string; + toggleStateValue: () => void; } // eslint-disable-next-line @typescript-eslint/no-unused-vars const UserUpdate: React.FC = ({ id, + toggleStateValue, }): JSX.Element => { const location = useLocation(); const currentUrl = location.state?.id || localStorage.getItem('id') || id; @@ -104,10 +106,13 @@ const UserUpdate: React.FC = ({ applangcode: '', file: '', }); + localStorage.setItem('FirstName', firstName); + localStorage.setItem('LastName', lastName); + localStorage.setItem('Email', email); + localStorage.setItem('UserImage', file); toast.success('Successful updated'); - setTimeout(() => { - window.location.reload(); - }, 500); + + toggleStateValue(); } } catch (error: any) { /* istanbul ignore next */ @@ -117,7 +122,7 @@ const UserUpdate: React.FC = ({ /* istanbul ignore next */ const cancelUpdate = (): void => { - window.location.reload(); + toggleStateValue(); }; return ( diff --git a/src/screens/MemberDetail/MemberDetail.tsx b/src/screens/MemberDetail/MemberDetail.tsx index 22510a62e5..d190b47246 100644 --- a/src/screens/MemberDetail/MemberDetail.tsx +++ b/src/screens/MemberDetail/MemberDetail.tsx @@ -36,10 +36,18 @@ const MemberDetail: React.FC = ({ id }): JSX.Element => { data: userData, loading: loading, error: error, + refetch: refetch, } = useQuery(USER_DETAILS, { variables: { id: currentUrl }, // For testing we are sending the id as a prop }); + /* istanbul ignore next */ + const toggleStateValue = (): void => { + if (state === 1) setState(2); + else setState(1); + refetch(); + }; + if (loading) { return ; } @@ -286,7 +294,7 @@ const MemberDetail: React.FC = ({ id }): JSX.Element => { ) : ( - + )}