From 1b7c9591cad85427b49a2772a7698792715e950e Mon Sep 17 00:00:00 2001 From: Araozu Date: Tue, 21 Nov 2023 14:35:23 -0500 Subject: [PATCH] [FE][Scans] Show message when conversion is successful --- frontend/src/Scans/ScansList.tsx | 14 +++++++++--- frontend/src/Scans/index.tsx | 38 ++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/frontend/src/Scans/ScansList.tsx b/frontend/src/Scans/ScansList.tsx index 6901c18..72f60fe 100644 --- a/frontend/src/Scans/ScansList.tsx +++ b/frontend/src/Scans/ScansList.tsx @@ -7,7 +7,7 @@ import { PDFIcon } from "../icons/PDFIcon"; import { LoadingStatus, useLoading } from "../utils/functions"; import { QuestionIcon } from "../icons/QuestionIcon"; -export function ScansList(props: {scanData: Array | null}) { +export function ScansList(props: {scanData: Array | null, onSuccess: () => void}) { const {status, setStatus, error, setError} = useLoading(); const loading = createMemo(() => status() === LoadingStatus.Loading); @@ -56,9 +56,9 @@ export function ScansList(props: {scanData: Array | null}) { }, ) .then((res) => res.json()) - .then((res) => { + .then(() => { setStatus(LoadingStatus.Ok); - console.log(res); + props.onSuccess(); }) .catch((err) => { setStatus(LoadingStatus.Error); @@ -155,6 +155,14 @@ export function ScansList(props: {scanData: Array | null}) { + + +
+

+ Error convirtiendo PDFs: {error()} +

+
+
diff --git a/frontend/src/Scans/index.tsx b/frontend/src/Scans/index.tsx index f0e5e71..3e6374d 100644 --- a/frontend/src/Scans/index.tsx +++ b/frontend/src/Scans/index.tsx @@ -1,4 +1,4 @@ -import { createMemo, createSignal } from "solid-js"; +import { Show, createMemo, createSignal } from "solid-js"; import { FilledButton } from "../components/FilledButton"; import { FilledCard } from "../components/FilledCard"; import { LoadingIcon } from "../icons/LoadingIcon"; @@ -15,22 +15,24 @@ export interface ScanData { } export type ScanResult = -| {Full: [string, number, string]} -| {Partial: [string, string]} -| {Empty: string} -| {Error: string}; + | { Full: [string, number, string] } + | { Partial: [string, string] } + | { Empty: string } + | { Error: string }; export function Scans() { - const {status, setStatus, error, setError} = useLoading(); + const { status, setStatus, error, setError } = useLoading(); const [scanData, setScanData] = createSignal | null>(null); + const [converted, setConverted] = createSignal(false); const loading = createMemo(() => status() === LoadingStatus.Loading); const detectScans = () => { setStatus(LoadingStatus.Loading); setScanData(null); + setConverted(false); fetch(`${import.meta.env.VITE_BACKEND_URL}/api/scans/detect`) .then((res) => res.json()) @@ -146,7 +148,7 @@ export function Scans() { > + + +

+ Error detectando escaneos: {error()} +

+
- + { + setConverted(true); + setScanData(null); + }} + /> + + + +

+ Archivos convertidos con éxito +

+
+
);