Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import clsx from "clsx";
import { ff } from "@humansignal/core";
import { usePersistentState } from "@humansignal/core/lib/hooks/usePersistentState";
import type { MSTAnnotation, MSTStore } from "../../stores/types";
import TaskSummary from "../TaskSummary/TaskSummary";
import Grid from "./Grid";
 
import styles from "./ViewAll.module.scss";
 
type Props = {
  store: MSTStore["annotationStore"];
  annotations: MSTAnnotation[];
  root: any;
};
 
const Tab = ({ title, active, onSelect }: { title: string; active: boolean; onSelect: () => void }) => {
  return (
    <div className={clsx(styles.tab, { [styles.active]: active })} onClick={onSelect}>
      {title}
    </div>
  );
};
 
export const ViewAll = ({ store: annotationStore, annotations, root }: Props) => {
  const [tab, setTab] = usePersistentState<"summary" | "compare">("view-all-tab", "summary");
 
  if (annotationStore.store.hasInterface("annotations:summary") && ff.isActive(ff.FF_SUMMARY)) {
    return (
      <div>
        <div className={styles.tabs}>
          <Tab title="Summary" active={tab === "summary"} onSelect={() => setTab("summary")} />
          <Tab title="Compare" active={tab === "compare"} onSelect={() => setTab("compare")} />
        </div>
        {tab === "summary" && (
          <div>
            <TaskSummary store={annotationStore} annotations={annotations} />
          </div>
        )}
        {tab === "compare" && (
          <div>
            <Grid store={annotationStore} annotations={annotations} root={root} />
          </div>
        )}
      </div>
    );
  }
 
  return <Grid store={annotationStore} annotations={annotations} root={root} />;
};