raidAthmaneBenlala commited on
Commit
56c8666
·
1 Parent(s): 9d8ec5b

feat: no default task/version selected on startup, button guides user to pick mode

Browse files
Files changed (1) hide show
  1. toothmap_frontend/src/App.jsx +14 -8
toothmap_frontend/src/App.jsx CHANGED
@@ -188,10 +188,10 @@ export default function App() {
188
  const [file, setFile] = useState(null);
189
  const [imagePreview, setImagePreview] = useState(null);
190
 
191
- // Tasks: 'diagnostic', 'segmentation', 'charting'
192
- const [task, setTask] = useState('charting');
193
- // Versions: 'v1' (YOLO), 'v2' (FasterRCNN)
194
- const [version, setVersion] = useState('v1');
195
 
196
  const [pipelineResults, setPipelineResults] = useState(null);
197
  const [rawBoxes, setRawBoxes] = useState(null);
@@ -201,6 +201,7 @@ export default function App() {
201
  const canvasRef = useRef(null);
202
 
203
  const modeStr = (() => {
 
204
  if (task === 'diagnostic') return version === 'v1' ? 'yolo' : 'frcnn';
205
  if (task === 'segmentation') return version === 'v1' ? 'seg_yolo' : 'seg_frcnn';
206
  if (task === 'charting') return version === 'v1' ? 'pipeline_yolo' : 'pipeline_frcnn';
@@ -217,7 +218,7 @@ export default function App() {
217
  };
218
 
219
  const handleAPI = async () => {
220
- if (!file) return;
221
  setLoading(true);
222
  setPipelineResults(null); setRawBoxes(null); setMaskSrc(null);
223
  const fd = new FormData();
@@ -421,9 +422,9 @@ export default function App() {
421
  {/* Analyze Button */}
422
  <button
423
  onClick={handleAPI}
424
- disabled={!file || loading}
425
  className={`w-full py-2.5 rounded-xl font-bold text-[13px] flex items-center justify-center gap-2 transition-all duration-200 shadow-md ${
426
- !file
427
  ? 'bg-[#1a1a1f] text-zinc-600 border border-white/5 cursor-not-allowed'
428
  : loading
429
  ? 'bg-blue-700 text-white cursor-wait'
@@ -431,7 +432,12 @@ export default function App() {
431
  }`}
432
  >
433
  {loading ? <Loader2 size={16} className="animate-spin" /> : <ScanLine size={16} />}
434
- {loading ? 'Analyse en cours…' : `Lancer l'analyse IA — ${task === 'diagnostic' ? 'Détection' : task === 'segmentation' ? 'Segmentation' : 'Analyse complète'}`}
 
 
 
 
 
435
  </button>
436
 
437
  {/* Stats Row */}
 
188
  const [file, setFile] = useState(null);
189
  const [imagePreview, setImagePreview] = useState(null);
190
 
191
+ // Tasks: 'diagnostic', 'segmentation', 'charting' — null = nothing selected
192
+ const [task, setTask] = useState(null);
193
+ // Versions: 'v1' (YOLO), 'v2' (FasterRCNN) — null = nothing selected
194
+ const [version, setVersion] = useState(null);
195
 
196
  const [pipelineResults, setPipelineResults] = useState(null);
197
  const [rawBoxes, setRawBoxes] = useState(null);
 
201
  const canvasRef = useRef(null);
202
 
203
  const modeStr = (() => {
204
+ if (!task || !version) return null;
205
  if (task === 'diagnostic') return version === 'v1' ? 'yolo' : 'frcnn';
206
  if (task === 'segmentation') return version === 'v1' ? 'seg_yolo' : 'seg_frcnn';
207
  if (task === 'charting') return version === 'v1' ? 'pipeline_yolo' : 'pipeline_frcnn';
 
218
  };
219
 
220
  const handleAPI = async () => {
221
+ if (!file || !modeStr) return;
222
  setLoading(true);
223
  setPipelineResults(null); setRawBoxes(null); setMaskSrc(null);
224
  const fd = new FormData();
 
422
  {/* Analyze Button */}
423
  <button
424
  onClick={handleAPI}
425
+ disabled={!file || !task || !version || loading}
426
  className={`w-full py-2.5 rounded-xl font-bold text-[13px] flex items-center justify-center gap-2 transition-all duration-200 shadow-md ${
427
+ !file || !task || !version
428
  ? 'bg-[#1a1a1f] text-zinc-600 border border-white/5 cursor-not-allowed'
429
  : loading
430
  ? 'bg-blue-700 text-white cursor-wait'
 
432
  }`}
433
  >
434
  {loading ? <Loader2 size={16} className="animate-spin" /> : <ScanLine size={16} />}
435
+ {loading
436
+ ? 'Analyse en cours…'
437
+ : !task || !version
438
+ ? 'Sélectionnez un mode et une version'
439
+ : `Lancer l'analyse IA — ${task === 'diagnostic' ? 'Détection' : task === 'segmentation' ? 'Segmentation' : 'Analyse complète'}`
440
+ }
441
  </button>
442
 
443
  {/* Stats Row */}