Spaces:
Running
Running
Avijit Ghosh
commited on
Commit
·
f7c8d87
1
Parent(s):
18e0e98
new cards
Browse files
app/evaluation/[id]/page.client.tsx
CHANGED
|
@@ -89,13 +89,8 @@ export default function EvaluationDetailsPage() {
|
|
| 89 |
const catEval = evaluation?.categoryEvaluations?.[categoryId]
|
| 90 |
if (!catEval) return undefined
|
| 91 |
|
| 92 |
-
//
|
| 93 |
-
|
| 94 |
-
return catEval.additionalAspects
|
| 95 |
-
}
|
| 96 |
-
|
| 97 |
-
// Check processSources and benchmarkSources for explicit scope/description notes
|
| 98 |
-
const checkSources = (sourcesObj: any) => {
|
| 99 |
if (!sourcesObj) return undefined
|
| 100 |
for (const entries of Object.values(sourcesObj)) {
|
| 101 |
if (Array.isArray(entries)) {
|
|
@@ -109,35 +104,49 @@ export default function EvaluationDetailsPage() {
|
|
| 109 |
return undefined
|
| 110 |
}
|
| 111 |
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
for (const k of canonicalKeys) {
|
| 121 |
-
const ans = obj[k]
|
| 122 |
-
if (Array.isArray(ans)) {
|
| 123 |
-
if (!ans.every((a) => String(a).toLowerCase() === "n/a" || /not applicable/i.test(String(a)))) return false
|
| 124 |
-
} else if (ans === undefined || ans === null) {
|
| 125 |
-
// treat missing as NA
|
| 126 |
-
continue
|
| 127 |
-
} else if (String(ans).toLowerCase() === "n/a" || /not applicable/i.test(String(ans))) {
|
| 128 |
-
continue
|
| 129 |
-
} else {
|
| 130 |
-
return false
|
| 131 |
-
}
|
| 132 |
}
|
| 133 |
-
|
|
|
|
| 134 |
}
|
| 135 |
|
| 136 |
const benchmarkQs = BENCHMARK_QUESTIONS.map((q) => q.id)
|
| 137 |
const processQs = PROCESS_QUESTIONS.map((q) => q.id)
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
}
|
| 142 |
|
| 143 |
return undefined
|
|
|
|
| 89 |
const catEval = evaluation?.categoryEvaluations?.[categoryId]
|
| 90 |
if (!catEval) return undefined
|
| 91 |
|
| 92 |
+
// Helper to check sources for explicit NA notes
|
| 93 |
+
const checkSourcesForNA = (sourcesObj: any) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
if (!sourcesObj) return undefined
|
| 95 |
for (const entries of Object.values(sourcesObj)) {
|
| 96 |
if (Array.isArray(entries)) {
|
|
|
|
| 104 |
return undefined
|
| 105 |
}
|
| 106 |
|
| 107 |
+
// If there are any non-NA answers (yes/no or any non 'n/a' text), the category is applicable
|
| 108 |
+
const isNonNAAnswer = (ans: any) => {
|
| 109 |
+
if (ans === undefined || ans === null) return false
|
| 110 |
+
if (Array.isArray(ans)) {
|
| 111 |
+
return ans.some((a) => {
|
| 112 |
+
const s = String(a || "").trim().toLowerCase()
|
| 113 |
+
return s !== "n/a" && !/not applicable/i.test(s) && s.length > 0
|
| 114 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
}
|
| 116 |
+
const s = String(ans).trim().toLowerCase()
|
| 117 |
+
return s !== "n/a" && !/not applicable/i.test(s) && s.length > 0
|
| 118 |
}
|
| 119 |
|
| 120 |
const benchmarkQs = BENCHMARK_QUESTIONS.map((q) => q.id)
|
| 121 |
const processQs = PROCESS_QUESTIONS.map((q) => q.id)
|
| 122 |
|
| 123 |
+
// Check answers for any non-NA content
|
| 124 |
+
let anyNonNA = false
|
| 125 |
+
if (catEval.benchmarkAnswers) {
|
| 126 |
+
for (const k of benchmarkQs) {
|
| 127 |
+
if (isNonNAAnswer(catEval.benchmarkAnswers[k])) {
|
| 128 |
+
anyNonNA = true
|
| 129 |
+
break
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
if (!anyNonNA && catEval.processAnswers) {
|
| 134 |
+
for (const k of processQs) {
|
| 135 |
+
if (isNonNAAnswer(catEval.processAnswers[k])) {
|
| 136 |
+
anyNonNA = true
|
| 137 |
+
break
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
if (anyNonNA) return undefined
|
| 143 |
+
|
| 144 |
+
// Only treat category as fully N/A when the category-level field `additionalAspects`
|
| 145 |
+
// explicitly marks it as not applicable (page 2 of the form). Question-level markers
|
| 146 |
+
// (process/benchmark source descriptions or scopes) should NOT make the entire category
|
| 147 |
+
// non-selectable — they will still be shown as per-question NA in the details view.
|
| 148 |
+
if (typeof catEval.additionalAspects === "string" && /not applicable/i.test(catEval.additionalAspects)) {
|
| 149 |
+
return catEval.additionalAspects
|
| 150 |
}
|
| 151 |
|
| 152 |
return undefined
|