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

chore: [IOCOM-1678] FIMS history single listItem error state #6136

Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3985,6 +3985,7 @@ permissionRequest:
FIMS:
history:
errorStates:
dataUnavailable: "Dati non disponibili"
ko:
title: "C’è un problema temporaneo"
body: "Il caricamento della lista degli accessi non è riuscito"
Expand Down
1 change: 1 addition & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3985,6 +3985,7 @@ permissionRequest:
FIMS:
history:
errorStates:
dataUnavailable: "Dati non disponibili"
ko:
title: "C’è un problema temporaneo"
body: "Il caricamento della lista degli accessi non è riuscito"
Expand Down
59 changes: 55 additions & 4 deletions ts/features/fims/history/components/FimsHistoryListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
import { ListItemNav } from "@pagopa/io-app-design-system";
import {
Caption,
HSpacer,
Icon,
LabelSmall,
ListItemNav,
PressableListItemBase,
useIOTheme,
VSpacer
} from "@pagopa/io-app-design-system";
import { constNull } from "fp-ts/lib/function";
import * as React from "react";
import { View } from "react-native";
import { ServiceId } from "../../../../../definitions/backend/ServiceId";
import { ServicePublic } from "../../../../../definitions/backend/ServicePublic";
import { Consent } from "../../../../../definitions/fims/Consent";
import I18n from "../../../../i18n";
import { dateToAccessibilityReadableFormat } from "../../../../utils/accessibility";
import { potFoldWithDefault } from "../../../../utils/pot";
import { useAutoFetchingServiceByIdPot } from "../../common/utils/hooks";
import { LoadingFimsHistoryListItem } from "./FimsHistoryLoaders";

// ------- TYPES

type SuccessListItemProps = {
serviceData: ServicePublic;
consent: Consent;
};
type BaseHistoryListItemProps = {
item: Consent;
};

// --------- LISTITEMS

const SuccessListItem = ({ serviceData, consent }: SuccessListItemProps) => (
<ListItemNav
onPress={constNull}
Expand All @@ -24,17 +43,49 @@ const SuccessListItem = ({ serviceData, consent }: SuccessListItemProps) => (
hideChevron
/>
);
type HistoryListItemProps = {
item: Consent;

const FailureListItem = ({ item }: BaseHistoryListItemProps) => {
const theme = useIOTheme();

return (
<PressableListItemBase>
<View
style={{
paddingVertical: 15
}}
>
<View
style={{
alignSelf: "flex-start",
flexDirection: "row"
}}
>
<Icon name="calendar" size={16} color="grey-300" />
<HSpacer size={4} />
<Caption color={theme["textBody-tertiary"]}>
{dateToAccessibilityReadableFormat(item.timestamp)}
</Caption>
</View>
<VSpacer size={4} />
<LabelSmall weight="Semibold" color="error-600">
{I18n.t("FIMS.history.errorStates.dataUnavailable")}
</LabelSmall>
</View>
<Icon name="errorFilled" color="error-600" />
</PressableListItemBase>
);
};

export const FimsHistoryListItem = ({ item }: HistoryListItemProps) => {
// ------- RENDERER

export const FimsHistoryListItem = ({ item }: BaseHistoryListItemProps) => {
const { serviceData } = useAutoFetchingServiceByIdPot(
item.service_id as ServiceId
);

return potFoldWithDefault(serviceData, {
default: LoadingFimsHistoryListItem,
noneError: _ => <FailureListItem item={item} />,
some: data => <SuccessListItem serviceData={data} consent={item} />,
someError: data => <SuccessListItem serviceData={data} consent={item} />,
someLoading: data => <SuccessListItem serviceData={data} consent={item} />
Expand Down
Loading