From 26dba66470962313a8003210cbc718bbf6ed6451 Mon Sep 17 00:00:00 2001 From: Hassan Azmi Date: Tue, 18 Aug 2020 16:45:17 -0400 Subject: [PATCH] Refetch profiles when going back to router --- app/containers/AddProfile/index.js | 2 +- app/containers/Profiles/index.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/containers/AddProfile/index.js b/app/containers/AddProfile/index.js index 9f52c75..6c36746 100644 --- a/app/containers/AddProfile/index.js +++ b/app/containers/AddProfile/index.js @@ -39,7 +39,7 @@ const AddProfile = () => { const [createProfile] = useMutation(CREATE_PROFILE); const handleAddProfile = (profileType, name, details, childProfileIds = []) => { - createProfile({ + return createProfile({ variables: { profileType, customerId, diff --git a/app/containers/Profiles/index.js b/app/containers/Profiles/index.js index a8dc03b..c15b7c1 100644 --- a/app/containers/Profiles/index.js +++ b/app/containers/Profiles/index.js @@ -1,6 +1,7 @@ -import React, { useContext } from 'react'; +import React, { useContext, useEffect } from 'react'; import gql from 'graphql-tag'; import { useQuery, useMutation } from '@apollo/react-hooks'; +import { useLocation } from 'react-router-dom'; import { Alert, notification } from 'antd'; @@ -39,6 +40,11 @@ const Profiles = () => { variables: { customerId, limit: 100 }, }); const [deleteProfile] = useMutation(DELETE_PROFILE); + const location = useLocation(); + + useEffect(() => { + refetch(); + }, [location.pathname === '/profiles']); const reloadTable = () => { refetch()