Add isPublic field to evaluation API and detail page for public visibility management
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m6s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m6s
This commit is contained in:
@@ -118,7 +118,7 @@ export async function PUT(
|
|||||||
const { id } = await params;
|
const { id } = await params;
|
||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
|
|
||||||
const { candidateName, candidateRole, candidateTeam, evaluatorName, evaluationDate, status, findings, recommendations, dimensionScores } = body;
|
const { candidateName, candidateRole, candidateTeam, evaluatorName, evaluationDate, status, findings, recommendations, dimensionScores, isPublic } = body;
|
||||||
|
|
||||||
const existing = await prisma.evaluation.findUnique({ where: { id } });
|
const existing = await prisma.evaluation.findUnique({ where: { id } });
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
@@ -146,6 +146,7 @@ export async function PUT(
|
|||||||
if (status != null) updateData.status = status;
|
if (status != null) updateData.status = status;
|
||||||
if (findings != null) updateData.findings = findings;
|
if (findings != null) updateData.findings = findings;
|
||||||
if (recommendations != null) updateData.recommendations = recommendations;
|
if (recommendations != null) updateData.recommendations = recommendations;
|
||||||
|
if (typeof isPublic === "boolean") updateData.isPublic = isPublic;
|
||||||
|
|
||||||
if (Object.keys(updateData).length > 0) {
|
if (Object.keys(updateData).length > 0) {
|
||||||
await prisma.auditLog.create({
|
await prisma.auditLog.create({
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ interface Evaluation {
|
|||||||
recommendations: string | null;
|
recommendations: string | null;
|
||||||
dimensionScores: DimensionScore[];
|
dimensionScores: DimensionScore[];
|
||||||
sharedWith?: { id: string; user: { id: string; email: string; name: string | null } }[];
|
sharedWith?: { id: string; user: { id: string; email: string; name: string | null } }[];
|
||||||
|
isPublic?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function EvaluationDetailPage() {
|
export default function EvaluationDetailPage() {
|
||||||
@@ -168,6 +169,7 @@ export default function EvaluationDetailPage() {
|
|||||||
status: toSave.status,
|
status: toSave.status,
|
||||||
findings: toSave.findings,
|
findings: toSave.findings,
|
||||||
recommendations: toSave.recommendations,
|
recommendations: toSave.recommendations,
|
||||||
|
isPublic: toSave.isPublic ?? false,
|
||||||
dimensionScores: (toSave.dimensionScores ?? []).map((ds) => ({
|
dimensionScores: (toSave.dimensionScores ?? []).map((ds) => ({
|
||||||
dimensionId: ds.dimensionId,
|
dimensionId: ds.dimensionId,
|
||||||
evaluationId: id,
|
evaluationId: id,
|
||||||
@@ -258,6 +260,20 @@ export default function EvaluationDetailPage() {
|
|||||||
>
|
>
|
||||||
{saving ? "..." : "save"}
|
{saving ? "..." : "save"}
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
const next = !(evaluation.isPublic ?? false);
|
||||||
|
setEvaluation((e) => (e ? { ...e, isPublic: next } : null));
|
||||||
|
handleSave(evaluation ? { ...evaluation, isPublic: next } : null);
|
||||||
|
}}
|
||||||
|
className={`rounded border px-3 py-1.5 font-mono text-xs ${
|
||||||
|
evaluation.isPublic
|
||||||
|
? "border-emerald-500/50 bg-emerald-500/20 text-emerald-600 dark:text-emerald-400"
|
||||||
|
: "border-zinc-300 dark:border-zinc-600 bg-zinc-100 dark:bg-zinc-700 text-zinc-600 dark:text-zinc-400 hover:bg-zinc-200 dark:hover:bg-zinc-600"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{evaluation.isPublic ? "publique" : "rendre publique"}
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
onClick={() => setShareOpen(true)}
|
onClick={() => setShareOpen(true)}
|
||||||
className="rounded border border-cyan-500/50 bg-cyan-500/10 px-3 py-1.5 font-mono text-xs text-cyan-600 dark:text-cyan-400 hover:bg-cyan-500/20"
|
className="rounded border border-cyan-500/50 bg-cyan-500/10 px-3 py-1.5 font-mono text-xs text-cyan-600 dark:text-cyan-400 hover:bg-cyan-500/20"
|
||||||
|
|||||||
Reference in New Issue
Block a user