Skip to content

Commit

Permalink
[AD20036-82] Feature/text validation (#8)
Browse files Browse the repository at this point in the history
* update text validation

* update url

* update changelog

* fix success params

* update url

---------

Co-authored-by: Arnau Zapata Delgado <azapata@Arnaus-MacBook-Pro.local>
  • Loading branch information
arnauZap and Arnau Zapata Delgado authored Feb 6, 2023
1 parent faf3620 commit 2676c6d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -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
10 changes: 3 additions & 7 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
17 changes: 7 additions & 10 deletions src/pages/success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
Expand All @@ -38,19 +39,15 @@ const SuccessPage = () => {
>
<SuccessParagraph data-cy="first-paragraph">
<Paragraph>
El proceso ha sido llevado cabo con éxito. <br />
El proceso ha sido llevado a cabo con éxito. <br />
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}
<br />
Si deseas conocer más detalles técnicos acerca de tu documento en
blockchain visita el siguiente enlace de{' '}
<a
href={`${url}`}
target="_blank"
rel="noreferrer"
>
<a href={`${url}`} target="_blank" rel="noreferrer">
Alastria Telsius Explorer.
</a>
</Paragraph>
Expand Down
12 changes: 8 additions & 4 deletions src/pages/validateQR/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<File>()
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -192,5 +197,4 @@ const ValidateQR: NextPage<{}> = () => {
return isProcessingRequest ? renderLoadingView() : renderUploadFileView()
}


export default ValidateQR
3 changes: 1 addition & 2 deletions src/services/ApiClient.ts
Original file line number Diff line number Diff line change
@@ -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`
Expand Down

0 comments on commit 2676c6d

Please sign in to comment.