From 065b80234405da370d760f7d9711a4bc6a0a10ea Mon Sep 17 00:00:00 2001 From: seriouselly Date: Fri, 5 Jun 2026 19:01:48 +0700 Subject: [PATCH] fix(scan-page): implement upload button workflow - Add conditional button behavior based on file selection state - Before file selected: button opens file picker - After file selected: button triggers file upload to API - Show "Mengunggah..." text and disable button during upload - Display error messages below button when upload fails This fixes the issue where users could select files but had no way to submit them for analysis. --- apps/web/src/app.tsx | 42 ++++++--------- apps/web/src/main.tsx | 2 +- apps/web/src/pages/catalog-page.tsx | 1 - apps/web/src/pages/scan-page.tsx | 81 +++++++++++++++-------------- 4 files changed, 59 insertions(+), 67 deletions(-) diff --git a/apps/web/src/app.tsx b/apps/web/src/app.tsx index 4a4f7b3..05b7ebd 100644 --- a/apps/web/src/app.tsx +++ b/apps/web/src/app.tsx @@ -21,57 +21,47 @@ import { MainLayout } from "@/components/layout/main-layout"; const queryClient = new QueryClient(); const router = createBrowserRouter([ - { path: "/", element: }, + { path: "/", element: }, { path: "/login", element: }, { path: "/register", element: }, { path: "/dashboard", element: ( - - - - - + + + ), }, { path: "/scan", element: ( - - - - - + + + ), }, { path: "/library", element: ( - - - - - + + + ), }, { path: "/diagnoses", element: ( - - - - - + + + ), }, { path: "/diagnoses/:id", element: ( - - - - - + + + ), }, { diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx index 81819a4..b2bc486 100644 --- a/apps/web/src/main.tsx +++ b/apps/web/src/main.tsx @@ -1,6 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; -import { App } from './app'; +import { App } from './App'; import './index.css'; ReactDOM.createRoot(document.getElementById('root')!).render( diff --git a/apps/web/src/pages/catalog-page.tsx b/apps/web/src/pages/catalog-page.tsx index 82f6b4c..e9ff9e0 100644 --- a/apps/web/src/pages/catalog-page.tsx +++ b/apps/web/src/pages/catalog-page.tsx @@ -3,7 +3,6 @@ import { useQuery } from '@tanstack/react-query'; import { Link, useSearchParams } from 'react-router-dom'; import { AlertCircle } from 'lucide-react'; import type { RiskLevel } from '@zeavis/shared'; -import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; import { RiskBadge } from '@/components/risk-badge'; import { apiClient } from '@/lib/api-client'; diff --git a/apps/web/src/pages/scan-page.tsx b/apps/web/src/pages/scan-page.tsx index 953156f..9765a18 100644 --- a/apps/web/src/pages/scan-page.tsx +++ b/apps/web/src/pages/scan-page.tsx @@ -2,7 +2,6 @@ import { useRef, useState } from "react"; import { useNavigate, Link } from "react-router-dom"; import { useMutation, useQueryClient, useQuery } from "@tanstack/react-query"; import { Button } from "@/components/ui/button"; -import { Card, CardContent } from "@/components/ui/card"; import { Modal } from "@/components/ui/modal"; import { DiagnosisStatusBadge } from "@/components/diagnosis-status-badge"; import type { DiagnosisRecord } from "@zeavis/shared"; @@ -117,7 +116,7 @@ export function ScanPage() { {/* Header */}

Scan Tanaman

-

+

Unggah foto daun jagung untuk dianalisis oleh sistem AI kami secara real-time.

@@ -132,6 +131,7 @@ export function ScanPage() { Area Unggah Gambar
+ {/* Upload Area */} - {mutation.isPending && ( -
- Mengunggah... -
+ {!previewUrl ? ( + + ) : ( + )} {mutation.isError && (
@@ -390,36 +395,34 @@ export function ScanPage() { )} {!diagnosesQuery.isLoading && !diagnosesQuery.isError && (
- {(diagnosesQuery.data ?? []) - .slice(0, 5) - .map((d) => ( -
-
- thumb -
-
- {d.disease?.commonName ?? "Unknown"} -
-
- {new Date(d.createdAt).toLocaleString("id-ID")} -
+ {(diagnosesQuery.data ?? []).slice(0, 5).map((d) => ( +
+
+ thumb +
+
+ {d.disease?.commonName ?? "Unknown"} +
+
+ {new Date(d.createdAt).toLocaleString("id-ID")}
- - Lihat -
- ))} + + Lihat + +
+ ))}
)}