-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[No QA] [Direct Feeds] Broken connection violation #50793
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
Changes from all commits
2f90dd1
7e7c40c
7bce745
ba663d7
d9316e8
129025e
91e299d
630893f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import React from 'react'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
|
mountiny marked this conversation as resolved.
|
||
| import {useOnyx} from 'react-native-onyx'; | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import * as PolicyUtils from '@libs/PolicyUtils'; | ||
| import * as ReportUtils from '@libs/ReportUtils'; | ||
| import Navigation from '@navigation/Navigation'; | ||
| import CONST from '@src/CONST'; | ||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import ROUTES from '@src/ROUTES'; | ||
| import type {Policy, Report} from '@src/types/onyx'; | ||
| import TextLink from './TextLink'; | ||
|
|
||
| type BrokenConnectionDescriptionProps = { | ||
| /** Transaction id of the corresponding report */ | ||
| transactionID: string; | ||
|
|
||
| /** Current report */ | ||
| report: OnyxEntry<Report>; | ||
|
|
||
| /** Policy which the report is tied to */ | ||
| policy: OnyxEntry<Policy>; | ||
| }; | ||
|
|
||
| function BrokenConnectionDescription({transactionID, policy, report}: BrokenConnectionDescriptionProps) { | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my concern here is that for a fraction of time |
||
|
|
||
| const brokenConnection530Error = transactionViolations?.find((violation) => violation.data?.rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530); | ||
| const brokenConnectionError = transactionViolations?.find((violation) => violation.data?.rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION); | ||
| const isPolicyAdmin = PolicyUtils.isPolicyAdmin(policy); | ||
|
|
||
| if (!brokenConnection530Error && !brokenConnectionError) { | ||
| return ''; | ||
| } | ||
|
|
||
| if (brokenConnection530Error) { | ||
| return translate('violations.brokenConnection530Error'); | ||
| } | ||
|
|
||
| if (isPolicyAdmin && !ReportUtils.isCurrentUserSubmitter(report?.reportID ?? '')) { | ||
| return ( | ||
| <> | ||
| {`${translate('violations.adminBrokenConnectionError')}`} | ||
| <TextLink | ||
| style={[styles.textLabelSupporting, styles.link]} | ||
| onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policy?.id ?? '-1'))} | ||
| >{`${translate('workspace.common.companyCards')}`}</TextLink> | ||
| . | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| if (ReportUtils.isReportApproved(report) || ReportUtils.isReportManuallyReimbursed(report) || (ReportUtils.isProcessingReport(report) && !PolicyUtils.isInstantSubmitEnabled(policy))) { | ||
| return translate('violations.memberBrokenConnectionError'); | ||
| } | ||
|
|
||
| return `${translate('violations.memberBrokenConnectionError')} ${translate('violations.markAsCashToIgnore')}`; | ||
| } | ||
|
|
||
| BrokenConnectionDescription.displayName = 'BrokenConnectionDescription'; | ||
|
|
||
| export default BrokenConnectionDescription; | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||||||||||||||||||
| import type {ReactNode} from 'react'; | ||||||||||||||||||||||||
| import type {ReactElement, ReactNode} from 'react'; | ||||||||||||||||||||||||
| import React from 'react'; | ||||||||||||||||||||||||
| import {View} from 'react-native'; | ||||||||||||||||||||||||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||||||||||||||||||||||||
|
|
@@ -9,7 +9,7 @@ type MoneyRequestHeaderStatusBarProps = { | |||||||||||||||||||||||
| icon: ReactNode; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** Banner Description */ | ||||||||||||||||||||||||
| description: string; | ||||||||||||||||||||||||
| description: string | ReactElement; | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we save the description as string itself, we can convert the prop into string before passing ? (saying cause we don't want the BE to throw some weird error
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @allgandalf could you clarify what BE errors do you mean? App/src/components/MoneyRequestHeaderStatusBar.tsx Lines 18 to 28 in 91e299d
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** Whether we style flex grow */ | ||||||||||||||||||||||||
| shouldStyleFlexGrow?: boolean; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4688,7 +4688,10 @@ const translations = { | |
| return message; | ||
| }, | ||
| reviewRequired: 'Review required', | ||
| rter: ({brokenBankConnection, email, isAdmin, isTransactionOlderThan7Days, member}: ViolationsRterParams) => { | ||
| rter: ({brokenBankConnection, email, isAdmin, isTransactionOlderThan7Days, member, rterType}: ViolationsRterParams) => { | ||
| if (rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530 || rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION) { | ||
| return ''; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This caused issue we should show violation message for the two type of violations. |
||
| } | ||
| if (brokenBankConnection) { | ||
| return isAdmin | ||
| ? `Can't auto-match receipt due to broken bank connection which ${email} needs to fix` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When will we use these translations? Should we remove then?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The updates were implemented in this PR. |
||
|
|
@@ -4700,6 +4703,10 @@ const translations = { | |
|
|
||
| return ''; | ||
| }, | ||
| brokenConnection530Error: 'Receipt pending due to broken bank connection.', | ||
| adminBrokenConnectionError: 'Receipt pending due to broken bank connection. Please resolve in ', | ||
| memberBrokenConnectionError: 'Receipt pending due to broken bank connection. Please ask a workspace admin to resolve.', | ||
| markAsCashToIgnore: 'Mark as cash to ignore and request payment.', | ||
| smartscanFailed: 'Receipt scanning failed. Enter details manually.', | ||
| someTagLevelsRequired: ({tagName}: ViolationsTagOutOfPolicyParams = {}) => `Missing ${tagName ?? 'Tag'}`, | ||
| tagOutOfPolicy: ({tagName}: ViolationsTagOutOfPolicyParams = {}) => `${tagName ?? 'Tag'} no longer valid`, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.