Skip to content
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

[Wave Collect] [Xero] Show organization name #41969

Merged
merged 18 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions src/components/ConnectionLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ type ConnectionLayoutProps = {
/** Header title for the connection */
headerTitle: TranslationPaths;

/** The subtitle to show in the header */
headerSubtitle?: string;

/** React nodes that will be shown */
children?: React.ReactNode;

/** Title of the connection component */
title?: TranslationPaths;

/** Subtitle of the connection */
subtitle?: TranslationPaths;
Copy link
Member Author

@rushatgabhane rushatgabhane May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't used anywhere, so I took the liberty of removing it. Let me know if you disagree

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense and we can add it again if required later. I don't see any of my/other screens also using this.


/** The current policyID */
policyID: string;

Expand All @@ -44,22 +44,18 @@ type ConnectionLayoutProps = {
/** Style of the title text */
titleStyle?: StyleProp<TextStyle> | undefined;

/** Style of the subtitle text */
subTitleStyle?: StyleProp<TextStyle> | undefined;

/** Whether to use ScrollView or not */
shouldUseScrollView?: boolean;
};

type ConnectionLayoutContentProps = Pick<ConnectionLayoutProps, 'title' | 'titleStyle' | 'subtitle' | 'subTitleStyle' | 'children'>;
type ConnectionLayoutContentProps = Pick<ConnectionLayoutProps, 'title' | 'titleStyle' | 'children'>;

function ConnectionLayoutContent({title, titleStyle, subtitle, subTitleStyle, children}: ConnectionLayoutContentProps) {
function ConnectionLayoutContent({title, titleStyle, children}: ConnectionLayoutContentProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
return (
<>
{title && <Text style={[styles.pb5, titleStyle]}>{translate(title)}</Text>}
{subtitle && <Text style={[styles.textLabelSupporting, subTitleStyle]}>{translate(subtitle)}</Text>}
{children}
</>
);
Expand All @@ -70,13 +66,12 @@ function ConnectionLayout({
headerTitle,
children,
title,
subtitle,
headerSubtitle: subtitle,
policyID,
accessVariants,
featureName,
contentContainerStyle,
titleStyle,
subTitleStyle,
shouldUseScrollView = true,
}: ConnectionLayoutProps) {
const {translate} = useLocalize();
Expand All @@ -85,14 +80,12 @@ function ConnectionLayout({
() => (
<ConnectionLayoutContent
title={title}
subtitle={subtitle}
subTitleStyle={subTitleStyle}
titleStyle={titleStyle}
>
{children}
</ConnectionLayoutContent>
),
[title, subtitle, titleStyle, subTitleStyle, children],
[title, titleStyle, children],
);

return (
Expand All @@ -108,6 +101,7 @@ function ConnectionLayout({
>
<HeaderWithBackButton
title={translate(headerTitle)}
subtitle={subtitle}
onBackButtonPress={() => Navigation.goBack()}
/>
{shouldUseScrollView ? (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function MoneyRequestView({
<OfflineWithFeedback
pendingAction={pendingAction}
errors={transaction?.errors}
errorRowStyles={[styles.ml4]}
errorRowStyles={[styles.mh4]}
onClose={() => {
if (!transaction?.transactionID) {
return;
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ export default {
other: 'Unexpected error, please try again later.',
genericCreateFailureMessage: 'Unexpected error submitting this expense. Please try again later.',
genericCreateInvoiceFailureMessage: 'Unexpected error sending invoice, please try again later.',
receiptDeleteFailureError: 'Unexpected error deleting this receipt. Please try again later.',
// eslint-disable-next-line rulesdir/use-periods-for-error-messages
receiptFailureMessage: "The receipt didn't upload. ",
// eslint-disable-next-line rulesdir/use-periods-for-error-messages
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ export default {
other: 'Error inesperado, por favor inténtalo más tarde.',
genericCreateFailureMessage: 'Error inesperado al enviar este gasto. Por favor, inténtalo más tarde.',
genericCreateInvoiceFailureMessage: 'Error inesperado al enviar la factura, inténtalo de nuevo más tarde.',
receiptDeleteFailureError: 'Error inesperado al borrar este recibo. Vuelve a intentarlo más tarde.',
// eslint-disable-next-line rulesdir/use-periods-for-error-messages
receiptFailureMessage: 'El recibo no se subió. ',
// eslint-disable-next-line rulesdir/use-periods-for-error-messages
Expand Down
5 changes: 4 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6315,7 +6315,10 @@ function detachReceipt(transactionID: string) {
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: transaction,
value: {
...transaction,
errors: ErrorUtils.getMicroSecondOnyxError('iou.error.receiptDeleteFailureError'),
},
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import * as Connections from '@libs/actions/connections';
import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils';
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections';
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow';
Expand All @@ -30,10 +31,14 @@ function XeroAdvancedPage({policy}: WithPolicyConnectionsProps) {
return selectedAccount?.name ?? '';
}, [bankAccounts, invoiceCollectionsAccountID]);

const tenants = useMemo(() => getXeroTenants(policy ?? undefined), [policy]);
const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID);

return (
<ConnectionLayout
displayName={XeroAdvancedPage.displayName}
headerTitle="workspace.xero.advancedConfig.advanced"
headerSubtitle={currentXeroOrganization?.name}
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
policyID={policyID}
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import React, {useMemo} from 'react';
import ConnectionLayout from '@components/ConnectionLayout';
import type {MenuItemProps} from '@components/MenuItem';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import type {OfflineWithFeedbackProps} from '@components/OfflineWithFeedback';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import {findCurrentXeroOrganization, getXeroTenants} from '@libs/PolicyUtils';
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections';
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
import CONST from '@src/CONST';
Expand All @@ -19,6 +20,9 @@ function XeroExportConfigurationPage({policy}: WithPolicyConnectionsProps) {
const policyOwner = policy?.owner ?? '';

const {export: exportConfiguration, errorFields, pendingFields} = policy?.connections?.xero?.config ?? {};
const tenants = useMemo(() => getXeroTenants(policy ?? undefined), [policy]);
const currentXeroOrganization = findCurrentXeroOrganization(tenants, policy?.connections?.xero?.config?.tenantID);

const menuItems: MenuItem[] = [
{
description: translate('workspace.xero.preferredExporter'),
Expand Down Expand Up @@ -77,6 +81,7 @@ function XeroExportConfigurationPage({policy}: WithPolicyConnectionsProps) {
<ConnectionLayout
displayName={XeroExportConfigurationPage.displayName}
headerTitle="workspace.xero.export"
headerSubtitle={currentXeroOrganization?.name}
title="workspace.xero.exportDescription"
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]}
policyID={policyID}
Expand Down
Loading