-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44038 from mananjadhav/mj-netsuite-subsidiary-select
[#Wave-Control: Add NetSuite]: Top-level Subsidiary selection
- Loading branch information
Showing
19 changed files
with
357 additions
and
3 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type UpdateNetSuiteSubsidiaryParams = { | ||
policyID: string; | ||
subsidiary: string; | ||
subsidiaryID: string; | ||
}; | ||
|
||
export default UpdateNetSuiteSubsidiaryParams; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import * as API from '@libs/API'; | ||
import {WRITE_COMMANDS} from '@libs/API/types'; | ||
import * as ErrorUtils from '@libs/ErrorUtils'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {OnyxData} from '@src/types/onyx/Request'; | ||
|
||
type SubsidiaryParam = { | ||
subsidiaryID: string; | ||
subsidiary: string; | ||
}; | ||
|
||
function updateNetSuiteSubsidiary(policyID: string, newSubsidiary: SubsidiaryParam, oldSubsidiary: SubsidiaryParam) { | ||
const onyxData: OnyxData = { | ||
optimisticData: [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, | ||
value: { | ||
connections: { | ||
netsuite: { | ||
options: { | ||
config: { | ||
subsidiary: newSubsidiary.subsidiary, | ||
subsidiaryID: newSubsidiary.subsidiaryID, | ||
pendingFields: { | ||
subsidiary: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, | ||
}, | ||
errorFields: { | ||
subsidiary: null, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
successData: [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, | ||
value: { | ||
connections: { | ||
netsuite: { | ||
options: { | ||
config: { | ||
subsidiary: newSubsidiary.subsidiary, | ||
subsidiaryID: newSubsidiary.subsidiaryID, | ||
errorFields: { | ||
subsidiary: null, | ||
}, | ||
pendingFields: { | ||
subsidiary: null, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
failureData: [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, | ||
value: { | ||
connections: { | ||
netsuite: { | ||
options: { | ||
config: { | ||
subsidiary: oldSubsidiary.subsidiary, | ||
subsidiaryID: oldSubsidiary.subsidiaryID, | ||
errorFields: { | ||
subsidiary: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), | ||
}, | ||
pendingFields: { | ||
subsidiary: null, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
const params = { | ||
policyID, | ||
...newSubsidiary, | ||
}; | ||
API.write(WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY, params, onyxData); | ||
} | ||
|
||
// We'll have more API calls in upcoming PRs | ||
// eslint-disable-next-line import/prefer-default-export | ||
export {updateNetSuiteSubsidiary}; |
Oops, something went wrong.