-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 #44930 from Expensify/arosiclair-export-integratio…
…n-action
- Loading branch information
Showing
11 changed files
with
237 additions
and
9 deletions.
There are no files selected for viewing
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,48 @@ | ||
/* eslint-disable react/no-array-index-key */ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import Text from '@components/Text'; | ||
import TextLink from '@components/TextLink'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as ReportActionUtils from '@libs/ReportActionsUtils'; | ||
import type {ReportAction} from '@src/types/onyx'; | ||
|
||
type ExportIntegrationProps = { | ||
action: OnyxEntry<ReportAction>; | ||
}; | ||
|
||
function ExportIntegration({action}: ExportIntegrationProps) { | ||
const styles = useThemeStyles(); | ||
const fragments = ReportActionUtils.getExportIntegrationActionFragments(action); | ||
|
||
return ( | ||
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter, styles.flexWrap]}> | ||
{fragments.map((fragment, index) => { | ||
if (!fragment.url) { | ||
return ( | ||
<Text | ||
key={index} | ||
style={[styles.chatItemMessage, styles.colorMuted]} | ||
> | ||
{fragment.text}{' '} | ||
</Text> | ||
); | ||
} | ||
|
||
return ( | ||
<TextLink | ||
key={index} | ||
href={fragment.url} | ||
> | ||
{fragment.text}{' '} | ||
</TextLink> | ||
); | ||
})} | ||
</View> | ||
); | ||
} | ||
|
||
ExportIntegration.displayName = 'ExportIntegration'; | ||
|
||
export default ExportIntegration; |
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,19 @@ | ||
/** | ||
* Take an integer reportID and convert it to a string representing a Base-62 report ID. | ||
* | ||
* This is in it's own module to prevent a dependency cycle between libs/ReportUtils.ts and libs/ReportActionUtils.ts | ||
* | ||
* @return string The reportID in base 62-format, always 12 characters beginning with `R`. | ||
*/ | ||
export default function getBase62ReportID(reportID: number): string { | ||
const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | ||
let result = ''; | ||
let remainder = reportID; | ||
while (remainder > 0) { | ||
const currentVal = remainder % 62; | ||
result = alphabet[currentVal] + result; | ||
remainder = Math.floor(remainder / 62); | ||
} | ||
|
||
return `R${result.padStart(11, '0')}`; | ||
} |
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