Skip to content

Commit

Permalink
feat: added support for reporting in error modal (#1036)
Browse files Browse the repository at this point in the history
Signed-off-by: wadeking98 <[email protected]>
  • Loading branch information
wadeking98 authored Dec 6, 2023
1 parent 3c687f0 commit 4fd206d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/legacy/core/App/components/misc/InfoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ interface BifoldErrorProps {
description?: string
bodyContent?: Element
message?: string
secondaryCallToActionTitle?: string
secondaryCallToActionPressed?: GenericFn
onCallToActionPressed?: GenericFn
onCallToActionLabel?: string
onClosePressed?: GenericFn
Expand All @@ -36,6 +38,8 @@ const InfoBox: React.FC<BifoldErrorProps> = ({
description,
bodyContent,
message,
secondaryCallToActionTitle,
secondaryCallToActionPressed,
onCallToActionPressed,
onCallToActionLabel,
onClosePressed,
Expand Down Expand Up @@ -228,6 +232,17 @@ const InfoBox: React.FC<BifoldErrorProps> = ({
/>
</View>
)}
{secondaryCallToActionTitle && secondaryCallToActionPressed && (
<View style={{ paddingTop: 10 }}>
<Button
title={secondaryCallToActionTitle}
accessibilityLabel={secondaryCallToActionTitle}
testID={testIdWithKey(secondaryCallToActionTitle)}
buttonType={ButtonType.Secondary}
onPress={secondaryCallToActionPressed}
/>
</View>
)}
</>
</ScrollView>
</View>
Expand Down
8 changes: 7 additions & 1 deletion packages/legacy/core/App/components/modals/ErrorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { useTheme } from '../../contexts/theme'
import { BifoldError } from '../../types/error'
import InfoBox, { InfoBoxType } from '../misc/InfoBox'

const ErrorModal: React.FC = () => {
interface ErrorModalProps {
reportProblemAction?: (error: BifoldError) => void
}

const ErrorModal: React.FC<ErrorModalProps> = ({ reportProblemAction }) => {
const { height } = useWindowDimensions()
const { t } = useTranslation()
const [modalVisible, setModalVisible] = useState<boolean>(false)
Expand Down Expand Up @@ -64,6 +68,8 @@ const ErrorModal: React.FC = () => {
description={error ? error.description : t('Error.Problem')}
message={formattedMessageForError(error ?? null)}
onCallToActionPressed={onDismissModalTouched}
secondaryCallToActionTitle={t('Error.ReportThisProblem')}
secondaryCallToActionPressed={reportProblemAction && error ? () => reportProblemAction(error) : undefined}
/>
</SafeAreaView>
</Modal>
Expand Down
1 change: 1 addition & 0 deletions packages/legacy/core/App/localization/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const translation = {
"code_pt-BR": "Portuguese",
},
"Error": {
"ReportThisProblem": "Report this problem",
"Unknown": "Unknown Error",
"Problem": "A problem has occurred",
"ErrorCode": "Error code",
Expand Down
1 change: 1 addition & 0 deletions packages/legacy/core/App/localization/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const translation = {
"code_pt-BR": "Portugais",
},
"Error": {
"ReportThisProblem": "Report this problem (FR)",
"Unknown": "Erreur inconnue",
"Problem": "Un problème est survenu",
"ErrorCode": "Code d'erreur",
Expand Down
1 change: 1 addition & 0 deletions packages/legacy/core/App/localization/pt-br/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const translation = {
"code_pt-BR": "Português",
},
"Error": {
"ReportThisProblem": "Report this problem (PB)",
"Unknown": "Erro Desconhecido",
"Problem": "Ocorreu um problema",
"ErrorCode": "Código de Erro",
Expand Down

0 comments on commit 4fd206d

Please sign in to comment.