PageSourceSearch

https://mouthly.ai/assets/ItemCategoryFormDialogContent-BEVMiCsN.js

js mouthly.ai collected 2026-10-05 15:41:24 UTC 3,392 bytes, 1 lines download raw bytes

1import{bV as w,bW as C,ba as a,w as e,x as L,bZ as F,r as j,R as k,aT as S,bm as T,bX as B,bS as Y,bT as P,$ as b,bc as I,e as E,bY as V,dk as X,b_ as q,b9 as H}from"./index-JpHfX16J.js";import{D as A}from"./dataTypes-MsMUqiFJ.js";import{I as $}from"./InputGroup-dHc3hQxa.js";import{T as U}from"./Textarea-BR_Q68eF.js";import{u as W}from"./useAutofocus-BzqLfGfZ.js";import{F as Z}from"./FieldRequiredHint-C4WZ0RZ2.js";import{D as z}from"./DialogContent-DhA8GGuH.js";import{c as J,d as K,e as Q}from"./queries-B4HSfBVm.js";import"./textArea-Cucgar-I.js";import"./query-keys-f1GCZYir.js";import"./query-keys-Clja6SAR.js";const M=w().shape({name:C().required().max(A.STRING).label(a.get("category_name_")),description:C().trim().max(A.TEXT).nullable()}),tt=M,et=M;function ot(){const t=W();return e.jsxs("div",{className:L,children:[e.jsx(F,{name:"name",label:a.get("category_name"),labelInfo:e.jsx(Z,{}),inline:!0,fastField:!0,children:e.jsx($,{name:"name",inputRef:o=>{t.current=o},"data-testId":"category-name-input",fastField:!0})}),e.jsx(F,{name:"description",label:a.get("description"),inline:!0,fastField:!0,children:e.jsx(U,{name:"description",growVertically:!0,large:!0,"data-testId":"category-description-input",fastField:!0})})]})}const N=j.createContext({});function st({itemCategoryId:t,dialogName:o,...s}){const{data:n,isFetching:r}=J(t!=null?t:void 0,{enabled:!!t}),{mutateAsync:m}=K(),{mutateAsync:d}=Q(),i=!t,u={itemCategoryId:t,dialogName:o,itemCategory:n,isItemCategoryLoading:r,createItemCategoryMutate:m,editItemCategoryMutate:d,isNewMode:i,isEditMode:!i};return e.jsx(z,{isLoading:r,name:"item-category-form",children:e.jsx(N.Provider,{value:u,...s})})}const R=()=>k.useContext(N);function nt({closeDialog:t}){const{isNewMode:o,dialogName:s}=R(),{isSubmitting:n}=B(),r=()=>{t(s)};return e.jsx("div",{className:Y,children:e.jsxs("div",{className:P,children:[e.jsx(b,{disabled:n,onClick:r,children:e.jsx(I,{id:"close"})}),e.jsx(b,{intent:E.PRIMARY,type:"submit",loading:n,children:o?e.jsx(I,{id:"submit"}):e.jsx(I,{id:"edit"})})]})})}const rt=S(nt,T);function at(){return e.jsxs(V,{children:[e.jsx(ot,{}),e.jsx(rt,{})]})}const _={name:"",description:"",costAccountId:"",sellAccountId:"",inventoryAccountId:"",costMethod:""},f=t=>typeof t=="number"?t||void 0:Number(t)||void 0,O=t=>({name:t.name,description:t.description,costAccountId:f(t.costAccountId),sellAccountId:f(t.sellAccountId),inventoryAccountId:f(t.inventoryAccountId),costMethod:t.costMethod}),it=t=>O(t);function ct({closeDialog:t}){const{isNewMode:o,itemCategory:s,itemCategoryId:n,dialogName:r,createItemCategoryMutate:m,editItemCategoryMutate:d}=R(),i=j.useMemo(()=>({..._,...X(s,_)}),[s]),y=(l,{setErrors:c})=>{l.find(g=>g.type==="CATEGORY_NAME_EXISTS")&&c({name:a.get("category_name_exists")})},u=(l,{setSubmitting:c,setErrors:g})=>{c(!0);const p={...l},D=()=>{t(r)},x=()=>{H.show({message:a.get(o?"the_item_category_has_been_created_successfully":"the_item_category_has_been_edited_successfully"),intent:E.SUCCESS}),D()},h=G=>{const{data:{errors:v}}=G;y(v,{setErrors:g}),c(!1)};o?m(O(p)).then(x).catch(h):d([n,it(p)]).then(x).catch(h)};return e.jsx(q,{validationSchema:o?tt:et,initialValues:i,onSubmit:u,children:e.jsx(at,{})})}const mt=S(ct,T);function Ft({itemCategoryId:t,dialogName:o}){return e.jsx(st,{itemCategoryId:t,dialogName:o,children:e.jsx(mt,{})})}export{Ft as ItemCategoryFormDialogContent};

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.