bug: bug double org is fixed

This commit is contained in:
Palash gupta 2022-05-13 11:15:10 +05:30
parent 53528f1045
commit 12c14f71ba
No known key found for this signature in database
GPG Key ID: 8FD05AE6F9150AD6
3 changed files with 9 additions and 6 deletions

View File

@ -38,7 +38,7 @@ function DisplayName({
dispatch({
type: UPDATE_ORG_NAME,
payload: {
index,
orgId,
name: orgName,
},
});

View File

@ -172,16 +172,19 @@ const appReducer = (
case UPDATE_ORG_NAME: {
const stateOrg = state.org || ({} as OrgPayload);
const { index, name: updatedName } = action.payload;
const current = stateOrg[index];
const { orgId, name: updatedName } = action.payload;
const orgIndex = stateOrg.findIndex((e) => e.id === orgId);
const current = stateOrg[orgIndex];
const updatedOrg: OrgPayload = [
...stateOrg.slice(0, index),
...stateOrg.slice(0, orgIndex),
{
...current,
name: updatedName,
},
...stateOrg.slice(index + 1, stateOrg.length),
...stateOrg.slice(orgIndex + 1, stateOrg.length),
];
return {

View File

@ -98,7 +98,7 @@ export interface UpdateOrgName {
type: typeof UPDATE_ORG_NAME;
payload: {
name: string;
index: number;
orgId: string;
};
}