Skip to content

Commit

Permalink
chore(IT Wallet): [SIW-709] Update PID issuing saga to match a generi…
Browse files Browse the repository at this point in the history
…c credential (#5373)
  • Loading branch information
LazyAfternoons authored Jan 9, 2024
1 parent 584aacd commit 7f98216
Show file tree
Hide file tree
Showing 48 changed files with 715 additions and 1,004 deletions.
2 changes: 2 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@ IT_WALLET_EXPERIMENTAL_ENABLED=YES
IT_WALLET_WP_URL='https://io-d-wallet-it.azurewebsites.net'
# IT-WALLET PID PROVIDER URL
IT_WALLET_PID_PROVIDER_URL='https://api.eudi-wallet-it-pid-provider.it/ci'
# IT-WALLET CREDENTIAL PROVIDER URL
IT_WALLET_CREDENTIAL_PROVIDER_URL='https://api.eudi-wallet-it-issuer.it/rp'
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,5 @@ IT_WALLET_EXPERIMENTAL_ENABLED=NO
IT_WALLET_WP_URL='https://io-d-wallet-it.azurewebsites.net'
# IT-WALLET PID PROVIDER URL
IT_WALLET_PID_PROVIDER_URL='https://api.eudi-wallet-it-pid-provider.it/ci'
# IT-WALLET CREDENTIAL PROVIDER URL
IT_WALLET_CREDENTIAL_PROVIDER_URL='https://api.eudi-wallet-it-issuer.it/rp'
7 changes: 2 additions & 5 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3471,9 +3471,6 @@ features:
issuedByNew: "Issued by"
releasedBy: "Released by"
info: "Further information about this data"
securityLevels:
high: "High"
na: "Not available"
mdl:
category: "License {{category}}"
issuedDate: "Valid from"
Expand All @@ -3495,8 +3492,8 @@ features:
confirm: "Yes, interrupt it."
cancel: "No, go back"
dataSource:
multi: "Provided by {{authSource}}"
single: "Provided by {{authSource}}"
multi: "Provided by {{credentialSource}}"
single: "Provided by {{credentialSource}}"
credential: "Credential"
attribute: "Attribute"
placeholders:
Expand Down
7 changes: 2 additions & 5 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3472,9 +3472,6 @@ features:
info: "Ulteriori info su questi dati"
issuedByNew: "Emessa da"
releasedBy: "Rilasciata da"
securityLevels:
high: "Alto"
na: "Non disponibile"
mdl:
category: "Licenza {{category}}"
issuedDate: "Valida dal"
Expand All @@ -3496,8 +3493,8 @@ features:
confirm: "Sì, interrompi"
cancel: "No, vai indietro"
dataSource:
multi: "Forniti da {{authSource}}"
single: "Fornito da {{authSource}}"
multi: "Forniti da {{credentialSource}}"
single: "Fornito da {{credentialSource}}"
credential: "Credenziale"
attribute: "Attributo"
placeholders:
Expand Down
8 changes: 7 additions & 1 deletion ts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export const defaultPin = "162534";
/**
* IT Wallet
*/
export const walletProviderUrl: string = pipe(
export const walletProviderBaseUrl: string = pipe(
Config.IT_WALLET_WP_URL,
NonEmptyString.decode,
E.getOrElse(() => "https://io-d-wallet-it.azurewebsites.net")
Expand All @@ -290,3 +290,9 @@ export const walletPidProviderUrl: string = pipe(
NonEmptyString.decode,
E.getOrElse(() => "https://api.eudi-wallet-it-pid-provider.it")
);

export const walletCredentialProviderUrl: string = pipe(
Config.IT_WALLET_CREDENTIAL_PROVIDER_URL,
NonEmptyString.decode,
E.getOrElse(() => "https://api.eudi-wallet-it-issuer.it/rp")
);
93 changes: 59 additions & 34 deletions ts/features/it-wallet/components/ItwCredentialCard.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import * as React from "react";
import { View, Dimensions, Image, StyleSheet } from "react-native";
import { sequence } from "fp-ts/lib/Array";
import { sequenceS } from "fp-ts/lib/Apply";
import * as O from "fp-ts/lib/Option";
import * as E from "fp-ts/lib/Either";
import { pipe } from "fp-ts/lib/function";
import { Body, H6, IOColors, Label } from "@pagopa/io-app-design-system";
import { PidWithToken } from "@pagopa/io-react-native-wallet/lib/typescript/pid/sd-jwt";
import customVariables from "../../../theme/variables";
import {
CredentialCatalogDisplay,
Expand All @@ -19,14 +23,6 @@ type CommonProps = {
type: string;
};

/**
* Props for the component when the credential is a PID.
* @param pidClaims - the claims of the PID.
*/
type WithPidProps = CommonProps & {
pidClaims: PidWithToken["pid"]["claims"];
};

/**
* Props for the component when the credential is a generic credential.
* @param parsedCredential - the parsed credential.
Expand All @@ -35,7 +31,7 @@ type WithCredentialProps = CommonProps & {
parsedCredential: ParsedCredential;
};

type CredentialCardProps = WithPidProps | WithCredentialProps;
type CredentialCardProps = WithCredentialProps;

/**
* Background standard dimension.
Expand All @@ -58,6 +54,56 @@ const FISCAL_CODE_MARGIN_TOP = NAME_MARGIN_TOP + 55 * SCALE_FACTOR;

const TITLE_MARGIN_TOP = 50 * SCALE_FACTOR;

/**
* Encapsulate the logic for displaying the lines in the bottom left corner of the card.
*/
const OverlayLines = ({
parsedCredential,
display: { textColor, firstLine, secondLine }
}: CredentialCardProps) => {
const maybeComposedLine = (line?: Array<string>) =>
pipe(
line,
O.fromNullable,
O.map(item => item.map(item => O.fromNullable(parsedCredential[item]))),
O.chain(sequence(O.option)),
O.map(item => item.map(item => item.value).join(" "))
);

return pipe(
// either we can have both lines or none
sequenceS(O.option)({
firstLine: maybeComposedLine(firstLine),
secondLine: maybeComposedLine(secondLine)
}),
E.fromOption(() => undefined),
// in case we have both lines, we can render them
E.map(({ firstLine, secondLine }) => (
<>
<Label
weight="Regular"
color={textColor}
style={[styles.text, styles.nameText]}
accessibilityLabel={firstLine}
>
{firstLine}
</Label>

<Body
weight="SemiBold"
color={textColor}
style={[styles.text, styles.fiscalCodeText]}
accessibilityLabel={secondLine}
>
{secondLine}
</Body>
</>
)),
E.mapLeft(() => <></> /* nothing to render */),
E.toUnion
);
};

/**
* Renders a card for the PID credential with the name and fiscal code of the owner.
* @param title - the credential title.
Expand All @@ -72,7 +118,7 @@ const ItwCredentialCard = (props: CredentialCardProps) => {
* the values of the fields specified in the display configuration of the credential otherwise.
* @returns an object containing the lines to display.
*/
const getLines = (): { firstLine: string; secondLine: string } => {
/* const getLines = (): { firstLine: string; secondLine: string } => {
if ("pidClaims" in props) {
const { pidClaims } = props;
return {
Expand All @@ -91,9 +137,7 @@ const ItwCredentialCard = (props: CredentialCardProps) => {
: "";
return { firstLine: flText, secondLine: slText };
}
};

const { firstLine, secondLine } = getLines();
}; */

const { textColor, title } = props.display;

Expand All @@ -109,26 +153,7 @@ const ItwCredentialCard = (props: CredentialCardProps) => {
>
{props.display.title}
</H6>
{firstLine && (
<Label
weight="Regular"
color={textColor}
style={[styles.text, styles.nameText]}
accessibilityLabel={firstLine}
>
{firstLine}
</Label>
)}
{secondLine && (
<Body
weight="SemiBold"
color={textColor}
style={[styles.text, styles.fiscalCodeText]}
accessibilityLabel={secondLine}
>
{secondLine}
</Body>
)}
<OverlayLines {...props} />
</View>
);
};
Expand Down
4 changes: 2 additions & 2 deletions ts/features/it-wallet/components/ItwCredentialClaim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { pipe } from "fp-ts/lib/function";
import { View, Image } from "react-native";
import { DateFromString } from "@pagopa/ts-commons/lib/dates";
import {
ClaimDisplayFormat,
ClaimValue,
DrivingPrivilegesClaim,
DrivingPrivilegesClaimType,
Expand All @@ -18,7 +19,6 @@ import I18n from "../../../i18n";
import { useItwInfoBottomSheet } from "../hooks/useItwInfoBottomSheet";
import { localeDateFormat } from "../../../utils/locale";
import { useIOBottomSheetAutoresizableModal } from "../../../utils/hooks/bottomSheet";
import { Claim } from "./ItwCredentialClaimsList";

/**
* Component which renders a place of birth type claim.
Expand Down Expand Up @@ -238,7 +238,7 @@ const DrivingPrivilegesClaimItem = ({
* It renders a different component based on the type of the claim.
* @param claim - the claim to render
*/
const ItwCredentialClaim = ({ claim }: { claim: Claim }) =>
const ItwCredentialClaim = ({ claim }: { claim: ClaimDisplayFormat }) =>
pipe(
claim.value,
ClaimValue.decode,
Expand Down
Loading

0 comments on commit 7f98216

Please sign in to comment.