From b6dd29161dae8bedecf67ffe3d07514907f6ce22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Lopes?= <1211289@isep.ipp.pt> Date: Mon, 25 Nov 2024 22:35:04 +0000 Subject: [PATCH] fix: fixed action qr code --- next.config.js | 2 +- src/app/(admin)/actions/page.tsx | 28 +++++++++++-------- .../Action/ActionQrCodeData/index.tsx | 2 +- .../QRCode/QRCodeTab/ScanTab/index.tsx | 9 +++++- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/next.config.js b/next.config.js index 57b6581..2b16e10 100644 --- a/next.config.js +++ b/next.config.js @@ -4,7 +4,7 @@ const nextConfig = { remotePatterns: [ { protocol: "https", - hostname: "*.storage.googleapis.com", + hostname: "*.storage.googleapis.com/**", }, { protocol: "https", diff --git a/src/app/(admin)/actions/page.tsx b/src/app/(admin)/actions/page.tsx index f376b6c..2fc429f 100644 --- a/src/app/(admin)/actions/page.tsx +++ b/src/app/(admin)/actions/page.tsx @@ -18,12 +18,12 @@ const actions: React.FC = async () => { - - - - - - + + + + + + @@ -32,12 +32,16 @@ const actions: React.FC = async () => { key={action.id} className="border-b transition-colors hover:bg-gray-100" > - - - - - - + + + + +
NamePointsAlt TextLiveVisibleActionNamePointsAlt TextLiveVisibleAction
{action.name}{action.points}{action.altText || "N/A"}{action.isLive ? "Yes" : "No"}{action.isVisible ? "Yes" : "No"} + {action.name}{action.points}{action.altText || "N/A"} + {action.isLive ? "Yes" : "No"} + + {action.isVisible ? "Yes" : "No"} + = ({ id }) => { }, [id]); return ( -
+
{qrCodeData && ( = ({ setHidden }) => { async function handleActionScan(data: string) { const actionId = data.split("-")[1]; - await fetch(BASE_URL + `/actions/${actionId}`, { + const res = await fetch(BASE_URL + `/actions/${actionId}`, { method: "POST", body: JSON.stringify({ data }), }); + if (!res.ok) { + swal("Erro", "Ocorreu um erro a dar scan no QR Code da ação...", "error"); + return; + } + + swal("Sucesso", "Os teus pontos foram adicionados com sucesso!", "success"); + setHidden(true); setProcessing(false); }