Skip to content

Commit

Permalink
refactor(ui): fix responsiveness, images and text
Browse files Browse the repository at this point in the history
* [REF] ui/ux

* add: rekognito and amplify implementation

* add: liveness and face match implementation

* fix: optional payload

* add: `disableInstructionScreen` props to component

* [REF] ui/ux and i18n

---------

Co-authored-by: Marluan Espiritusanto <marluanespiritusantoguerrero@gmail.com>
  • Loading branch information
JE1999 and marluanespiritusanto authored May 5, 2023
1 parent 29037bb commit 76776c7
Show file tree
Hide file tree
Showing 20 changed files with 458 additions and 196 deletions.
Binary file modified public/assets/ladingChica2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions src/components/biometric/displayText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
export type HintDisplayText = {
hintMoveFaceFrontOfCameraText?: string;
hintTooManyFacesText?: string;
hintFaceDetectedText?: string;
hintCanNotIdentifyText?: string;
hintTooCloseText?: string;
hintTooFarText?: string;
hintHoldFacePositionCountdownText?: string;
hintConnectingText?: string;
hintVerifyingText?: string;
hintIlluminationTooBrightText?: string;
hintIlluminationTooDarkText?: string;
hintIlluminationNormalText?: string;
hintHoldFaceForFreshnessText?: string;
};

export type CameraDisplayText = {
cameraMinSpecificationsHeadingText?: string;
cameraMinSpecificationsMessageText?: string;
cameraNotFoundHeadingText?: string;
cameraNotFoundMessageText?: string;
retryCameraPermissionsText?: string;
};

export type InstructionDisplayText = {
instructionsHeaderHeadingText?: string;
instructionsHeaderBodyText?: string;
instructionsBeginCheckText?: string;
photosensitivyWarningHeadingText?: string;
photosensitivyWarningBodyText?: string;
photosensitivyWarningInfoText?: string;
instructionListHeadingText?: string;
goodFitCaptionText?: string;
goodFitAltText?: string;
tooFarCaptionText?: string;
tooFarAltText?: string;
instructionListStepOneText?: string;
instructionListStepTwoText?: string;
instructionListStepThreeText?: string;
instructionListStepFourText?: string;
};

export type StreamDisplayText = {
recordingIndicatorText?: string;
cancelLivenessCheckText?: string;
};

export const defaultErrorDisplayText = {
timeoutHeaderText: 'Se acabó el tiempo',
timeoutMessageText:
"La cara no llenó el óvalo dentro del límite de tiempo. Vuelva a intentarlo y llene completamente el óvalo con la cara en 7 segundos.",
faceDistanceHeaderText: 'Comprobación fallida durante la cuenta atrás',
faceDistanceMessageText:
'Evite acercarse durante la cuenta regresiva y asegúrese de que solo una cara esté frente a la cámara.',
clientHeaderText: 'Error del cliente',
clientMessageText: 'Verificación fallida debido a un problema con el cliente',
serverHeaderText: 'Problema del servidor',
serverMessageText: 'No se puede completar la verificación debido a un problema con el servidor',
landscapeHeaderText: 'Orientación horizontal no compatible',
landscapeMessageText:
'Gire su dispositivo a la orientación vertical (retrato).',
portraitMessageText:
'Asegúrese de que su dispositivo permanezca en orientación vertical (retrato) durante la verificación.',
tryAgainText: 'Intentar otra vez',
};

export type ErrorDisplayTextFoo = typeof defaultErrorDisplayText;
export type ErrorDisplayText = Partial<ErrorDisplayTextFoo>;

export const defaultLivenessDisplayText: Required<LivenessDisplayText> = {
instructionsHeaderHeadingText: 'Liveness check',
instructionsHeaderBodyText:
'You will go through a face verification process to prove that you are a real person.',
instructionsBeginCheckText: 'Begin check',
photosensitivyWarningHeadingText: 'Photosensitivity warning',
photosensitivyWarningBodyText:
'This check displays colored lights. Use caution if you are photosensitive.',
photosensitivyWarningInfoText:
'A small percentage of individuals may experience epileptic seizures when exposed to colored lights. Use caution if you, or anyone in your family, have an epileptic condition.',
instructionListHeadingText: 'Follow the instructions to complete the check:',
goodFitCaptionText: 'Good fit',
goodFitAltText:
"Ilustration of a person's face, perfectly fitting inside of an oval.",
tooFarCaptionText: 'Too far',
tooFarAltText:
"Illustration of a person's face inside of an oval; there is a gap between the perimeter of the face and the boundaries of the oval.",
instructionListStepOneText:
'When an oval appears, fill the oval with your face within 7 seconds.',
instructionListStepTwoText: "Maximize your screen's brightness.",
instructionListStepThreeText:
'Make sure your face is not covered with sunglasses or a mask.',
instructionListStepFourText:
'Move to a well-lit place that is not in direct sunlight.',
cameraMinSpecificationsHeadingText:
'Camera does not meet minimum specifications',
cameraMinSpecificationsMessageText:
'Camera must support at least 320*240 resolution and 15 frames per second.',
cameraNotFoundHeadingText: 'Camera not accessible.',
cameraNotFoundMessageText:
'Verifique que la cámara esté conectada y que los permisos de la cámara estén habilitados en la configuración antes de volver a intentarlo.',
retryCameraPermissionsText: 'Procesar de nuevo',
cancelLivenessCheckText: 'Cancelar comprobación de vitalidad',
recordingIndicatorText: 'Grabación',
hintMoveFaceFrontOfCameraText: 'Mover la cara frente a la cámara',
hintTooManyFacesText: 'Asegúrese de que solo una cara esté frente a la cámara',
hintFaceDetectedText: 'Cara detectada',
hintCanNotIdentifyText: 'Mover la cara frente a la cámara',
hintTooCloseText: 'Muévete mas atrás',
hintTooFarText: 'Muévete mas cerca',
hintHoldFacePositionCountdownText: 'Mantener la posición de la cara durante la cuenta regresiva',
hintConnectingText: 'Conectando...',
hintVerifyingText: 'Verificando...',
hintIlluminationTooBrightText: 'Mover al área de atenuación',
hintIlluminationTooDarkText: 'Mover a un área más brillante',
hintIlluminationNormalText: 'Condiciones de iluminación normales',
hintHoldFaceForFreshnessText: 'Quédate quieto',
...defaultErrorDisplayText,
};

export interface LivenessDisplayText
extends HintDisplayText,
CameraDisplayText,
InstructionDisplayText,
ErrorDisplayText,
StreamDisplayText {}
132 changes: 119 additions & 13 deletions src/components/biometric/face-liveness-detector.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { FaceLivenessDetector } from "@aws-amplify/ui-react-liveness";
import { Loader, ThemeProvider } from "@aws-amplify/ui-react";
import { ThemeProvider } from "@aws-amplify/ui-react";
import React from "react";
import { LoadingProgress } from "../elements/loading";
import { AlertErrorMessage } from "../elements/alert";
import { View, Heading, Alert, Card, Text } from '@aws-amplify/ui-react';
import { defaultLivenessDisplayText } from './displayText'

export function LivenessQuickStartReact({ handleNextForm, cedula }: any) {
const next = handleNextForm;
const id = cedula;
const [loading, setLoading] = React.useState<boolean>(true);
const [error, setError] = React.useState<boolean>(false);
const [sessionId, setSessionId] = React.useState<string>("");

React.useEffect(() => {
Expand All @@ -29,22 +34,123 @@ export function LivenessQuickStartReact({ handleNextForm, cedula }: any) {
if (data.match) {
next();
} else {
alert("No se ha podido validar correctamente la identidad.");
setError(true);
}
};

// const dictionary = {
// // use default strings for english
// en: null,
// es: {
// instructionsHeaderHeadingText: 'Verificación de vida',
// instructionsHeaderBodyText:
// 'Pasará por un proceso de verificación facial para demostrar que es una persona real.',
// instructionListStepOneText:
// 'Cuando aparezca un óvalo, rellena el óvalo con tu cara en 7 segundos.',
// instructionListStepTwoText: 'Maximiza el brillo de tu pantalla.',
// instructionListStepThreeText:
// 'Asegúrese de que su cara no esté cubierta con gafas de sol o una máscara.',
// instructionListStepFourText:
// 'Muévase a un lugar bien iluminado que no esté expuesto a la luz solar directa.',
// photosensitivyWarningHeadingText: 'Advertencia de fotosensibilidad',
// photosensitivyWarningBodyText:
// 'Esta verificación muestra luces de colores. Tenga cuidado si es fotosensible.',
// instructionListHeadingText:
// 'Siga las instrucciones para completar la verificación:',
// goodFitCaptionText: 'Buen ajuste',
// tooFarCaptionText: 'Demasiado lejos',
// },
// };

return (
<ThemeProvider>
{loading ? (
<Loader />
) : (
<FaceLivenessDetector
sessionId={sessionId}
region="us-east-1"
onAnalysisComplete={handleAnalysisComplete}
disableInstructionScreen={true}
<>
{error &&
<AlertErrorMessage
type="info"
message="No se ha podido validar correctamente la identidad."
/>
)}
</ThemeProvider>
}
<br />
<ThemeProvider>
{loading ? (
<LoadingProgress />
) : (
<FaceLivenessDetector
sessionId={sessionId}
region="us-east-1"
onAnalysisComplete={handleAnalysisComplete}
disableInstructionScreen={true}
displayText={defaultLivenessDisplayText}
// components={{
// Header: () => {
// return (
// <>
// asd
// </>
// // <View flex="1">
// // <Heading>asd</Heading>
// // <Text>
// // Yasdasd
// // </Text>
// // </View>
// );
// },
// PhotosensitiveWarning: (): JSX.Element => {
// return (
// <>
// asd
// </>
// // <Alert
// // variation="warning"
// // isDismissible={false}
// // hasIcon={true}
// // heading="Caution"
// // >
// // asdasd
// // </Alert>
// );
// },
// Instructions: (): JSX.Element => {
// return (
// <>
// asd
// </>
// // <Card variation="elevated">
// // asdasd
// // <ol>
// // <li>
// // asdasdasdmask.
// // </li>
// // <li>
// // Moasdasdas
// // </li>
// // <li>
// // Fill oasdasdasdasdasdold for colored lights.
// // </li>
// // </ol>
// // </Card>
// );
// },
// ErrorView: ({ children } : any) => {
// return (
// <>
// <br />
// <AlertErrorMessage
// message="Comprobación fallida durante la cuenta atrás"
// type="error"
// />
// {/* <View flex="1" backgroundColor="white">
// <Heading color="black">adasdsd</Heading>
// {children}
// asdsd
// </View> */}
// </>
// );
// },
// }}
/>
)}
</ThemeProvider>
</>
);
}
19 changes: 14 additions & 5 deletions src/components/elements/alert/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import Swal from "sweetalert2";
import Alert from '@mui/material/Alert';

interface IProps {
interface IPropsAlertErrorMessage {
message: string;
type: "error" | "warning" | "info" | "success"
}
interface IProps {
text?: string;
}

export const AlertError = (text?: string) => {
export const AlertErrorMessage = ({message, type}: IPropsAlertErrorMessage) => (
<Alert severity={type}>{message}</Alert>
)

export const AlertError = (text?: string) => {
return Swal.fire({
icon: "error",
title: "Error",
text: text ? text : "Ocurrió un error al procesar la solicitud",
confirmButtonColor: "#002D62",
confirmButtonColor: "#003670",
});
};

Expand All @@ -18,7 +27,7 @@ export const AlertWarning = (text: string) => {
icon: "warning",
title: "Aviso",
text: text,
confirmButtonColor: "#002D62",
confirmButtonColor: "#003670",
});
};

Expand All @@ -27,6 +36,6 @@ export const AlertSuccess = (text?: string) => {
icon: "success",
title: "Correcto",
text: text ? text : "Proceso realizado correctamente",
confirmButtonColor: "#002D62",
confirmButtonColor: "#003670",
});
};
2 changes: 1 addition & 1 deletion src/components/elements/boxContentCenter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function BoxContentCenter({ children }: any) {
<Box
sx={{
width: "100%",
height: `calc(100vh - 134px)`,
height: `calc(100vh - 199px)`,
display: "flex",
justifyContent: "center",
alignItems: "center",
Expand Down
1 change: 1 addition & 0 deletions src/components/elements/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const ButtonApp = ({
fontWeight: `${outlined ? "bold" : "normal"}`,
borderRadius: "50px",
padding: "10px 0px",
height: "60px",
}}
startIcon={startIcon}
>
Expand Down
4 changes: 3 additions & 1 deletion src/components/elements/cardAuth/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const CardAuth = ({
children,
lading,
ladingWidth,
ladingHeight,
icon,
}: any) => {
return (
Expand All @@ -24,6 +25,7 @@ export const CardAuth = ({
src={lading?.src}
alt="Lading"
width={ladingWidth ? ladingWidth : "500"}
height={ladingHeight ? ladingHeight : "500"}
/>
</div>
)}
Expand All @@ -44,7 +46,7 @@ export const CardAuth = ({
}}
>
<div style={{ marginRight: "15px", marginTop: "-3px" }}>
<Image src={LogoDedo.src} alt="Logo" width="40" height="20" />
<Image src={LogoDedo.src} alt="Logo" width="40" height="40" />
</div>
<Typography
color="primary"
Expand Down
10 changes: 10 additions & 0 deletions src/components/elements/loading/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import CircularProgress from '@mui/material/CircularProgress';
import Box from '@mui/material/Box';

export const LoadingProgress = () => {
return (
<Box sx={{ display: 'flex', justifyContent: 'center' }}>
<CircularProgress color='info' />
</Box>
);
}
Loading

0 comments on commit 76776c7

Please sign in to comment.