-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[Workspace Feeds] Card name field on confirmation page #52028
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
mountiny
merged 5 commits into
Expensify:main
from
callstack-internal:VickyStash/feature/51908-card-name-on-confirmation-page
Nov 7, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1aa4fe7
Add Card name display to the confirmation step
VickyStash b14b704
Minor improvement
VickyStash 25ae51a
Minor fix
VickyStash 2b88412
Merge branch 'refs/heads/main' into VickyStash/feature/51908-card-nam…
VickyStash 98bf01c
Align the UI between steps
VickyStash 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
95 changes: 95 additions & 0 deletions
95
src/pages/workspace/companyCards/assignCard/CardNameStep.tsx
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,95 @@ | ||
| import React from 'react'; | ||
| import {useOnyx} from 'react-native-onyx'; | ||
| import FormProvider from '@components/Form/FormProvider'; | ||
| import InputWrapper from '@components/Form/InputWrapper'; | ||
| import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; | ||
| import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
| import ScreenWrapper from '@components/ScreenWrapper'; | ||
| import Text from '@components/Text'; | ||
| import TextInput from '@components/TextInput'; | ||
| import useAutoFocusInput from '@hooks/useAutoFocusInput'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import * as ErrorUtils from '@libs/ErrorUtils'; | ||
| import * as ValidationUtils from '@libs/ValidationUtils'; | ||
| import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
| import * as CompanyCards from '@userActions/CompanyCards'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import INPUT_IDS from '@src/types/form/EditExpensifyCardNameForm'; | ||
|
|
||
| type CardNameStepProps = { | ||
| /** Current policy id */ | ||
| policyID: string; | ||
| }; | ||
|
|
||
| function CardNameStep({policyID}: CardNameStepProps) { | ||
| const {translate} = useLocalize(); | ||
| const {inputCallbackRef} = useAutoFocusInput(); | ||
| const styles = useThemeStyles(); | ||
| const [assignCard] = useOnyx(ONYXKEYS.ASSIGN_CARD); | ||
|
|
||
| const data = assignCard?.data; | ||
|
|
||
| const submit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.EDIT_WORKSPACE_COMPANY_CARD_NAME_FORM>) => { | ||
| CompanyCards.setAssignCardStepAndData({ | ||
| currentStep: CONST.COMPANY_CARD.STEP.CONFIRMATION, | ||
| data: { | ||
| cardName: values.name, | ||
| }, | ||
| isEditing: false, | ||
| }); | ||
| }; | ||
|
|
||
| const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.EDIT_WORKSPACE_COMPANY_CARD_NAME_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.EDIT_WORKSPACE_COMPANY_CARD_NAME_FORM> => { | ||
| const errors = ValidationUtils.getFieldRequiredErrors(values, [INPUT_IDS.NAME]); | ||
| const length = values.name.length; | ||
|
|
||
| if (length > CONST.STANDARD_LENGTH_LIMIT) { | ||
| ErrorUtils.addErrorMessage(errors, INPUT_IDS.NAME, translate('common.error.characterLimitExceedCounter', {length, limit: CONST.STANDARD_LENGTH_LIMIT})); | ||
| } | ||
|
|
||
| return errors; | ||
| }; | ||
|
|
||
| return ( | ||
| <AccessOrNotFoundWrapper | ||
| policyID={policyID} | ||
| featureName={CONST.POLICY.MORE_FEATURES.ARE_COMPANY_CARDS_ENABLED} | ||
| > | ||
| <ScreenWrapper | ||
| testID={CardNameStep.displayName} | ||
| shouldEnablePickerAvoiding={false} | ||
| includeSafeAreaPaddingBottom={false} | ||
| > | ||
| <HeaderWithBackButton | ||
| title={translate('workspace.moreFeatures.companyCards.cardName')} | ||
| onBackButtonPress={() => CompanyCards.setAssignCardStepAndData({currentStep: CONST.COMPANY_CARD.STEP.CONFIRMATION, isEditing: false})} | ||
| /> | ||
| <Text style={[styles.mh5, styles.mt3, styles.mb5]}>{translate('workspace.moreFeatures.companyCards.giveItNameInstruction')}</Text> | ||
| <FormProvider | ||
| formID={ONYXKEYS.FORMS.EDIT_WORKSPACE_COMPANY_CARD_NAME_FORM} | ||
| submitButtonText={translate('common.confirm')} | ||
| onSubmit={submit} | ||
| style={[styles.flex1, styles.mh5]} | ||
| enabledWhenOffline | ||
| validate={validate} | ||
| > | ||
| <InputWrapper | ||
| InputComponent={TextInput} | ||
| inputID={INPUT_IDS.NAME} | ||
| label={translate('workspace.moreFeatures.companyCards.cardName')} | ||
| aria-label={translate('workspace.moreFeatures.companyCards.cardName')} | ||
| role={CONST.ROLE.PRESENTATION} | ||
| defaultValue={data?.cardName} | ||
| ref={inputCallbackRef} | ||
| /> | ||
| </FormProvider> | ||
| </ScreenWrapper> | ||
| </AccessOrNotFoundWrapper> | ||
| ); | ||
| } | ||
|
|
||
| CardNameStep.displayName = 'CardNameStep'; | ||
|
|
||
| export default CardNameStep; |
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
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.