Files
igny8/frontend/dist/assets/js/AuthorProfiles-B2gmK5S5.js
IGNY8 VPS (Salman) 3c100be1cf more
2025-11-13 14:12:36 +00:00

2 lines
3.5 KiB
JavaScript

import{r as a,j as e}from"./chunk-UIGDSWPH-BhuNDbxn.js";import{u as P,aa as b,P as A,B as o,ab as k,ac as w,ad as C}from"./main-af3pcbZa.js";import{C as S}from"./Card-CAsJMMfR.js";import{F as E}from"./FormModal-DkhE3zPR.js";import{B as F}from"./Badge-DM3morB7.js";import{S as _}from"./plus-2WF6_FMG.js";import"./index-ju2wdkG8.js";import"./SelectDropdown-C8sZwHi_.js";function z(){const s=P(),[u,x]=a.useState([]),[h,d]=a.useState(!0),[g,r]=a.useState(!1),[i,m]=a.useState(null),[l,n]=a.useState({name:"",description:"",tone:"",language:"en",is_active:!0});a.useEffect(()=>{c()},[]);const c=async()=>{try{d(!0);const t=await b();x(t.results||[])}catch(t){s.error(`Failed to load author profiles: ${t.message}`)}finally{d(!1)}},f=()=>{m(null),n({name:"",description:"",tone:"",language:"en",is_active:!0}),r(!0)},y=t=>{m(t),n({name:t.name,description:t.description,tone:t.tone,language:t.language,is_active:t.is_active}),r(!0)},p=async()=>{try{i?(await k(i.id,l),s.success("Author profile updated successfully")):(await w(l),s.success("Author profile created successfully")),r(!1),c()}catch(t){s.error(`Failed to save: ${t.message}`)}},j=async t=>{if(confirm("Are you sure you want to delete this author profile?"))try{await C(t),s.success("Author profile deleted successfully"),c()}catch(N){s.error(`Failed to delete: ${N.message}`)}},v=[{name:"name",label:"Name",type:"text",required:!0},{name:"description",label:"Description",type:"textarea",required:!1},{name:"tone",label:"Tone",type:"text",required:!0},{name:"language",label:"Language",type:"text",required:!0},{name:"is_active",label:"Active",type:"checkbox",required:!1}];return e.jsxs("div",{className:"p-6",children:[e.jsx(A,{title:"Author Profiles"}),e.jsxs("div",{className:"mb-6 flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Author Profiles"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Manage writing style profiles"})]}),e.jsxs(o,{onClick:f,variant:"primary",children:[e.jsx(_,{className:"w-4 h-4 mr-2"}),"Create Profile"]})]}),h?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"text-gray-500",children:"Loading..."})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:u.map(t=>e.jsxs(S,{className:"p-6",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t.name}),e.jsx(F,{variant:"light",color:t.is_active?"success":"dark",children:t.is_active?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-4",children:t.description}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Tone:"})," ",e.jsx("span",{className:"text-gray-900 dark:text-white",children:t.tone})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Language:"})," ",e.jsx("span",{className:"text-gray-900 dark:text-white",children:t.language})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{variant:"secondary",size:"sm",onClick:()=>y(t),children:"Edit"}),e.jsx(o,{variant:"danger",size:"sm",onClick:()=>j(t.id),children:"Delete"})]})]},t.id))}),e.jsx(E,{isOpen:g,onClose:()=>r(!1),onSave:p,title:i?"Edit Author Profile":"Create Author Profile",fields:v,data:l,onChange:n})]})}export{z as default};