summaryrefslogtreecommitdiff
path: root/makima/frontend/src/components/SupervisorQuestionNotification.tsx
blob: b1cbacc683930dff817365cfbabd1fb45e9e233c (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
import { useNavigate } from "react-router";
import { useSupervisorQuestions } from "../contexts/SupervisorQuestionsContext";

export function SupervisorQuestionNotification() {
  const navigate = useNavigate();
  const { notificationQuestions, dismissNotification } = useSupervisorQuestions();

  // Filter out contract_complete questions - they are displayed on the task page instead
  const filteredQuestions = notificationQuestions.filter(
    (q) => q.questionType !== "contract_complete"
  );

  if (filteredQuestions.length === 0) {
    return null;
  }

  const handleGoToTask = (questionId: string, taskId: string) => {
    dismissNotification(questionId);
    navigate(`/mesh/${taskId}`);
  };

  return (
    <div className="fixed bottom-4 right-4 z-50 max-w-md space-y-2">
      {filteredQuestions.map((question) => (
        <div
          key={question.questionId}
          className="bg-[#0d1b2d] border border-amber-500/50 rounded-lg shadow-lg overflow-hidden"
        >
          {/* Header */}
          <div className="flex items-center justify-between px-4 py-3 bg-amber-900/30">
            <div className="flex items-center gap-2">
              <span className="text-amber-400 text-lg">?</span>
              <span className="font-mono text-sm text-amber-300 uppercase">
                Task needs input
              </span>
            </div>
            <button
              onClick={() => handleGoToTask(question.questionId, question.taskId)}
              className="px-3 py-1 font-mono text-xs text-amber-400 border border-amber-500/30 hover:border-amber-400/50 hover:bg-amber-900/20 transition-colors uppercase"
            >
              View Task
            </button>
          </div>

          {/* Question preview */}
          <div className="px-4 py-3">
            {question.context && (
              <div className="text-xs text-[#8b949e] font-mono mb-1 uppercase">
                {question.context}
              </div>
            )}
            <p className="text-sm text-[#dbe7ff] font-mono line-clamp-2">
              {question.question}
            </p>
          </div>
        </div>
      ))}
    </div>
  );
}