PageSourceSearch

https://app.stoqui.com.br/assets/CategoryMediaPage-jxhE7DO3.js

js stoqui.com.br collected 2026-09-24 11:58:12 UTC 5,752 bytes, 1 lines download raw bytes

1import{j as e,ab as j,T as l,a7 as i}from"./mui-CRsYZxVY.js";import{r as g}from"./vendor-Dwao9eNC.js";import{w as Y,J as Z,u as $,e as z,x as G,C as H,K as ee,b3 as ae,D as re,cU as ne,t as se,l as oe}from"./index-TALscxEc.js";import{S as ie}from"./SettingsScreenLayout-BWFwVJu5.js";import{B as v,L as te}from"./LinkDestinationField-c7YXpHN0.js";import{u as le}from"./query-8ViTdhdk.js";import{u as de}from"./useEditCategory-DFBO_RXR.js";import{u as ue}from"./useDraftStash-BhW-ltPG.js";import{S,C as b}from"./appearanceTokens-DaF_sGil.js";import"./datePickers-BIJXYOKG.js";import"./icons-D8aatgQ4.js";import"./lab-DSem1Osk.js";import"./UnsavedChangesDialog-gqy_t4YT.js";import"./tslib.es6-DPrcv4p0.js";import"./nativeGalleryPicker-D1sbOw5u.js";import"./CategoryPickerSheet-B2lypeTk.js";import"./CategoryQuickCreateSheet-DWRrPzmh.js";import"./ProductMultiSelectDialog-CJJuliyr.js";import"./ProductSearchBar-CThCmE3j.js";import"./useFlattenedProducts-ml3vnefA.js";import"./ProductAvatar-BTM6y7KS.js";import"./useCustomPages-DLZn-CvF.js";import"./homeLayout-C05shHWS.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new a.Error().stack;
1n&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[n]="a17ea0a7-f0d9-4bb7-bd33-375220967c5d",a._sentryDebugIdIdentifier="sentry-dbid-a17ea0a7-f0d9-4bb7-bd33-375220967c5d")})()}catch{}const ce=a=>le({queryKey:["category",a],queryFn:async()=>{const{data:n,error:c}=await Y.from("categoria").select("*").eq("id",a).single();if(c)throw c;return n},enabled:Number.isInteger(a)&&a>0});function p(a){const n=(a??"").trim();return n.length>0?n:null}const Re=()=>{const{categoryId:a}=Z(),n=Number(a),{data:c,isLoading:L}=ce(Number.isInteger(n)&&n>0?n:0),{user:f}=$(),o=c&&c.user_id===(f==null?void 0:f.id)?c:void 0,{data:D,isLoading:P}=z(),E=L||P,U=G(D),A=de(),[m,C]=g.useState(!1),[R,B]=g.useState(!1),[q,_]=g.useState(null),{control:N,handleSubmit:O,reset:x,setValue:V,watch:y,getValues:M,formState:{isDirty:W}}=H({defaultValues:{imagem_url:null,banner_desktop_url:null,banner_mobile_url:null,banner_link:null}}),h=o==null?void 0:o.id,{stash:F,take:K,clear:X}=ue(h?`category-media:${h}`:null);g.useEffect(()=>{if(!o)return;x({imagem_url:o.imagem_url??null,banner_desktop_url:o.banner_desktop_url??null,banner_mobile_url:o.banner_mobile_url??null,banner_link:o.banner_link??null});const r=K();r&&x(r,{keepDefaultValues:!0})},[h]);const J=y("imagem_url"),w=y("banner_desktop_url"),I=y("banner_mobile_url"),k=(r,d)=>V(r,d,{shouldDirty:!0}),Q=()=>new Promise((r,d)=>{O(async u=>{_(null);const T=!!(u.banner_mobile_url||u.banner_desktop_url);if(T&&(R||!ne(u.banner_link))){_("Confira o link do banner: digite um endereço completo."),d(new Error("invalid link"));return}C(!0);try{const t={imagem_url:p(u.imagem_url),banner_desktop_url:p(u.banner_desktop_url),banner_mobile_url:p(u.banner_mobile_url),banner_link:T?p(u.banner_link):null};await A.mutateAsync({id:n,...t}),x(t),X(),se(oe.STORE.CUSTOMIZE_COMPLETE,{stage:"category_media",imagem:!!t.imagem_url,banner:!!(t.banner_desktop_url||t.banner_mobile_url)}),r()}catch(t){_("Não foi possível salvar. Tente novamente."),d(t instanceof Error?t:new Error("save failed"))}finally{C(!1)}},()=>d(new Error("validation failed")))()}),s=!E&&!U?{plan:"pro",trigger:"category_media"}:void 0;return e.jsx(ie,{title:"Imagem e banner",isLoading:E,isDirty:W,isSaving:m,onSave:Q,saveError:q,lock:s,onBeforePaywall:()=>F(M()),children:o?e.jsxs(j,{spacing:2,children:[e.jsxs(l,{variant:"caption",color:"text.secondary",sx:{display:"block",ml:.5,mt:-1},children:["Categoria ",o.nome]}),s&&e.jsx(ae,{severity:"info",title:"Recurso do plano PRO",children:"Você pode preparar as imagens aqui. Para publicar na loja, assine o PRO ao salvar."}),e.jsxs(i,{children:[e.jsx(l,{sx:S,children:"Imagem da categoria"}),e.jsx(i,{sx:b,children:e.jsxs(j,{direction:{xs:"column",md:"row"},spacing:2,alignItems:"flex-start",children:[e.jsx(l,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:{xs:1.25,md:0},order:{md:2}},children:"Aparece na seção Categorias da página inicial. Sem ela, a loja usa a foto de um produto da categoria."}),e.jsx(i,{sx:{width:"100%",maxWidth:220,flexShrink:0},children:e.jsx(v,{type:"square",imageUrl:J??"",onImageChange:r=>k("imagem_url",r),disabled:m,lockedTrigger:s==null?void 0:s.trigger})})]})})]}),e.jsxs(i,{children:[e.jsx(l,{sx:S,children:"Banner da categoria"}),e.jsx(l,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:1.25,ml:.5},children:"Aparece no topo da página desta categoria, no lugar do banner da loja."}),e.jsxs(j,{spacing:2,children:[e.jsxs(i,{sx:b,children:[e.jsx(l,{variant:"body2",sx:{fontWeight:600,mb:1.25},children:"Computador"}),e.jsx(v,{type:"desktop",imageUrl:w??"",onImageChange:r=>k("banner_desktop_url",r),disabled:m,lockedTrigger:s==null?void 0:s.trigger})]}),e.jsxs(i,{sx:b,children:[e.jsx(l,{variant:"body2",sx:{fontWeight:600,mb:1.25},children:"Celular"}),e.jsx(i,{sx:{maxWidth:360},children:e.jsx(v,{type:"mobile",imageUrl:I??"",onImageChange:r=>k("banner_mobile_url",r),disabled:m,lockedTrigger:s==null?void 0:s.trigger})})]})]})]}),(I||w)&&e.jsxs(i,{children:[e.jsx(l,{sx:S,children:"Link do banner"}),e.jsx(i,{sx:b,children:e.jsx(re,{name:"banner_link",control:N,render:({field:r})=>e.jsx(te,{value:r.value??null,onChange:d=>r.onChange(d),onInvalidChange:B,disabled:m})})})]})]}):e.jsx(ee,{primaryText:"Categoria não encontrada",secondaryText:"Ela pode ter sido excluída."})})};export{Re as default};

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.