-
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 #28313 from MrMuzyk/feat-22878-activate-physical-card
activate physical card
- Loading branch information
Showing
14 changed files
with
343 additions
and
9 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,63 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import * as API from '../API'; | ||
|
||
/** | ||
* Activates the physical Expensify card based on the last four digits of the card number | ||
* | ||
* @param {Number} lastFourDigits | ||
* @param {Number} cardID | ||
*/ | ||
function activatePhysicalExpensifyCard(lastFourDigits, cardID) { | ||
API.write( | ||
'ActivatePhysicalExpensifyCard', | ||
{lastFourDigits, cardID}, | ||
{ | ||
optimisticData: [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: ONYXKEYS.CARD_LIST, | ||
value: { | ||
[cardID]: { | ||
errors: null, | ||
isLoading: true, | ||
}, | ||
}, | ||
}, | ||
], | ||
successData: [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: ONYXKEYS.CARD_LIST, | ||
value: { | ||
[cardID]: { | ||
isLoading: false, | ||
}, | ||
}, | ||
}, | ||
], | ||
failureData: [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: ONYXKEYS.CARD_LIST, | ||
value: { | ||
[cardID]: { | ||
isLoading: false, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
); | ||
} | ||
|
||
/** | ||
* Clears errors for a specific cardID | ||
* | ||
* @param {Number} cardID | ||
*/ | ||
function clearCardListErrors(cardID) { | ||
Onyx.merge(ONYXKEYS.CARD_LIST, {[cardID]: {errors: null, isLoading: false}}); | ||
} | ||
|
||
export {activatePhysicalExpensifyCard, clearCardListErrors}; |
Oops, something went wrong.