Skip to content

Commit

Permalink
Merge branch 'master' into IOPID-2108-a11y-first-onboarding-email-ins…
Browse files Browse the repository at this point in the history
…ertion
  • Loading branch information
Ladirico authored Aug 30, 2024
2 parents 989bc33 + 8c410f2 commit 90787fd
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 4 deletions.
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

0 comments on commit 90787fd

Please sign in to comment.