Skip to content

Commit 96a097d

Browse files
authored
Merge pull request Expensify#89965 from emkhalid/fix/domain-reset-not-here-89258
Fix Not here page after resetting domain
2 parents dac260f + 529c184 commit 96a097d

3 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/libs/actions/Domain.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import enhanceParameters from '@libs/Network/enhanceParameters';
2929
import {generateAccountID} from '@libs/UserUtils';
3030
import CONST from '@src/CONST';
3131
import ONYXKEYS from '@src/ONYXKEYS';
32-
import type {Domain, DomainSecurityGroup, UserSecurityGroupData} from '@src/types/onyx';
32+
import type {DomainSecurityGroup, UserSecurityGroupData} from '@src/types/onyx';
3333
import type {SecurityGroupKey} from '@src/types/onyx/Domain';
3434
import type {DomainSecurityGroupErrors} from '@src/types/onyx/DomainErrors';
3535
import type {PendingAction} from '@src/types/onyx/OnyxCommon';
@@ -767,7 +767,7 @@ function revokeDomainAdminAccess(domainAccountID: number, accountID: number) {
767767
/**
768768
* Removes the domain
769769
*/
770-
function resetDomain(domainAccountID: number, domainName: string, domain: Domain) {
770+
function resetDomain(domainAccountID: number, domainName: string) {
771771
const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS | typeof ONYXKEYS.COLLECTION.DOMAIN>> = [
772772
{
773773
onyxMethod: Onyx.METHOD.MERGE,
@@ -779,10 +779,15 @@ function resetDomain(domainAccountID: number, domainName: string, domain: Domain
779779
{
780780
onyxMethod: Onyx.METHOD.MERGE,
781781
key: `${ONYXKEYS.COLLECTION.DOMAIN}${domainAccountID}`,
782-
value: null,
782+
value: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE},
783783
},
784784
];
785-
const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS | typeof ONYXKEYS.COLLECTION.DOMAIN_ERRORS>> = [
785+
const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.DOMAIN | typeof ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS | typeof ONYXKEYS.COLLECTION.DOMAIN_ERRORS>> = [
786+
{
787+
onyxMethod: Onyx.METHOD.SET,
788+
key: `${ONYXKEYS.COLLECTION.DOMAIN}${domainAccountID}`,
789+
value: null,
790+
},
786791
{
787792
onyxMethod: Onyx.METHOD.MERGE,
788793
key: `${ONYXKEYS.COLLECTION.DOMAIN_PENDING_ACTIONS}${domainAccountID}`,
@@ -802,7 +807,7 @@ function resetDomain(domainAccountID: number, domainName: string, domain: Domain
802807
{
803808
onyxMethod: Onyx.METHOD.MERGE,
804809
key: `${ONYXKEYS.COLLECTION.DOMAIN}${domainAccountID}`,
805-
value: domain,
810+
value: {pendingAction: null},
806811
},
807812
{
808813
onyxMethod: Onyx.METHOD.MERGE,

src/pages/domain/DomainResetPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function DomainResetDomainPage({route}: DomainResetDomainPageProps) {
5757
Log.hmmm('Domain data is missing or there are more than 1 admin left');
5858
return;
5959
}
60-
resetDomain(route.params.domainAccountID, domainName, domain);
60+
resetDomain(route.params.domainAccountID, domainName);
6161
Navigation.goBack(ROUTES.WORKSPACES_LIST.route);
6262
};
6363

tests/actions/DomainTest.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import CONST from '@src/CONST';
3232
import IntlStore from '@src/languages/IntlStore';
3333
import OnyxUpdateManager from '@src/libs/actions/OnyxUpdateManager';
3434
import ONYXKEYS from '@src/ONYXKEYS';
35-
import type {Domain, DomainSecurityGroup, UserSecurityGroupData} from '@src/types/onyx';
35+
import type {DomainSecurityGroup, UserSecurityGroupData} from '@src/types/onyx';
3636
import type {SecurityGroupKey} from '@src/types/onyx/Domain';
3737
import type {BaseVacationDelegate} from '@src/types/onyx/VacationDelegate';
3838
import type PrefixedRecord from '@src/types/utils/PrefixedRecord';
@@ -93,20 +93,20 @@ describe('actions/Domain', () => {
9393
const apiWriteSpy = jest.spyOn(require('@libs/API'), 'write').mockImplementation(() => Promise.resolve());
9494
const domainAccountID = 123;
9595
const domainName = 'test.com';
96-
const domain = {
97-
accountID: domainAccountID,
98-
} as Domain;
9996

100-
resetDomain(domainAccountID, domainName, domain);
97+
resetDomain(domainAccountID, domainName);
10198

10299
expect(apiWriteSpy).toHaveBeenCalledWith(
103100
WRITE_COMMANDS.DELETE_DOMAIN,
104101
{domainAccountID, domainName},
105102
{
106-
optimisticData: [expect.objectContaining({value: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}}), expect.objectContaining({value: null})],
107-
successData: [expect.objectContaining({value: {pendingAction: null}}), expect.objectContaining({value: {errors: null}})],
103+
optimisticData: [
104+
expect.objectContaining({value: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}}),
105+
expect.objectContaining({value: {pendingAction: CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE}}),
106+
],
107+
successData: [expect.objectContaining({value: null}), expect.objectContaining({value: {pendingAction: null}}), expect.objectContaining({value: {errors: null}})],
108108
failureData: [
109-
expect.objectContaining({value: domain}),
109+
expect.objectContaining({value: {pendingAction: null}}),
110110
expect.objectContaining({value: {pendingAction: null}}),
111111
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
112112
expect.objectContaining({value: {errors: expect.any(Object)}}),

0 commit comments

Comments
 (0)