-
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 #44739 from software-mansion-labs/war-in/sage-inta…
…cct-export-config-offline-error Sage intacct export: offline and error
- Loading branch information
Showing
17 changed files
with
268 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {mapValues} from 'lodash'; | ||
import React from 'react'; | ||
import type {StyleProp, ViewStyle} from 'react-native'; | ||
import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; | ||
import type {ReceiptError, ReceiptErrors} from '@src/types/onyx/Transaction'; | ||
import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
import MessagesRow from './MessagesRow'; | ||
|
||
type ErrorMessageRowProps = { | ||
/** The errors to display */ | ||
errors?: OnyxCommon.Errors | ReceiptErrors | null; | ||
|
||
/** Additional style object for the error row */ | ||
errorRowStyles?: StyleProp<ViewStyle>; | ||
|
||
/** A function to run when the X button next to the error is clicked */ | ||
onClose?: () => void; | ||
|
||
/** Whether we can dismiss the error message */ | ||
canDismissError?: boolean; | ||
}; | ||
|
||
function ErrorMessageRow({errors, errorRowStyles, onClose, canDismissError = true}: ErrorMessageRowProps) { | ||
// Some errors have a null message. This is used to apply opacity only and to avoid showing redundant messages. | ||
const errorEntries = Object.entries(errors ?? {}); | ||
const filteredErrorEntries = errorEntries.filter((errorEntry): errorEntry is [string, string | ReceiptError] => errorEntry[1] !== null); | ||
const errorMessages = mapValues(Object.fromEntries(filteredErrorEntries), (error) => error); | ||
const hasErrorMessages = !isEmptyObject(errorMessages); | ||
|
||
return hasErrorMessages ? ( | ||
<MessagesRow | ||
messages={errorMessages} | ||
type="error" | ||
onClose={onClose} | ||
containerStyles={errorRowStyles} | ||
canDismiss={canDismissError} | ||
/> | ||
) : null; | ||
} | ||
|
||
ErrorMessageRow.displayName = 'ErrorMessageRow'; | ||
|
||
export default ErrorMessageRow; |
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
Oops, something went wrong.