From 2676c6d71da6a79921237c20fd0a3553758d21f8 Mon Sep 17 00:00:00 2001 From: arnauZap <114933020+arnauZap@users.noreply.github.com> Date: Mon, 6 Feb 2023 23:34:27 +0100 Subject: [PATCH] [AD20036-82] Feature/text validation (#8) * update text validation * update url * update changelog * fix success params * update url --------- Co-authored-by: Arnau Zapata Delgado --- CHANGELOG.md | 1 + next.config.js | 11 ++++++++++- src/pages/index.tsx | 10 +++------- src/pages/success.tsx | 17 +++++++---------- src/pages/validateQR/index.tsx | 12 ++++++++---- src/services/ApiClient.ts | 3 +-- 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 909d562..0e3bfea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- [[Valida.one] Actualizar texto validación](https://wealize.atlassian.net/browse/AD20036-82) - [[Valida.one] Validación a través de un QR y Incluir lógica de verificación de Izertis](https://wealize.atlassian.net/browse/AD20036-67) ### Add diff --git a/next.config.js b/next.config.js index 963c605..6435bc0 100644 --- a/next.config.js +++ b/next.config.js @@ -1,9 +1,18 @@ if (process.env.NODE_ENV !== 'production') { require('dotenv').config() } +const getAllAllowedEnvironmentVariables = () => { + return Object.entries(process.env).reduce( + (vars, [name, value]) => + /^(?:__|NODE_)/.test(name) ? vars : { ...vars, [name]: value }, + {} + ) +} const nextConfig = { - env: {} + env: { + ...getAllAllowedEnvironmentVariables() + } } module.exports = nextConfig diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 244631e..bd38540 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -33,14 +33,10 @@ const FileVerification: NextPage<{}> = () => { const uploadFile = async () => { setIsProcessingRequest(true) try { - const { error, message, hash, url }: any = await ApiClient.verifyFile( - uploadedFile - ) + const { error, message, hash, url, timestamp }: any = + await ApiClient.verifyFile(uploadedFile) if (message == 'OK') { - router.push( - `/success?timestamp=${url}&url=${url}`, - '/success' - ) + router.push(`/success?timestamp=${timestamp}&url=${url}&hash=${hash}`, '/success') } else { router.push('/error?error=' + error) } diff --git a/src/pages/success.tsx b/src/pages/success.tsx index 0dc3771..2cf4312 100644 --- a/src/pages/success.tsx +++ b/src/pages/success.tsx @@ -13,8 +13,9 @@ import { Title } from '../components/atomic_components/Text/variants' const SuccessPage = () => { const router = useRouter() - const timestamp = parseInt(router.query.timestamp as string) + const timestamp = router.query.timestamp as string const url = router.query.url as string + const hash = router.query.hash as string return (
@@ -38,19 +39,15 @@ const SuccessPage = () => { > - El proceso ha sido llevado cabo con éxito.
+ El proceso ha sido llevado a cabo con éxito.
Tu documento corresponde con una notarización en la RedT de - Alastria - {/* con fecha del{' '} - {moment.unix(timestamp).format('DD/MM/YYYY - HH:mm:ss')} */} + Alastria con fecha{' '} + {moment(timestamp).format('DD/MM/YYYY - HH:mm:ss')} con el + identificador {hash}
Si deseas conocer más detalles técnicos acerca de tu documento en blockchain visita el siguiente enlace de{' '} - + Alastria Telsius Explorer.
diff --git a/src/pages/validateQR/index.tsx b/src/pages/validateQR/index.tsx index 4f6c9c1..d32142b 100644 --- a/src/pages/validateQR/index.tsx +++ b/src/pages/validateQR/index.tsx @@ -15,7 +15,12 @@ import { } from '../../components/PrimaryButton' import { NotificationContainer, NotificationManager } from 'react-notifications' import 'react-notifications/lib/notifications.css' -import { IndexContainer, IndexParagraph, IndexSendContainer, IndexTitle } from './style' +import { + IndexContainer, + IndexTitle, + IndexParagraph, + IndexSendContainer +} from './style' const ValidateQR: NextPage<{}> = () => { const [uploadedFile, setUploadedFile] = useState() @@ -85,10 +90,10 @@ const ValidateQR: NextPage<{}> = () => { return } const responseVerifyFile: any = await ApiClient.verifyFile(file) - const { error, message, hash, url }: any = responseVerifyFile + const { error, message, hash, url, timestamp }: any = responseVerifyFile if (message == 'OK') { router.push( - `/success?uuid=${uuid}&url=${url}`, + `/success?timestamp=${timestamp}&url=${url}&hash=${hash}`, '/success' ) } else { @@ -192,5 +197,4 @@ const ValidateQR: NextPage<{}> = () => { return isProcessingRequest ? renderLoadingView() : renderUploadFileView() } - export default ValidateQR diff --git a/src/services/ApiClient.ts b/src/services/ApiClient.ts index 629c8d7..f708129 100644 --- a/src/services/ApiClient.ts +++ b/src/services/ApiClient.ts @@ -1,7 +1,6 @@ import axios from 'axios' export default class ApiClient { - private static API_NODE = - 'https://certificatio-feat-uuidf-trhwrd.herokuapp.com/api' + private static API_NODE = process.env.CERTIFICATION_URL; static API_NAMES = { UUID: `/uuid`, VERIFY: `/certifications/verify`