import{r as o,j as e}from"./vendor-react-wBh_31cN.js";import{g as f,r as p,G as u,ar as g,aG as h,as as j}from"./index-BKr2rJhV.js";import{o as v}from"./yup-XkUC3UEH.js";import{u as C,C as b}from"./index.esm-CAGtek53.js";import{E as N}from"./vendor-markdown-DYw41Xyj.js";import{C as B,a as E,b as M,c as S}from"./card-DISTA6Ay.js";import{C as k}from"./checkbox-DbZXziG0.js";import{L as i}from"./label-Dnebucx5.js";import{g as L}from"./getInputValidation-CUi6Oel7.js";import{d as V}from"./index-30yM3lNV.js";import{u as $}from"./useTitle-DQo_L6Ox.js";import{t as q}from"./titles-CzjGGAB3.js";import{u as w}from"./vendor-router-D1GqFWiT.js";import"./vendor-redux-CJZrIb6x.js";import"./vendor-utils-OeoE2qq_.js";import"./vendor-icons-BUUmD6ht.js";import"./vendor-radix-BRyWS4bQ.js";import"./vendor-grid-CeFlDWv4.js";const y=g().shape({message:j().max(255).label("Message").required(),active:h().label("Active").required()}),A=()=>{$(q.Banners);const r=w(),[t,{isLoading:n}]=V(),{formState:{errors:a},register:l,handleSubmit:m,control:c}=C({defaultValues:{message:"",active:!0},resolver:v(y),shouldUnregister:!1,reValidateMode:"onChange",mode:"onBlur"}),d=o.useCallback(async s=>{await t(s),r(f(p.settings.banner.list))},[t,r]);return e.jsx("div",{className:"flex flex-1 flex-col",children:e.jsxs(B,{children:[e.jsx(E,{children:e.jsx(M,{children:"Create new banner"})}),e.jsxs(S,{children:[e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-2.5",children:[e.jsx(i,{children:"Message"}),e.jsx(b,{render:({field:{value:s,onChange:x}})=>e.jsx(N,{value:s,onChange:x,height:"200px"}),name:"message",control:c}),(a==null?void 0:a.message)&&e.jsx("span",{className:"text-xs text-destructive",children:L("message",a).info})]}),e.jsxs("div",{className:"mt-7 flex items-center gap-2",children:[e.jsx(k,{id:"banner-active",...l("active")}),e.jsx(i,{htmlFor:"banner-active",children:"Active"})]})]}),e.jsx("div",{className:"mt-5 flex justify-end",children:e.jsx(u,{onClick:m(d),loading:n,children:"Save"})})]})]})})},Z=o.memo(A);export{Z as default};
