File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import ShowQR from "./pages/ShowQR";
66import ScanQR from "./pages/ScanQR" ;
77import Services from "./pages/Services" ;
88import Domains from "./pages/Domains" ;
9+ // import ScanDone from "./pages/ScanDone";
910
1011function App ( ) {
1112 return (
@@ -19,6 +20,7 @@ function App() {
1920 < Route path = "/scan-qr" element = { < ScanQR /> } />
2021 < Route path = "/services" element = { < Services /> } />
2122 < Route path = "/domains" element = { < Domains /> } />
23+ { /* <Route path="/scan-done" element={<ScanDone />} /> */ }
2224 </ Routes >
2325 </ Router >
2426 </ div >
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ const API_URL = import.meta.env.VITE_API_URL || "http://localhost:8080";
22
33export const validateQrCode = async (
44 validationId : string
5- ) : Promise < boolean > => {
5+ ) : Promise < "valid" | "invalid" | "error" > => {
66 try {
77 const response = await fetch (
88 `${ API_URL } /api/v1/validation/${ validationId } ` ,
@@ -14,21 +14,32 @@ export const validateQrCode = async (
1414 }
1515 ) ;
1616
17- if ( response . status === 200 ) {
18- return true ;
17+ if ( ! response . ok ) {
18+ return "error" ;
1919 }
20- return false ;
20+
21+ let data : unknown ;
22+ try {
23+ data = await response . json ( ) ;
24+ } catch {
25+ return "error" ;
26+ }
27+
28+ const result = ( data as { result ?: string } ) ?. result ?. toUpperCase ( ) ;
29+ if ( result === "VALID" ) return "valid" ;
30+ if ( result === "INVALID" ) return "invalid" ;
31+ return "error" ;
2132 } catch ( error ) {
2233 console . error ( "Validation error:" , error ) ;
23- return false ;
34+ return "error" ;
2435 }
2536} ;
2637
2738export type DomainItem = { id : number ; domain : string } ;
2839
2940export const getDomainList = async ( ) : Promise < DomainItem [ ] > => {
3041 try {
31- const response = await fetch ( `${ API_URL } /domains` , {
42+ const response = await fetch ( `${ API_URL } /api/v1/ domains` , {
3243 method : "GET" ,
3344 headers : {
3445 "Content-Type" : "application/json" ,
You can’t perform that action at this time.
0 commit comments