-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 #46207 from narefyev91/tax-exempt-actions
Add Tax Exempt to Subscription
- Loading branch information
Showing
10 changed files
with
113 additions
and
2 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
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
7 changes: 7 additions & 0 deletions
7
src/pages/settings/Subscription/TaxExemptActions/index.native.tsx
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 @@ | ||
function TaxExemptActions() { | ||
return null; // We need to disable actions on mobile | ||
} | ||
|
||
TaxExemptActions.displayName = 'TaxExemptActions'; | ||
|
||
export default TaxExemptActions; |
71 changes: 71 additions & 0 deletions
71
src/pages/settings/Subscription/TaxExemptActions/index.tsx
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,71 @@ | ||
import React, {useCallback, useMemo, useRef, useState} from 'react'; | ||
import {View} from 'react-native'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import ThreeDotsMenu from '@components/ThreeDotsMenu'; | ||
import type ThreeDotsMenuProps from '@components/ThreeDotsMenu/types'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import type {AnchorPosition} from '@styles/index'; | ||
import * as Report from '@userActions/Report'; | ||
import * as Subscription from '@userActions/Subscription'; | ||
import CONST from '@src/CONST'; | ||
|
||
const anchorAlignment = { | ||
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, | ||
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.TOP, | ||
}; | ||
|
||
function TaxExemptActions() { | ||
const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState<AnchorPosition>({horizontal: 0, vertical: 0}); | ||
const threeDotsMenuContainerRef = useRef<View>(null); | ||
|
||
const overflowMenu: ThreeDotsMenuProps['menuItems'] = useMemo( | ||
() => [ | ||
{ | ||
icon: Expensicons.Coins, | ||
numberOfLinesTitle: 2, | ||
text: translate('subscription.details.taxExempt'), | ||
onSelected: () => { | ||
Subscription.requestTaxExempt(); | ||
Report.navigateToConciergeChat(); | ||
}, | ||
}, | ||
], | ||
[translate], | ||
); | ||
|
||
const calculateAndSetThreeDotsMenuPosition = useCallback(() => { | ||
if (shouldUseNarrowLayout) { | ||
return; | ||
} | ||
threeDotsMenuContainerRef.current?.measureInWindow((x, y, width, height) => { | ||
setThreeDotsMenuPosition({ | ||
horizontal: x + width, | ||
vertical: y + height, | ||
}); | ||
}); | ||
}, [shouldUseNarrowLayout]); | ||
|
||
return ( | ||
<View | ||
ref={threeDotsMenuContainerRef} | ||
style={[styles.mtn2, styles.pAbsolute, styles.rn3]} | ||
> | ||
<ThreeDotsMenu | ||
onIconPress={calculateAndSetThreeDotsMenuPosition} | ||
menuItems={overflowMenu} | ||
anchorPosition={threeDotsMenuPosition} | ||
anchorAlignment={anchorAlignment} | ||
shouldOverlay | ||
/> | ||
</View> | ||
); | ||
} | ||
|
||
TaxExemptActions.displayName = 'TaxExemptActions'; | ||
|
||
export default TaxExemptActions; |
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 |
---|---|---|
|
@@ -55,6 +55,9 @@ export default { | |
r8: { | ||
right: 32, | ||
}, | ||
rn3: { | ||
right: -12, | ||
}, | ||
b0: { | ||
bottom: 0, | ||
}, | ||
|