11import Onyx from 'react-native-onyx' ;
22import type { OnyxUpdate } from 'react-native-onyx' ;
3+ import type { ValueOf } from 'type-fest' ;
34import * as API from '@libs/API' ;
4- import type { AddAdminToDomainParams , RemoveDomainAdminParams , SetTechnicalContactEmailParams , SetVacationDelegateParams , ToggleConsolidatedDomainBillingParams } from '@libs/API/parameters' ;
5+ import type { AddAdminToDomainParams , RemoveDomainAdminParams , SetTechnicalContactEmailParams , ToggleConsolidatedDomainBillingParams } from '@libs/API/parameters' ;
56import { READ_COMMANDS , SIDE_EFFECT_REQUEST_COMMANDS , WRITE_COMMANDS } from '@libs/API/types' ;
6- import { getMicroSecondOnyxErrorWithTranslationKey , getMicroSecondTranslationErrorWithTranslationKey } from '@libs/ErrorUtils' ;
7- import * as ErrorUtils from '@libs/ErrorUtils' ;
7+ import { getMicroSecondOnyxErrorWithTranslationKey } from '@libs/ErrorUtils' ;
88import { getAuthToken } from '@libs/Network/NetworkStore' ;
99import CONST from '@src/CONST' ;
1010import ONYXKEYS from '@src/ONYXKEYS' ;
11- import type * as OnyxCommon from '@src/types/onyx/OnyxCommon' ;
12- import { BaseVacationDelegate } from '@src/types/onyx/VacationDelegate' ;
11+ import type { BaseVacationDelegate } from '@src/types/onyx/VacationDelegate' ;
1312import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
1413import type PrefixedRecord from '@src/types/utils/PrefixedRecord' ;
1514import type { ScimTokenWithState } from './ScimToken/ScimTokenUtils' ;
@@ -796,10 +795,14 @@ function setDomainVacationDelegate(
796795 } ,
797796 ] ;
798797
799- // Will be replaced with new api call
798+ // Will be replaced with a new api call
800799 Onyx . update ( optimisticData ) ;
801- return new Promise ( ( resolve ) => {
802- resolve ( ) ;
800+ return new Promise < { jsonCode ?: ValueOf < typeof CONST . JSON_CODE > } > ( ( resolve ) => {
801+ if ( ! shouldOverridePolicyDiffWarning ) {
802+ resolve ( { jsonCode : CONST . JSON_CODE . POLICY_DIFF_WARNING } ) ;
803+ return ;
804+ }
805+ resolve ( { jsonCode : CONST . JSON_CODE . SUCCESS } ) ;
803806 } ) ;
804807}
805808
@@ -815,10 +818,10 @@ function deleteDomainVacationDelegate(vacationDelegate: BaseVacationDelegate, do
815818 onyxMethod : Onyx . METHOD . MERGE ,
816819 key : `${ ONYXKEYS . COLLECTION . DOMAIN } ${ domainAccountID } ` ,
817820 value : {
818- [ ` ${ CONST . DOMAIN . PRIVATE_VACATION_DELEGATE_PREFIX } ${ domainMemberAccountID } ` ] : {
821+ [ vacationDelegateKey ] : {
819822 delegate : null ,
820823 creator : null ,
821- previousDelegate : previousDelegate ,
824+ previousDelegate : previousDelegate ?? null ,
822825 } ,
823826 } as PrefixedRecord < typeof CONST . DOMAIN . PRIVATE_VACATION_DELEGATE_PREFIX , BaseVacationDelegate > ,
824827 } ,
@@ -934,7 +937,7 @@ function clearVacationDelegateError(domainMemberAccountID: number, domainAccount
934937 creator : null ,
935938 previousDelegate : null ,
936939 } ,
937- } as PrefixedRecord < typeof CONST . DOMAIN . PRIVATE_VACATION_DELEGATE_PREFIX , BaseVacationDelegate > ,
940+ } as unknown as PrefixedRecord < typeof CONST . DOMAIN . PRIVATE_VACATION_DELEGATE_PREFIX , BaseVacationDelegate > ,
938941 } ,
939942 ] ;
940943
0 commit comments