// @bun
import{gql as $}from"@apollo/client";import{useMutation as b}from"@apollo/client/react";import{useTemplateRuntime as h}from"@contractspec/lib.example-shared-ui";import{useState as B}from"react";import{jsx as w,jsxs as z}from"react/jsx-runtime";var k=$`
  mutation CreateTask($input: CreateTaskInput!) {
    createTask(input: $input) {
      id
      title
    }
  }
`;function E({categories:F}){let{projectId:G}=h(),[H,L]=B(""),[N,O]=B(""),[Q,U]=B("MEDIUM"),[J,V]=B("none"),[W,X]=B(""),[Z,{loading:Y}]=b(k);return z("form",{onSubmit:async(f)=>{if(f.preventDefault(),!H.trim())return;await Z({variables:{input:{projectId:G,title:H.trim(),description:N.trim()||void 0,priority:Q,categoryId:J==="none"?void 0:J,tags:q(W)}},refetchQueries:["Tasks"],awaitRefetchQueries:!0}),L(""),O(""),U("MEDIUM"),V("none"),X("")},className:"space-y-3 rounded-2xl border border-border bg-background/60 p-4",children:[w("div",{children:z("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Title",w("input",{type:"text",className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",placeholder:"What needs to get done?",value:H,onChange:(f)=>L(f.target.value),required:!0})]})}),w("div",{children:z("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Description",w("textarea",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",rows:3,placeholder:"Add context or policy notes",value:N,onChange:(f)=>O(f.target.value)})]})}),z("div",{className:"grid gap-3 md:grid-cols-3",children:[z("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Priority",z("select",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",value:Q,onChange:(f)=>U(f.target.value),children:[w("option",{value:"LOW",children:"Low"}),w("option",{value:"MEDIUM",children:"Medium"}),w("option",{value:"HIGH",children:"High"}),w("option",{value:"URGENT",children:"Urgent"})]})]}),z("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Category",z("select",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",value:J,onChange:(f)=>V(f.target.value),children:[w("option",{value:"none",children:"None"}),F.map((f)=>w("option",{value:f.id,children:f.name},f.id))]})]}),z("label",{className:"font-semibold text-muted-foreground text-xs uppercase",children:["Tags",w("input",{className:"mt-1 w-full rounded-md border border-border bg-card px-3 py-2 text-sm",placeholder:"Comma separated (optional)",value:W,onChange:(f)=>X(f.target.value)})]})]}),w("button",{type:"submit",className:"btn-primary w-full py-2 font-semibold text-sm",disabled:Y,children:Y?"Saving...":"Add task"})]})}function q(F){return F.split(",").map((G)=>G.trim()).filter(Boolean)}export{E as TaskForm};
