Repository navigation
[Simplified Collect][Taxes] Creating new taxes #37967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
luacmartins
merged 44 commits into
Expensify:main
from
software-mansion-labs:wave8/CreatingNewTaxes
Mar 18, 2024
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
b7cdc1b
add initial new tax page
kosmydel b351a28
add API command
kosmydel 0f5eaad
add AmountSelectorModal
kosmydel 3c3fc37
add TextPicker
kosmydel fd5029c
fix new pickers
kosmydel 9e492c2
use pendingActions and errors in tax rates
kosmydel da6573f
draft
kosmydel 4538c2a
Merge branch 'wave8/WorkspaceTaxesPage' into wave8/CreatingNewTaxes
kosmydel 01a70b9
fix validation
kosmydel 05f3a09
add saving drafts
kosmydel c0ead40
fix displaying tax rate in the list
kosmydel 34cef2a
change type names
kosmydel d9574c2
Merge branch 'wave8/WorkspaceTaxesPage' into wave8/CreatingNewTaxes
kosmydel 71d90f4
add spanish translation drafts
kosmydel 4be8838
fix translation
kosmydel ae25dc5
Merge branch 'wave8/WorkspaceTaxesPage' into wave8/CreatingNewTaxes
kosmydel b6b6fd4
add auto focus
kosmydel 6903cb5
add brickRoadIndicator
kosmydel d461d15
fix parameters
kosmydel 4728b24
Merge branch 'wave8/WorkspaceTaxesPage' into wave8/CreatingNewTaxes
kosmydel 7ba715e
fix rhp mapping
kosmydel c8ce6bb
clear drafts
kosmydel 31d41b9
cleanup
kosmydel 3cf7374
lint
kosmydel 2747599
Merge branch 'main' into wave8/CreatingNewTaxes
kosmydel 5ebdcb1
extract validation
kosmydel 46da5b0
fix types
kosmydel 5d6fb5e
adress review
kosmydel 438c973
Fix
kosmydel e94dde9
Merge branch 'main' into wave8/CreatingNewTaxes
kosmydel 3e62eb3
prevent creating duplicate id
kosmydel efd2a9b
cleanup
kosmydel 58e682b
polish
kosmydel a0a1049
address review
kosmydel 145c10b
Merge branch 'main' into wave8/CreatingNewTaxes
kosmydel bda7696
address review
kosmydel 9671e6c
fix types
kosmydel 082eeed
rename WorkspaceCreateTaxPage
kosmydel dc900fc
rename: getNextTaxCode
kosmydel ca68505
rename
kosmydel 186a79b
rename TAX_CREATE screen
kosmydel 79977f2
Update src/SCREENS.ts
kosmydel 4b764ea
address review
kosmydel dd79adb
fix comments
kosmydel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,64 @@ | ||
| import React, {useState} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import AmountForm from '@components/AmountForm'; | ||
| import Button from '@components/Button'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import Modal from '@components/Modal'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import ScrollView from '@components/ScrollView'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import CONST from '@src/CONST'; | ||
| import type {AmountSelectorModalProps} from './types'; | ||
|
|
||
| function AmountSelectorModal({value, description = '', onValueSelected, isVisible, onClose, ...rest}: AmountSelectorModalProps) { | ||
| const {translate} = useLocalize(); | ||
| const styles = useThemeStyles(); | ||
|
|
||
| const [currentValue, setValue] = useState(value); | ||
|
|
||
| return ( | ||
| <Modal | ||
| type={CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED} | ||
| isVisible={isVisible} | ||
| onClose={onClose} | ||
| onModalHide={onClose} | ||
| hideModalContentWhileAnimating | ||
| useNativeDriver | ||
| > | ||
| <ScreenWrapper | ||
| includePaddingTop={false} | ||
| includeSafeAreaPaddingBottom={false} | ||
| testID={AmountSelectorModal.displayName} | ||
| shouldEnableMaxHeight | ||
| > | ||
| <HeaderWithBackButton | ||
| title={description} | ||
| onBackButtonPress={onClose} | ||
| /> | ||
| <ScrollView contentContainerStyle={[styles.flex1, styles.mh5, styles.mb5]}> | ||
| <View style={styles.flex1}> | ||
| <AmountForm | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...rest} | ||
| autoFocus | ||
| value={currentValue} | ||
| onInputChange={setValue} | ||
| /> | ||
| </View> | ||
| <Button | ||
| success | ||
| large | ||
| pressOnEnter | ||
| text={translate('common.save')} | ||
| onPress={() => onValueSelected?.(currentValue ?? '')} | ||
| /> | ||
| </ScrollView> | ||
| </ScreenWrapper> | ||
| </Modal> | ||
| ); | ||
| } | ||
|
|
||
| AmountSelectorModal.displayName = 'AmountSelectorModal'; | ||
|
|
||
| export default AmountSelectorModal; |
This file contains hidden or 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,65 @@ | ||
| import React, {forwardRef, useState} from 'react'; | ||
| import type {ForwardedRef} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import FormHelpMessage from '@components/FormHelpMessage'; | ||
| import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
| import useStyleUtils from '@hooks/useStyleUtils'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import variables from '@styles/variables'; | ||
| import callOrReturn from '@src/types/utils/callOrReturn'; | ||
| import AmountSelectorModal from './AmountSelectorModal'; | ||
| import type {AmountPickerProps} from './types'; | ||
|
|
||
| function AmountPicker({value, description, title, errorText = '', onInputChange, furtherDetails, rightLabel, ...rest}: AmountPickerProps, forwardedRef: ForwardedRef<View>) { | ||
| const styles = useThemeStyles(); | ||
| const StyleUtils = useStyleUtils(); | ||
| const [isPickerVisible, setIsPickerVisible] = useState(false); | ||
|
|
||
| const showPickerModal = () => { | ||
| setIsPickerVisible(true); | ||
| }; | ||
|
|
||
| const hidePickerModal = () => { | ||
| setIsPickerVisible(false); | ||
| }; | ||
|
|
||
| const updateInput = (updatedValue: string) => { | ||
| if (updatedValue !== value) { | ||
| onInputChange?.(updatedValue); | ||
| } | ||
| hidePickerModal(); | ||
| }; | ||
|
|
||
| const descStyle = !value || value.length === 0 ? StyleUtils.getFontSizeStyle(variables.fontSizeLabel) : null; | ||
|
|
||
| return ( | ||
| <View> | ||
| <MenuItemWithTopDescription | ||
| ref={forwardedRef} | ||
| shouldShowRightIcon | ||
| title={callOrReturn(title, value)} | ||
| descriptionTextStyle={descStyle} | ||
| description={description} | ||
| onPress={showPickerModal} | ||
| furtherDetails={furtherDetails} | ||
| rightLabel={rightLabel} | ||
| /> | ||
| <View style={styles.ml5}> | ||
| <FormHelpMessage message={errorText} /> | ||
| </View> | ||
| <AmountSelectorModal | ||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| {...rest} | ||
| value={value} | ||
| isVisible={isPickerVisible} | ||
| description={description} | ||
| onClose={hidePickerModal} | ||
| onValueSelected={updateInput} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| AmountPicker.displayName = 'AmountPicker'; | ||
|
|
||
| export default forwardRef(AmountPicker); |
This file contains hidden or 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,40 @@ | ||
| import type {AmountFormProps} from '@components/AmountForm'; | ||
| import type {MenuItemBaseProps} from '@components/MenuItem'; | ||
| import type {MaybePhraseKey} from '@libs/Localize'; | ||
|
|
||
| type AmountSelectorModalProps = { | ||
| /** Whether the modal is visible */ | ||
| isVisible: boolean; | ||
|
|
||
| /** Current value */ | ||
| value?: string; | ||
|
|
||
| /** Function to call when the user selects a item */ | ||
| onValueSelected?: (value: string) => void; | ||
|
|
||
| /** Function to call when the user closes the modal */ | ||
| onClose: () => void; | ||
| } & Pick<MenuItemBaseProps, 'description'>; | ||
|
|
||
| type AmountPickerProps = { | ||
| /** Item to display */ | ||
| value?: string; | ||
|
|
||
| /** A placeholder value to display */ | ||
| title?: string | ((value?: string) => string); | ||
|
|
||
| /** Form Error description */ | ||
| errorText?: MaybePhraseKey; | ||
|
|
||
| /** Callback to call when the input changes */ | ||
| onInputChange?: (value: string | undefined) => void; | ||
|
|
||
| /** Text to display under the main menu item */ | ||
| furtherDetails?: string; | ||
|
|
||
| /** Whether to show the tooltip text */ | ||
| shouldShowTooltips?: boolean; | ||
| } & Pick<MenuItemBaseProps, 'rightLabel' | 'description'> & | ||
| AmountFormProps; | ||
|
|
||
| export type {AmountSelectorModalProps, AmountPickerProps}; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.