-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refresh page after adding/editing team member #1750
Conversation
@@ -53,6 +55,12 @@ const TeamList = () => { | |||
getTeamList(); | |||
}, []); | |||
|
|||
useEffect(() => { | |||
if (refreshList) { | |||
getTeamList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of fetching again, either use the updated response from the create, update or delete requests with the previous state or update the API response with the updated list.
@@ -72,13 +72,17 @@ const EditClient = ({ user = {}, isEdit = false }: Props) => { | |||
if (isEdit) { | |||
if (user.isTeamMember) { | |||
await teamApi.updateTeamMember(user.id, payload); | |||
setRefreshList(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
} else { | ||
await teamApi.deleteInvitedMember(user.id); | ||
setRefreshList(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
merge with develop
@prasanthchaduvula Please review again |
} else { | ||
await teamApi.updateInvitedMember(user.id, payload); | ||
const res = await teamApi.updateInvitedMember(user.id, payload); | ||
const updatedUser = res.data.invitation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create updatedTeamList
function. Extract the below logic and call it inside the above if and this else conditions and pass theres.data.user
or res.data.invitation
as param.
teamList.map(member => {
if (member.id === updatedUser.id) {
return updatedUser;
}
return member;
});
setTeamList(updatedTeamList);
} else { | ||
await teamApi.deleteInvitedMember(user.id); | ||
const res = await teamApi.deleteInvitedMember(user.id); | ||
const updatedTeamList = teamList.filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create one function named updatedTeamListAferDelete
with below code and pass res.data.user.id
or res.data.id
and call it inside the if and else conditions
teamList.filter(
member => member.id !== id
);
setTeamList(updatedTeamList);
Closes #1741
What