Refetch profiles when going back to router

This commit is contained in:
Hassan Azmi
2020-08-18 16:45:17 -04:00
parent fd4f90173b
commit 26dba66470
2 changed files with 8 additions and 2 deletions

View File

@@ -39,7 +39,7 @@ const AddProfile = () => {
const [createProfile] = useMutation(CREATE_PROFILE);
const handleAddProfile = (profileType, name, details, childProfileIds = []) => {
createProfile({
return createProfile({
variables: {
profileType,
customerId,

View File

@@ -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()