vendor: 1,534 bytes, line 1
1import{V as se,r as t,aa as te,j as e,ab as ae,W as H,ac as re,ad as ne,ae as ie,af as oe,g as le,K as de,a6 as ce,i as D,P as pe,N as ue,O as xe,Q as he,I as O,R as me,ag as fe,B as b,C as je,T as ge,a as Ce,b as ye,d as ve,s as q,p as R,a0 as B}from"./index-KJIc_ciD.js";import{L as C}from"./label-R1fcaIu-.js";import{T as Ne,a as we,b as P,c as y,d as _e,e as h}from"./table-C7TDNQ36.js";import{T as F}from"./textarea-CqZs4IfM.js";import{C as be,c as Se}from"./card-gp3C_18b.js";import{S as Te}from"./switch-DVrGOV73.js";import{A as Ae,a as De,b as Re,c as ke,d as qe,e as Pe,f as Ee,g as Ie,h as Le}from"./alert-dialog-BNP9fj-k.js";import{C as Oe,a as Be}from"./chevron-up-D_fCxlKM.js";import{P as Fe}from"./pencil-BmiCMc0Q.js";import{T as He}from"./trash-2-Dac-VHUI.js";import"./index-BkCqSLkz.js";var E="Collapsible",[Me,ns]=se(E),[We,M]=Me(E),U=t.forwardRef((r,d)=>{const{__scopeCollapsible:p,open:l,defaultOpen:a,disabled:o,onOpenChange:c,...u}=r,[m,f]=te({prop:l,defaultProp:a??!1,onChange:c,caller:E});return e.jsx(We,{scope:p,disabled:o,contentId:ae(),open:m,onOpenToggle:t.useCallback(()=>f(j=>!j),[f]),children:e.jsx(H.div,{"data-state":$(m),"data-disabled":o?"":void 0,...u,ref:d})})});U.displayName=E;var G="CollapsibleTrigger",K=t.forwardRef((r,d)=>{const{__scopeCollapsible:p,...l}=r,a=M(G,p);return e.jsx(H.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":$(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...l,ref:d,onClick:re(r.onClick,a.onOpenToggle)})});
1K.displayName=G;var W="CollapsibleContent",Q=t.forwardRef((r,d)=>{const{forceMount:p,...l}=r,a=M(W,r.__scopeCollapsible);return e.jsx(ne,{present:p||a.open,children:({present:o})=>e.jsx($e,{...l,ref:d,present:o})})});Q.displayName=W;var $e=t.forwardRef((r,d)=>{const{__scopeCollapsible:p,present:l,children:a,...o}=r,c=M(W,p),[u,m]=t.useState(l),f=t.useRef(null),j=ie(d,f),S=t.useRef(0),v=S.current,T=t.useRef(0),N=T.current,w=c.open||u,_=t.useRef(w),g=t.useRef(void 0);return t.useEffect(()=>{const i=requestAnimationFrame(()=>_.current=!1);return()=>cancelAnimationFrame(i)},[]),oe(()=>{const i=f.current;if(i){g.current=g.current||{transitionDuration:i.style.transitionDuration,animationName:i.style.animationName},i.style.transitionDuration="0s",i.style.animationName="none";const A=i.getBoundingClientRect();S.current=A.height,T.current=A.width,_.current||(i.style.transitionDuration=g.current.transitionDuration,i.style.animationName=g.current.animationName),m(l)}},[c.open,l]),e.jsx(H.div,{"data-state":$(c.open),"data-disabled":c.disabled?"":void 0,id:c.contentId,hidden:!w,...o,ref:j,style:{"--radix-collapsible-content-height":v?`${v}px`:void 0,"--radix-collapsible-content-width":N?`${N}px`:void 0,...r.style},children:w&&a})});function $(r){return r?"open":"closed"}var Ve=U;const ze=Ve,Ue=K,Ge=Q,is=()=>{const{user:r}=le(),[d,p]=t.useState([]),[l,a]=t.useState(!1),[o,c]=t.useState(null),[u,m]=t.useState(""),[f,j]=t.useState(""),[S,v]=t.useState("24"),[T,N]=t.useState(""),[w,_]=t.useState(""),[g,i]=t.useState(""),[A,k]=t.useState(!1),[V,J]=t.useState(null),I=async()=>{const{data:s}=await q.from("support_types").select("*").order("name");s&&p(s)};t.useEffect(()=>{I()},[]);const z=s=>s.split(",").map(n=>n.trim()).filter(Boolean),X=async()=>{const s={name:u,description:f,default_sla_hours:parseInt(S),required_inputs:z(T),workflow_steps:z(w),sla_notes:g,is_custom:A};if(o){const{error:n}=await q.from("support_types").update(s).eq("id",o.id);if(n){R.error(n.message);return}B({user_id:r.id,action:"support_type_updated",entity_type:"support_type",entity_id:o.id,details:{name:u}}),R.success("Support type updated")}else{const{data:n,error:x}=await q.from("support_types").insert(s).select("id").single();if(x){R.error(x.message);return}B({user_id:r.id,action:"support_type_created",entity_type:"support_type",entity_id:n==null?void 0:n.id,details:{name:u}}),R.success("Support type created")}L(),a(!1),I()},Y=async s=>{await q.from("support_types").delete().eq("id",s),B({user_id:r.id,action:"support_type_deleted",entity_type:"support_type",entity_id:s}),R.success("Support type deleted"),I()},L=()=>{c(null),m(""),j(""),v("24"),N(""),_(""),i(""),k(!1)},Z=s=>{c(s),m(s.name),j(s.description||""),v(String(s.default_sla_hours)),N((s.required_inputs||[]).join(", ")),_((s.workflow_steps||[]).join(", ")),i(s.sla_notes||""),k(s.is_custom||!1),a(!0)},ee=()=>{L(),k(!0),a(!0)};return e.jsxs("div",{className:"space-y-6 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-display font-bold",children:"Support Types"}),e.jsx("p",{className:"text-muted-foreground",children:"Configure support categories, SLA, required inputs & workflows"})]}),e.jsxs(de,{open:l,onOpenChange:s=>{a(s),s||L()},children:[e.jsx(ce,{asChild:!0,children:e.jsxs(D,{onClick:ee,className:"gradient-primary text-primary-foreground",children:[e.jsx(pe,{className:"h-4 w-4 mr-2"})," Add Custom Type"]})}),e.jsxs(ue,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(xe,{children:e.jsx(he,{children:o?"Edit Support Type":"Create Custom Support Type"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(C,{children:"Name *"}),e.jsx(O,{value:u,onChange:s=>m(s.target.value),placeholder:"e.g. Email Support, VM Setup"})]}),e.jsxs("div",{children:[e.jsx(C,{children:"Description"}),e.jsx(F,{value:f,onChange:s=>j(s.target.value),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(C,{children:"Default SLA (hours)"}),e.jsx(O,{type:"number",value:S,onChange:s=>v(s.target.value),min:"1"})]}),e.jsxs("div",{children:[e.jsx(C,{children:"Required Inputs"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Comma-separated list of fields required when creating a ticket"}),e.jsx(F,{value:T,onChange:s=>N(s.target.value),placeholder:"e.g. User identity, Email address, Verification proof",rows:2})]}),e.jsxs("div",{children:[e.jsx(C,{children:"Workflow Steps"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Comma-separated steps for resolving this type"}),e.jsx(F,{value:w,onChange:s=>_(s.target.value),placeholder:"e.g. Verify identity, Reset password, Notify user",rows:2})]}),e.jsxs("div",{children:[e.jsx(C,{children:"SLA Notes"}),e.jsx(O,{value:g,onChange:s=>i(s.target.value),placeholder:"e.g. 1-2 hours for verified users"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Te,{checked:A,onCheckedChange:k}),e.jsx(C,{children:"Custom type (admin-defined)"})]})]}),e.jsx(me,{children:e.jsx(D,{onClick:X,className:"gradient-primary text-primary-foreground",disabled:!u.trim(),children:o?"Update":"Create"})})]})]})]}),e.jsx(be,{children:e.jsx(Se,{className:"p-0",children:e.jsxs(Ne,{children:[e.jsx(we,{children:e.jsxs(P,{children:[e.jsx(y,{className:"w-8"}),e.jsx(y,{children:"Name"}),e.jsx(y,{children:"Description"}),e.jsx(y,{children:"SLA"}),e.jsx(y,{children:"Required Inputs"}),e.jsx(y,{children:"Notes"}),e.jsx(y,{className:"w-24",children:"Actions"})]})}),e.jsxs(_e,{children:[d.map(s=>e.jsx(ze,{asChild:!0,open:V===s.id,onOpenChange:n=>J(n?s.id:null),children:e.jsxs(e.Fragment,{children:[e.jsxs(P,{children:[e.jsx(h,{children:e.jsx(Ue,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"icon",className:"h-6 w-6",children:V===s.id?e.jsx(Oe,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})})})}),e.jsx(h,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"h-4 w-4 text-warning"}),s.name,s.is_custom&&e.jsx(b,{variant:"outline",className:"text-xs",children:"Custom"})]})}),e.jsx(h,{className:"text-muted-foreground max-w-[200px] truncate",children:s.description||"â"}),e.jsx(h,{children:e.jsxs(b,{variant:"secondary",className:"gap-1",children:[e.jsx(je,{className:"h-3 w-3"}),s.default_sla_hours,"h"]})}),e.jsx(h,{children:e.jsxs("div",{className:"flex flex-wrap gap-1 max-w-[200px]",children:[(s.required_inputs||[]).slice(0,3).map((n,x)=>e.jsx(b,{variant:"outline",className:"text-xs",children:n},x)),(s.required_inputs||[]).length>3&&e.jsx(ge,{children:e.jsxs(Ce,{children:[e.jsx(ye,{children:e.jsxs(b,{variant:"outline",className:"text-xs",children:["+",s.required_inputs.length-3]})}),e.jsx(ve,{children:e.jsx("p",{children:s.required_inputs.slice(3).join(", ")})})]})})]})}),e.jsx(h,{className:"text-muted-foreground text-sm max-w-[150px] truncate",children:s.sla_notes||"â"}),e.jsx(h,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(D,{variant:"ghost",size:"icon",onClick:()=>Z(s),children:e.jsx(Fe,{className:"h-4 w-4"})}),e.jsxs(Ae,{children:[e.jsx(De,{asChild:!0,children:e.jsx(D,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(He,{className:"h-4 w-4"})})}),e.jsxs(Re,{children:[e.jsxs(ke,{children:[e.jsx(qe,{children:"Delete support type?"}),e.jsx(Pe,{children:"This cannot be undone."})]}),e.jsxs(Ee,{children:[e.jsx(Ie,{children:"Cancel"}),e.jsx(Le,{onClick:()=>Y(s.id),className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})]})]})})]}),e.jsx(Ge,{asChild:!0,children:e.jsx(P,{className:"bg-muted/30",children:e.jsx(h,{colSpan:7,children:e.jsxs("div",{className:"py-2 px-4 space-y-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"Workflow Steps"}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-1",children:[(s.workflow_steps||[]).map((n,x)=>e.jsxs(b,{variant:"secondary",className:"text-xs",children:[x+1,". ",n]},x)),(!s.workflow_steps||s.workflow_steps.length===0)&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"No workflow steps defined"})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"All Required Inputs"}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[(s.required_inputs||[]).map((n,x)=>e.jsx(b,{variant:"outline",className:"text-xs",children:n},x)),(!s.required_inputs||s.required_inputs.length===0)&&e.jsx("span",{className:"text-muted-foreground text-xs",children:"No required inputs"})]})]}),s.sla_notes&&e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-semibold text-muted-foreground uppercase",children:"SLA Notes"}),e.jsx("p",{className:"text-sm mt-1",children:s.sla_notes})]})]})})})})]})},s.id)),d.length===0&&e.jsx(P,{children:e.jsx(h,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No support types yet"})})]})]})})})]})};export{is as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.