SGTLIM commited on
Commit
e0beff3
·
1 Parent(s): ea889c4

Fix returning annotator training skip

Browse files
Files changed (1) hide show
  1. frontend/src/pages/GuidelinePage.jsx +12 -15
frontend/src/pages/GuidelinePage.jsx CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import React, { useEffect, useState } from "react";
3
  import GuidelineContent from "./GuidelineContent";
4
 
@@ -11,12 +10,6 @@ export default function GuidelinePage({
11
  onLookupResult
12
  }) {
13
  const nameIsValid = annotatorName.trim().length > 0;
14
-
15
- // Lightweight name-collision guard: there's no login, so two different
16
- // people could type the same name and accidentally share an assignment.
17
- // This is advisory only (a self-reported checkbox), not proof of identity
18
- // - see GET /assignment/lookup, which never creates anything, just reports
19
- // whether a name is already in use.
20
  const [collisionInfo, setCollisionInfo] = useState(null);
21
  const [collisionAcknowledged, setCollisionAcknowledged] = useState(false);
22
 
@@ -24,27 +17,31 @@ export default function GuidelinePage({
24
  setCollisionAcknowledged(false);
25
 
26
  const name = annotatorName.trim();
27
- if (!name || !apiBaseUrl) {
28
  setCollisionInfo(null);
 
29
  return undefined;
30
  }
31
 
32
  let cancelled = false;
33
  const timer = setTimeout(() => {
34
- fetch(`${apiBaseUrl}/assignment/lookup?annotator=${encodeURIComponent(name)}`)
 
 
 
35
  .then((res) => (res.ok ? res.json() : { exists: false }))
36
  .then((data) => {
37
  if (cancelled) return;
38
  setCollisionInfo(data.exists ? data : null);
39
- // A round only ever exists for a name that already passed
40
- // training (see App.jsx's handleGuidelineLookupResult) - reuse
41
- // this same lookup instead of firing a second request just to
42
- // check that.
43
  onLookupResult?.(data);
44
  })
45
  .catch(() => {
46
- // Fail open - this check is advisory, never block name entry on a lookup error.
47
- if (!cancelled) setCollisionInfo(null);
 
 
 
 
48
  });
49
  }, 400);
50
 
 
 
1
  import React, { useEffect, useState } from "react";
2
  import GuidelineContent from "./GuidelineContent";
3
 
 
10
  onLookupResult
11
  }) {
12
  const nameIsValid = annotatorName.trim().length > 0;
 
 
 
 
 
 
13
  const [collisionInfo, setCollisionInfo] = useState(null);
14
  const [collisionAcknowledged, setCollisionAcknowledged] = useState(false);
15
 
 
17
  setCollisionAcknowledged(false);
18
 
19
  const name = annotatorName.trim();
20
+ if (!name) {
21
  setCollisionInfo(null);
22
+ onLookupResult?.({ exists: false });
23
  return undefined;
24
  }
25
 
26
  let cancelled = false;
27
  const timer = setTimeout(() => {
28
+ // In production apiBaseUrl is intentionally an empty string because
29
+ // the frontend and backend share the same origin. An empty base URL
30
+ // must therefore still perform the lookup using the relative route.
31
+ fetch(`${apiBaseUrl || ""}/assignment/lookup?annotator=${encodeURIComponent(name)}`)
32
  .then((res) => (res.ok ? res.json() : { exists: false }))
33
  .then((data) => {
34
  if (cancelled) return;
35
  setCollisionInfo(data.exists ? data : null);
 
 
 
 
36
  onLookupResult?.(data);
37
  })
38
  .catch(() => {
39
+ // Fail open: the collision check is advisory and should not block
40
+ // a new annotator if the lookup endpoint is temporarily unavailable.
41
+ if (!cancelled) {
42
+ setCollisionInfo(null);
43
+ onLookupResult?.({ exists: false });
44
+ }
45
  });
46
  }, 400);
47