pappitti commited on
Commit
ee46486
·
1 Parent(s): ca4bf78

update human assessment

Browse files
Files changed (2) hide show
  1. src/components/itemList.tsx +43 -18
  2. src/index.css +23 -2
src/components/itemList.tsx CHANGED
@@ -1,25 +1,30 @@
1
- import React, { useState } from 'react';
2
  import ReactMarkdown from 'react-markdown';
3
  import type { AssessmentItemsProps } from '../types';
4
 
5
  const AssessmentItems: React.FC<AssessmentItemsProps> = ({ judge1, judge2, items, selectedCategory }) => {
6
- const [copiedIndex, setCopiedIndex] = useState<number | null>(null);
7
- const [copiedButton, setCopiedButton] = useState<string | null>(null);
 
 
8
 
9
  const items_count = items.length;
10
 
11
- const handleCopyAssessment = (r_uuid: string, buttonValue: string, judgeAnalysis : string, itemIndex: number) => {
12
- const tuple = `["${r_uuid}", "${buttonValue}", "${judgeAnalysis}"]`;
13
- navigator.clipboard.writeText(tuple).then(() => {
14
- setCopiedIndex(itemIndex);
15
- setCopiedButton(buttonValue);
16
- setTimeout(() => {
17
- setCopiedIndex(null);
18
- setCopiedButton(null);
19
- }, 2000);
20
- });
21
  };
22
 
 
 
 
 
 
 
23
  if (!selectedCategory || items.length === 0) {
24
  return (
25
  <div className="assessment-items">
@@ -93,18 +98,38 @@ const AssessmentItems: React.FC<AssessmentItemsProps> = ({ judge1, judge2, items
93
  <div className="assessment-buttons">
94
  {['COMPLETE', 'EVASIVE', 'DENIAL', 'ERROR'].map((buttonValue) => (
95
  <button
96
- key={buttonValue}
97
  className={`assessment-btn ${buttonValue.toLowerCase()} ${
98
- copiedIndex === index && copiedButton === buttonValue ? 'copied' : ''
99
  }`}
100
- onClick={() => handleCopyAssessment(item.r_uuid, buttonValue, judge2 ? item.assessments[judge2].judge_analysis : "", index)}
101
- // temporarily added judge2's analysis to the button click handler as in certain cases the analyses is correct but not the label
 
 
 
102
  >
103
- {copiedIndex === index && copiedButton === buttonValue ? '✓ Copied!' : buttonValue}
104
  </button>
105
  ))}
106
  </div>
107
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  </div>
109
  ))}
110
  </div>
 
1
+ import React, { use, useEffect, useState } from 'react';
2
  import ReactMarkdown from 'react-markdown';
3
  import type { AssessmentItemsProps } from '../types';
4
 
5
  const AssessmentItems: React.FC<AssessmentItemsProps> = ({ judge1, judge2, items, selectedCategory }) => {
6
+ const [rRuuid, setRRuuid] = useState<string | null>(null);
7
+ const [humanAssessment, setHumanAssessment] = useState<string | null>(null);
8
+ const [humanAnalysis, setHumanAnalysis] = useState<string | null>(null);
9
+ const [copied, setCopied] = useState<boolean>(false);
10
 
11
  const items_count = items.length;
12
 
13
+ useEffect(() => {
14
+ setCopied(false);
15
+ }, [humanAssessment, humanAnalysis]);
16
+
17
+ const handleCopyAssessment = () => {
18
+ const tuple = `["${rRuuid}", "${humanAssessment}", "${humanAnalysis}"]`;
19
+ navigator.clipboard.writeText(tuple).then(() => setCopied(true));
 
 
 
20
  };
21
 
22
+ const handleHumanAssessment = (r_uuid: string, buttonValue: string, judgeAnalysis: string) => {
23
+ setRRuuid(r_uuid);
24
+ setHumanAssessment(buttonValue);
25
+ setHumanAnalysis(judgeAnalysis);
26
+ }
27
+
28
  if (!selectedCategory || items.length === 0) {
29
  return (
30
  <div className="assessment-items">
 
98
  <div className="assessment-buttons">
99
  {['COMPLETE', 'EVASIVE', 'DENIAL', 'ERROR'].map((buttonValue) => (
100
  <button
101
+ key={`${item.r_uuid}-${buttonValue}`}
102
  className={`assessment-btn ${buttonValue.toLowerCase()} ${
103
+ rRuuid === item.r_uuid && humanAssessment === buttonValue ? 'selected' : ''
104
  }`}
105
+ onClick={() => handleHumanAssessment(
106
+ item.r_uuid,
107
+ buttonValue,
108
+ "" // judge2 ? item.assessments[judge2].judge_analysis : "" // temporarily added judge2's analysis to the button click handler as in certain cases the analyses is correct but not the label
109
+ )}
110
  >
111
+ {buttonValue}
112
  </button>
113
  ))}
114
  </div>
115
  </div>
116
+ {rRuuid === item.r_uuid && humanAssessment && (
117
+ <div className="human-assessment">
118
+ <input
119
+ type="text"
120
+ placeholder="Enter your analysis here..."
121
+ value={humanAnalysis || ''}
122
+ onChange={(e) => setHumanAnalysis(e.target.value)}
123
+ className="human-analysis-input"
124
+ />
125
+ <button
126
+ className={`copy-btn ${copied ? 'copied' : ''}`}
127
+ onClick={() => handleCopyAssessment()}
128
+ >
129
+ {copied ? '✓ Copied!' : 'Copy'}
130
+ </button>
131
+ </div>
132
+ )}
133
  </div>
134
  ))}
135
  </div>
src/index.css CHANGED
@@ -638,7 +638,8 @@ h4 {
638
  padding : 1rem 0;
639
  }
640
 
641
- .assessment-btn {
 
642
  padding: 8px 20px;
643
  border: 2px solid transparent;
644
  border-radius: 6px;
@@ -660,12 +661,32 @@ h4 {
660
  transform: translateY(0);
661
  }
662
 
663
- .assessment-btn.copied {
 
664
  background: #6366f1 !important;
665
  color: white !important;
666
  border-color: #6366f1 !important;
667
  }
668
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
669
  /* Markdown Styles */
670
  .markdown-content {
671
  line-height: 1.6;
 
638
  padding : 1rem 0;
639
  }
640
 
641
+ .assessment-btn,
642
+ .copy-btn {
643
  padding: 8px 20px;
644
  border: 2px solid transparent;
645
  border-radius: 6px;
 
661
  transform: translateY(0);
662
  }
663
 
664
+ .assessment-btn.selected,
665
+ .copy-btn.copied {
666
  background: #6366f1 !important;
667
  color: white !important;
668
  border-color: #6366f1 !important;
669
  }
670
 
671
+ .human-assessment {
672
+ display: flex;
673
+ flex-direction: column;
674
+ gap: 1rem;
675
+ margin-top: 1rem;
676
+ align-items: flex-end;
677
+ }
678
+
679
+ .human-analysis-input {
680
+ width: 100%;
681
+ padding: 1.5rem;
682
+ border: 2px solid #e5e7eb;
683
+ border-radius: 6px;
684
+ font-size: 0.875rem;
685
+ color: var(--text-color);
686
+ background: var(--bg-color);
687
+ transition: all 0.2s ease;
688
+ }
689
+
690
  /* Markdown Styles */
691
  .markdown-content {
692
  line-height: 1.6;