-
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 #46203 from VickyStash/feature/45176-invoicing-det…
…ails-section [No QA] Invoicing details section
- Loading branch information
Showing
18 changed files
with
325 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
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
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
79 changes: 79 additions & 0 deletions
79
src/pages/workspace/invoices/WorkspaceInvoicingDetailsName.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,79 @@ | ||
import type {StackScreenProps} from '@react-navigation/stack'; | ||
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 TextInput from '@components/TextInput'; | ||
import useAutoFocusInput from '@hooks/useAutoFocusInput'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as ValidationUtils from '@libs/ValidationUtils'; | ||
import Navigation from '@navigation/Navigation'; | ||
import type {SettingsNavigatorParamList} from '@navigation/types'; | ||
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type SCREENS from '@src/SCREENS'; | ||
import INPUT_IDS from '@src/types/form/WorkspaceInvoicesCompanyNameForm'; | ||
|
||
type WorkspaceInvoicingDetailsNameProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.INVOICES_COMPANY_NAME>; | ||
|
||
function WorkspaceInvoicingDetailsName({route}: WorkspaceInvoicingDetailsNameProps) { | ||
const {policyID} = route.params; | ||
|
||
const {translate} = useLocalize(); | ||
const {inputCallbackRef} = useAutoFocusInput(); | ||
const styles = useThemeStyles(); | ||
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const submit = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_INVOICES_COMPANY_NAME_FORM>) => { | ||
// TODO: implement UpdateInvoiceCompanyName API call when it's supported | ||
Navigation.goBack(); | ||
}; | ||
|
||
const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.WORKSPACE_INVOICES_COMPANY_NAME_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.WORKSPACE_INVOICES_COMPANY_NAME_FORM> => | ||
ValidationUtils.getFieldRequiredErrors(values, [INPUT_IDS.COMPANY_NAME]); | ||
|
||
return ( | ||
<AccessOrNotFoundWrapper | ||
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} | ||
policyID={policyID} | ||
// TODO: uncomment when CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED is supported | ||
// featureName={CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED} | ||
> | ||
<ScreenWrapper | ||
testID={WorkspaceInvoicingDetailsName.displayName} | ||
shouldEnablePickerAvoiding={false} | ||
shouldEnableMaxHeight | ||
> | ||
<HeaderWithBackButton title={translate('workspace.invoices.companyName')} /> | ||
<FormProvider | ||
formID={ONYXKEYS.FORMS.WORKSPACE_INVOICES_COMPANY_NAME_FORM} | ||
submitButtonText={translate('common.save')} | ||
onSubmit={submit} | ||
style={[styles.flex1, styles.mh5]} | ||
enabledWhenOffline | ||
validate={validate} | ||
> | ||
<InputWrapper | ||
InputComponent={TextInput} | ||
inputID={INPUT_IDS.COMPANY_NAME} | ||
label={translate('workspace.invoices.companyName')} | ||
accessibilityLabel={translate('workspace.invoices.companyName')} | ||
role={CONST.ROLE.PRESENTATION} | ||
defaultValue={policy?.invoice?.companyName} | ||
ref={inputCallbackRef} | ||
/> | ||
</FormProvider> | ||
</ScreenWrapper> | ||
</AccessOrNotFoundWrapper> | ||
); | ||
} | ||
|
||
WorkspaceInvoicingDetailsName.displayName = 'WorkspaceInvoicingDetailsName'; | ||
|
||
export default WorkspaceInvoicingDetailsName; |
57 changes: 57 additions & 0 deletions
57
src/pages/workspace/invoices/WorkspaceInvoicingDetailsSection.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,57 @@ | ||
import React, {useMemo} from 'react'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; | ||
import Section from '@components/Section'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import Navigation from '@navigation/Navigation'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
type WorkspaceInvoicingDetailsSectionProps = { | ||
/** The current policy ID */ | ||
policyID: string; | ||
}; | ||
|
||
function WorkspaceInvoicingDetailsSection({policyID}: WorkspaceInvoicingDetailsSectionProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); | ||
|
||
const horizontalPadding = useMemo(() => (shouldUseNarrowLayout ? styles.ph5 : styles.ph8), [shouldUseNarrowLayout, styles]); | ||
|
||
return ( | ||
<Section | ||
title={translate('workspace.invoices.invoicingDetails')} | ||
subtitle={translate('workspace.invoices.invoicingDetailsDescription')} | ||
containerStyles={[styles.ph0, shouldUseNarrowLayout ? styles.pt5 : styles.pt8]} | ||
subtitleStyles={horizontalPadding} | ||
titleStyles={[styles.textStrong, horizontalPadding]} | ||
childrenStyles={styles.pt5} | ||
subtitleMuted | ||
> | ||
<MenuItemWithTopDescription | ||
key={translate('workspace.invoices.companyName')} | ||
shouldShowRightIcon | ||
title={policy?.invoice?.companyName} | ||
description={translate('workspace.invoices.companyName')} | ||
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_INVOICES_COMPANY_NAME.getRoute(policyID))} | ||
style={horizontalPadding} | ||
/> | ||
<MenuItemWithTopDescription | ||
key={translate('workspace.invoices.companyWebsite')} | ||
shouldShowRightIcon | ||
title={policy?.invoice?.companyWebsite} | ||
description={translate('workspace.invoices.companyWebsite')} | ||
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_INVOICES_COMPANY_WEBSITE.getRoute(policyID))} | ||
style={horizontalPadding} | ||
/> | ||
</Section> | ||
); | ||
} | ||
|
||
WorkspaceInvoicingDetailsSection.displayName = 'WorkspaceInvoicingDetailsSection'; | ||
|
||
export default WorkspaceInvoicingDetailsSection; |
Oops, something went wrong.