PageSourceSearch

https://app.zerply.ai/assets/v2/settings.prompt-tags-D3zxe4EP.js

js zerply.ai collected 2026-10-05 13:21:44 UTC 6,705 bytes, 2 lines download raw bytes

1import{r as t,e as f,U as o,j as e,B as x,m as V,a0 as J,I as q,q as K,T as Q,D as B,n as L,o as _,p as z,af as O,f as P}from"./index-QVtaH2Yp.js";import{L as $}from"./label-CCW8dh9x.js";import{S as W}from"./skeleton-DzUIW5Ku.js";import{A as X}from"./arrow-right-3YQNmuSc.js";import{P as Y}from"./pencil-Dr0TDtb9.js";try{let a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new a.Error().stack;n&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[n]="b71461c7-4857-44ec-a314-00f5843869b1",a._sentryDebugIdIdentifier="sentry-dbid-b71461c7-4857-44ec-a314-00f5843869b1")}catch{}function re(){const[a,n]=t.useState([]),[j,m]=t.useState(!0),[i,y]=t.useState(""),[v,c]=t.useState(!1),[r,p]=t.useState(!1),[C,b]=t.useState(null),[u,g]=t.useState(""),[N,h]=t.useState("#F97316"),[T,S]=t.useState(!1),[F,D]=t.useState(null);t.useEffect(()=>{H()},[]);const H=async()=>{m(!0);try{const s=await f.get("/prompt-tags");n(s.data.data||[])}catch(s){console.error("Failed to fetch tags:",s),o.error("Failed to load tags")}finally{m(!1)}},E=t.useMemo(()=>{const s=i.trim().toLowerCase();return s===""?a:a.filter(l=>l.name.toLowerCase().includes(s))},[a,i]),M=s=>{b(s),g(s.name),h(s.color||"#F97316"),c(!0)},R=()=>{b(null),g(""),h("#F97316"),p(!0)},k=async()=>{if(!u.trim()){o.error("Tag name is required");return}S(!0);try{const s={name:u.trim(),color:N||void 0};if(C){const d=(await f.put(`/prompt-tags/${C.id}`,s)).data;n(w=>w.map(I=>I.id===d.id?d:I)),c(!1),o.success("Tag updated")}else{const d=(await f.post("/prompt-tags",s)).data;n(w=>[d,...w]),p(!1),o.success("Tag created")}b(null),g(""),h("#F97316")}catch(s){console.error("Failed to save tag:",s),o.error(P(s,"Failed to save tag"))}finally{S(!1)}},G=async s=>{if(confirm(`Delete "${s.name}"? This will remove it from all prompts.`)){D(s.id);try{await f.delete(`/prompt-tags/${s.id}`),n(l=>l.filter(d=>d.id!==s.id)),o.success("Tag deleted")}catch(l){console.error("Failed to delete tag:",l),o.error(P(l,"Failed to delete tag"))}finally{D(null)}}},A=["#F97316","#EF4444","#EC4899","#8B5CF6","#3B82F6","#10B981","#F59E0B","#6B7280"];return e.jsxs("div",{className:"flex flex-col min-h-full bg-white",children:[e.jsxs("div",{className:"flex flex-col gap-4 px-6 py-4 border-b border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-lg font-semibold text-gray-900",children:"Prompt Tags"}),e.jsxs(x,{onClick:R,size:"sm",className:"bg-orange-500 hover:bg-orange-600 text-white gap-2",children:[e.jsx(V,{className:"w-4 h-4"}),"Add Tag"]})]}),e.jsxs("div",{className:"relative max-w-xs",children:[e.jsx(J,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(q,{placeholder:"Search tags...",value:i,onChange:s=>y(s.target.value),className:"pl-10 h-9 text-sm focus-visible:ring-0 focus-visible:ring-offset-0"})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:j?e.jsx("div",{className:"p-4 space-y-2",children:Array.from({length:5}).map((s,l)=>e.jsx(W,{className:"h-10 w-full"},l))}):E.length===0?e.jsx("div",{className:"flex flex-col items-center justify-center p-12 text-center",children:i?e.jsx(e.Fragment,{children:e.jsx("div",{className:"text-gray-400 mb-2",children:"No tags match your search"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm text-gray-500 mb-4",children:"No tags yet"}),e.jsxs("a",{href:"/ai-visibility/prompts",className:"inline-flex items-center gap-1 text-sm px-3 py-1.5 border border-gray-300 text-gray-500 hover:text-gray-700 hover:border-gray-400 rounded-md hover:bg-gray-50 transition-colors",children:["Go to Prompts",e.jsx(X,{className:"h-3.5 w-3.5"})]})]})}):e.jsx("div",{className:"divide-y divide-gray-200",children:E.map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3 px-6 py-3 hover:bg-gray-50 transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-3 w-3 rounded-full flex-shrink-0",style:{backgroundColor:s.color||"#F97316"}}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 truncate",children:s.name}),e.jsxs("p",{className:"text-xs text-gray-500",children:[s.prompt_count??0," prompt",s.prompt_count!==1?"s":""]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>M(s),className:"h-8 w-8 p-0",children:e.jsx(Y,{className:"h-4 w-4 text-gray-600"})}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>G(s),disabled:F===s.id,className:"h-8 w-8 p-0 text-gray-600 hover:text-red-600",children:F===s.id?e.jsx(K,{className:"h-4 w-4 animate-spin"}):e.jsx(Q,{className:"h-4 w-4"})})]})]},s.id))})}),e.jsx(B,{open:r,onOpenChange:p,children:e.jsxs(L,{className:"sm:max-w-sm",children:[e.jsxs(_,{children:[e.jsx(z,{children:"Create Tag"}),e.jsx(O,{children:"Add a new prompt tag"})]}),e.jsx(U,{name:u,setName:g,color:N,setColor:h,saving:T,onSave:k,onCancel:()=>p(!1),predefinedColors:A})]})}),e.jsx(B,{open:v,onOpenChange:c,children:e.jsxs(L,{className:"sm:max-w-sm",children:[e.jsxs(_,{children:[e.jsx(z,{children:"Edit Tag"}),e.jsx(O,{children:"Update tag details"})]}),e.jsx(U,{name:u,setName:g,color:N,setColor:h,saving:T,onSave:k,onCancel:()=>c(!1),predefinedColors:A})]})})]})}function U({name:a,setName:n,color:j,setColor:m,saving:i,onSave:y,onCancel:v,predefinedColors:c}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx($,{htmlFor:"tag-name",className:"text-sm",children:"Name"}),e.jsx(q,{id:"tag-name",value:a,onChange:r=>n(r.target.value),placeholder:"e.g., High Priority",maxLength:100,className:"mt-1 h-9 text-sm",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx($,{className:"text-sm",children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("input",{type:"color",value:j,onChange:r=>m(r.target.value),className:"h-9 w-12 rounded border border-gray-300 cursor-pointer"}),e.jsx("div",{className:"flex gap-1",children:c.map(r=>e.jsx("button",{type:"button",className:"w-7 h-7 rounded border-2 border-transparent hover:border-gray-300 transition-all",style:{backgroundColor:r},onClick:()=>m(r),"aria-label":`Select color ${r}`},r))})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(x,{variant:"outline",onClick:v,size:"sm",children:"Cancel"}),e.jsx(x,{onClick:y,disabled:i||!a.trim(),size:"sm",className:"bg-orange-500 hover:bg-orange-600 text-white",children:i?"Saving...":"Save"})]})]})}export{re as default};
2//# sourceMappingURL=settings.prompt-tags-D3zxe4EP.js.map

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.