'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useState } from 'react';
import { Button } from '../../ui/button.js';
import { Badge } from '../../ui/badge.js';
import { EstimateType } from '../../../../../../packages/core/src/domain/generated/output.js';
import { updatePmProject } from '../../../app/actions/update-pm-project.js';
const ESTIMATE_OPTIONS = [
    {
        value: EstimateType.None,
        label: 'None',
        description: 'No estimates',
    },
    {
        value: EstimateType.Category,
        label: 'T-Shirt Sizes',
        description: 'XS, S, M, L, XL',
    },
    {
        value: EstimateType.Points,
        label: 'Fibonacci Points',
        description: '1, 2, 3, 5, 8, 13, 21',
    },
];
export function EstimateSettings({ projectId, currentEstimateType, onEstimateTypeChange, className, }) {
    const [selected, setSelected] = useState(currentEstimateType);
    const [saving, setSaving] = useState(false);
    const handleSelect = async (type) => {
        if (type === selected)
            return;
        setSelected(type);
        setSaving(true);
        await updatePmProject(projectId, { estimateType: type });
        setSaving(false);
        onEstimateTypeChange?.(type);
    };
    return (_jsxs("div", { "data-testid": "estimate-settings", className: className, children: [_jsxs("div", { className: "mb-3 flex items-center gap-2", children: [_jsx("h3", { className: "text-xs font-medium", children: "Estimate System" }), saving ? _jsx("span", { className: "text-muted-foreground text-[10px]", children: "Saving..." }) : null] }), _jsx("div", { className: "space-y-2", children: ESTIMATE_OPTIONS.map((opt) => (_jsx(Button, { variant: selected === opt.value ? 'default' : 'outline', size: "sm", className: "h-auto w-full justify-start px-3 py-2 text-left", onClick: () => handleSelect(opt.value), "data-testid": `estimate-option-${opt.value}`, children: _jsxs("div", { className: "flex w-full items-center justify-between", children: [_jsxs("div", { children: [_jsx("span", { className: "text-xs font-medium", children: opt.label }), _jsx("span", { className: "text-muted-foreground ml-2 text-[10px]", children: opt.description })] }), selected === opt.value ? (_jsx(Badge, { variant: "secondary", className: "text-[10px]", children: "Active" })) : null] }) }, opt.value))) })] }));
}
