lms/public/build/assets/category-form-BqEOwxwO.js
2025-12-15 12:26:23 +01:00

2 lines
2.9 KiB
JavaScript

import{u as y,r as h,b as L,j as e}from"./vendor-BKmmeuxg.js";import{I as w}from"./icon-picker-iXyBXP6r.js";import{I as c}from"./input-error-LaPr_4wd.js";import{B as j}from"./button-BpNwv2aE.js";import{D as g,a as B,b as f,c as v,d as b,e as P,f as V}from"./dialog-B2gN9MvT.js";import{I as S}from"./input-DM0goJrn.js";import{L as l}from"./label-HmIcv5Yx.js";import{S as q}from"./scroll-area-C8HGru-R.js";import{S as A,a as H,b as R,c as z,d as C}from"./select-CD9o3HN1.js";import{T as G}from"./textarea-CyndvowL.js";import"./use-lang-YfV87_zl.js";import"./debounce-CWHP_ANh.js";import"./tooltip-BsX7Z6vz.js";import"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const ie=({title:D,handler:_,category:s})=>{const{props:I}=y(),{translate:N}=I,{dashboard:t,input:i,button:d}=N,[m,p]=h.useState(!1),[F,u]=h.useState(!1),{data:n,setData:o,post:O,put:T,processing:E,errors:r,reset:x}=L({name:s?s.name:"",icon:s?s.icon:"",status:s?s.status:"active",description:s?s.description:""}),k=a=>{a.preventDefault(),s?T(route("blogs.categories.update",s.id),{onSuccess:()=>{p(!1),x()}}):O(route("blogs.categories.store"),{onSuccess:()=>{p(!1),x()}})};return h.useEffect(()=>{m||x()},[m]),e.jsxs(g,{open:m,onOpenChange:p,children:[e.jsx(B,{children:_}),e.jsxs(f,{className:"sm:max-w-[425px]",children:[e.jsx(v,{children:e.jsx(b,{children:D})}),e.jsxs("form",{onSubmit:k,children:[e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",children:i.title}),e.jsx(S,{id:"name",value:n.name,onChange:a=>o("name",a.target.value),className:r.name?"border-red-500":"",placeholder:t.enter_category_name}),e.jsx(c,{message:r.name})]}),e.jsxs("div",{children:[e.jsx(l,{children:i.category_icon}),e.jsx(S,{required:!0,readOnly:!0,type:"text",name:"icon",value:n.icon,placeholder:i.icon_placeholder,onClick:()=>u(!0)}),e.jsx(c,{message:r.icon}),e.jsx(g,{open:F,onOpenChange:u,children:e.jsx(f,{className:"p-0",children:e.jsxs(q,{className:"max-h-[90vh] p-6",children:[e.jsx(v,{className:"mb-6",children:e.jsx(b,{children:t.icon_picker})}),e.jsx(w,{onSelect:a=>{o("icon",a),u(!1)}})]})})})]}),e.jsxs("div",{children:[e.jsx(l,{htmlFor:"status",children:i.category_status}),e.jsxs(A,{value:n.status,onValueChange:a=>o("status",a),children:[e.jsx(H,{children:e.jsx(R,{})}),e.jsxs(z,{children:[e.jsx(C,{value:"active",children:t.active}),e.jsx(C,{value:"inactive",children:t.inactive})]})]}),e.jsx(c,{message:r.status})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"description",children:t.subtitle_80_char}),e.jsx(G,{id:"description",value:n.description||"",onChange:a=>o("description",a.target.value),className:r.description?"border-red-500":"",placeholder:t.enter_category_description,maxLength:80,rows:3}),e.jsx(c,{message:r.description})]})]}),e.jsxs(P,{children:[e.jsx(V,{children:e.jsx(j,{type:"button",variant:"outline",children:d.close})}),e.jsx(j,{type:"submit",disabled:E,children:s?d.update:d.create})]})]})]})]})};export{ie as default};