Skip to content
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

Merged
merged 16 commits into from
Apr 10, 2024
Merged

Conversation

Shruti-Apte
Copy link
Contributor

@Shruti-Apte Shruti-Apte commented Mar 22, 2024

Closes #1741

What

  • Page refresh after add/edit/delete
  • Compensation tab hidden from profile and team details
  • Employment and devices tab added on team details

@@ -53,6 +55,12 @@ const TeamList = () => {
getTeamList();
}, []);

useEffect(() => {
if (refreshList) {
getTeamList();
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@apoorv1316 apoorv1316 reopened this Apr 8, 2024
@Shruti-Apte Shruti-Apte assigned apoorv1316 and unassigned Shruti-Apte Apr 9, 2024
@apoorv1316
Copy link
Contributor

@prasanthchaduvula Please review again

} else {
await teamApi.updateInvitedMember(user.id, payload);
const res = await teamApi.updateInvitedMember(user.id, payload);
const updatedUser = res.data.invitation;
Copy link
Contributor

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.useror 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(
Copy link
Contributor

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);

@apoorv1316 apoorv1316 merged commit 6b91123 into develop Apr 10, 2024
1 check passed
@apoorv1316 apoorv1316 deleted the refresh_team_list branch April 10, 2024 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refresh page after adding/editing team member
3 participants