From acca1abc01bb69af8f072a65ac4317a6279ae170 Mon Sep 17 00:00:00 2001 From: admin-valentin Date: Sat, 1 Aug 2026 10:43:40 +0000 Subject: [PATCH] feat(cc-053): Decision Register page --- src/app/dashboard/decisions/register/page.tsx | 359 +++--------------- 1 file changed, 60 insertions(+), 299 deletions(-) diff --git a/src/app/dashboard/decisions/register/page.tsx b/src/app/dashboard/decisions/register/page.tsx index 04f803c..2bb5402 100644 --- a/src/app/dashboard/decisions/register/page.tsx +++ b/src/app/dashboard/decisions/register/page.tsx @@ -1,324 +1,85 @@ 'use client'; -import { useState } from 'react'; -import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { useForm } from 'react-hook-form'; -import { z } from 'zod'; -import { apiFetch, type Decision } from '../../../../lib/api'; +import Link from 'next/link'; +import { useQuery } from '@tanstack/react-query'; +import { apiFetch } from '../../../../lib/api'; +import type { Decision } from '../../../../lib/api'; import { useSession } from '../../../../components/session-provider'; -const createDecisionSchema = z.object({ - context: z.string().min(1, 'Contextul este obligatoriu').max(2000), - optionsText: z.string().optional(), - reviewDueAt: z.string().optional(), -}); -type CreateDecisionForm = z.infer; - -function parseOptions(text: string): string[] { - return text.split('\n').map((s) => s.trim()).filter(Boolean); +function fmtDate(s: string | null) { + if (!s) return '—'; + return new Date(s).toLocaleDateString('ro-RO', { day: 'numeric', month: 'short', year: 'numeric' }); } -function DecisionCard({ - decision, - tenantId, - onUpdated, -}: { - decision: Decision; - tenantId: string; - onUpdated: () => Promise; -}) { - const [isExpanded, setIsExpanded] = useState(false); - const [selectedOption, setSelectedOption] = useState(decision.selectedOption ?? ''); - const [outcomeReview, setOutcomeReview] = useState(decision.outcomeReview ?? ''); - - const options = (decision.options as string[]).filter(Boolean); - const isDecided = Boolean(decision.selectedOption); - const isOverdue = - decision.reviewDueAt ? new Date(decision.reviewDueAt) < new Date() : false; - - const updateMutation = useMutation({ - mutationFn: (dto: { selectedOption?: string; outcomeReview?: string }) => - apiFetch(`/v1/decisions/${decision.id}`, { - method: 'PATCH', - tenantId, - body: dto, - }), - onSuccess: async () => { - await onUpdated(); - }, - }); - - return ( -
  • - - - {isExpanded && ( -
    - {decision.selectedOption && ( -
    - Decizie luată: {decision.selectedOption} -
    - )} - - {options.length > 0 && ( -
    -

    Selectează opțiunea

    -
    - {options.map((opt, i) => ( - - ))} -
    -
    - )} - -
    - -