PageSourceSearch

https://acientistaagricola.pt/_next/static/chunks/1864-0279d87a8f21e05f.js

js acientistaagricola.pt collected 2026-09-24 21:26:58 UTC 10,996 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1864],{25229:(e,a,t)=>{t.r(a),t.d(a,{ProductsGrid:()=>S});var r=t(52189),s=t(75209),l=t(42093),i=t.n(l),n=t(20556),o=t(1011),d=t(53019),c=t(87031),u=t(34435),m=t(32893),x=t(66866),p=t(36596);let g=(0,p.createServerReference)("60a019e039ec59add77bb62cb03e134f509a0f089d",p.callServer,void 0,p.findSourceMapURL,"setProductVisibility");var b=t(60532);let h=(0,p.createServerReference)("404ca6dddb947c20f3c59573655292459c1219c25f",p.callServer,void 0,p.findSourceMapURL,"countProductArticleUses");var y=t(77421);let f=(0,p.createServerReference)("402a5a89f3bb890671d60b8fde1171a66a913f916e",p.callServer,void 0,p.findSourceMapURL,"getProductsData"),v={active:"bg-green-50 text-green-700",unavailable:"bg-amber-50 text-amber-700",deleted:"bg-red-50 text-red-600"},j={physical:"F\xedsico",digital:"Digital",subscription:"Subscri\xe7\xe3o"},N=e=>(e/100).toLocaleString("pt-PT",{style:"currency",currency:"EUR"});function S(e){let{categories:a}=e,[t,l]=(0,s.useState)(0),p=()=>l(e=>e+1),S=async e=>{await e,p()},k=[{key:"name",header:"Nome",isSortable:!0,isFiltrable:!0,priority:"maxima",render:e=>(0,r.jsxs)("div",{children:[(0,r.jsx)(i(),{href:"/admin/products/".concat(e.id),className:"font-medium text-gray-800 hover:text-green-700",children:e.name}),(0,r.jsxs)("span",{className:"block text-xs text-gray-400",children:["/",e.slug]})]})},{key:"price",header:"Pre\xe7o",isSortable:!0,align:"right",priority:"media",render:e=>e.price_from?(0,r.jsxs)("span",{children:[(0,r.jsx)("span",{className:"text-xs text-gray-400",children:"desde "}),N(e.price_cents)]}):N(e.price_cents)},{key:"stock",header:"Stock",isSortable:!0,align:"right",customFilter:(0,x.d)([{value:"sem_controlo",label:"Sem controlo"},{value:"com_controlo",label:"Com controlo"},{value:"lowstock",label:"LowStock"}]),render:e=>null===e.stock?"Ilimitado":e.stock},{key:"type",header:"Tipo",isSortable:!0,customFilter:(0,x.d)([{value:"physical",label:"F\xedsico"},{value:"digital",label:"Digital"},{value:"subscription",label:"Subscri\xe7\xe3o"}]),render:e=>{var a;return null!=(a=j[e.product_type])?a:e.product_type}},{key:"category",header:"Categoria",customFilter:(0,x.d)(a),render:e=>{var a;return null!=(a=e.category_name)?a:"—"}},{key:"points",header:"Pontos",isSortable:!0,align:"right",customFilter:{render:(e,a)=>(0,r.jsxs)("label",{className:"inline-flex items-center gap-1.5 text-xs text-gray-600",children:[(0,r.jsxs)("span",{className:"relative inline-flex h-4 w-7 shrink-0 items-center",children:[(0,r.jsx)("input",{type:"checkbox",checked:"1"===e,onChange:e=>a(e.target.checked?"1":""),className:"peer sr-only"}),(0,r.jsx)("span",{className:"absolute inset-0 rounded-full bg-gray-300 transition-colors peer-checked:bg-green-600"}),(0,r.jsx)("span",{className:"absolute left-0.5 top-0.5 h-3 w-3 rounded-full bg-white transition-transform peer-checked:translate-x-3"})]}),"> 0"]})},render:e=>e.points_per_unit>0?e.points_per_unit:"—"},{key:"status",header:"Estado",isSortable:!0,priority:"media",customFilter:(0,x.d)([{value:"active",label:"Ativo"},{value:"unavailable",label:"Indispon\xedvel"},{value:"deleted",label:"Apagado"}]),render:e=>(0,r.jsx)("span",{className:"inline-flex rounded-full px-2.5 py-0.5 text-xs font-medium ".concat(v[e.status]),children:(0,m.lZ)(e.status)})}],A=[{icon:(0,r.jsx)(n.A,{size:16}),label:"Ver no site",href:e=>"/agrostore/".concat(e.slug),external:!0},{icon:e=>e.is_visible?(0,r.jsx)(o.A,{size:16}):(0,r.jsx)(d.A,{size:16}),label:e=>e.is_visible?"Ocultar das listagens":"Tornar vis\xedvel",onClick:e=>void S(g(e.id,!e.is_visible)),hidden:e=>"deleted"===e.status},{icon:e=>"deleted"===e.status?(0,r.jsx)(c.A,{size:16}):(0,r.jsx)(u.A,{size:16}),label:e=>"deleted"===e.status?"Restaurar":"Apagar",tone:"danger",onClick:e=>{if("deleted"===e.status)return void S((0,b.U)(e.id,"active"));h(e.id).then(a=>{let t=a?" Aten\xe7\xe3o: est\xe1 em ".concat(a," artigo").concat(1===a?"":"s"," — o cart\xe3o deixa de aparecer neles."):"";confirm('Apagar "'.concat(e.name,'"? Fica apagado (l\xf3gico) e pode ser restaurado.').concat(t))&&S((0,y.D)(e.id))})}}],C=[{ui:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.A,{size:15})," Ocultar"]}),onClick:async e=>{await Promise.all(e.map(e=>g(e,!1))),p()}},{ui:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.A,{size:15})," Apagar"]}),tone:"danger",onClick:async e=>{confirm("Apagar ".concat(e.length," produto(s)?"))&&(await Promise.all(e.map(e=>(0,y.D)(e))),p())}}];return(0,r.jsx)(x.z,{columns:k,getData:f,getRowKey:e=>e.id,rowActions:A,bulkActions:C,selectable:!0,selectAll:!0,perPage:20,defaultSort:{key:"name",dir:"asc"},emptyLabel:"Sem produtos.",refreshKey:t})}},35082:(e,a,t)=>{t.r(a),t.d(a,{CategoriesManager:()=>g});var r=t(52189),s=t(75209),l=t(12750),i=t(34435),n=t(20556),o=t(39180),d=t(66866),c=t(36596);let u=(0,c.createServerReference)("402b15e74df6920975cb5a8bc71a8c14fa73193940",c.callServer,void 0,c.findSourceMapURL,"s
1aveCategory"),m=(0,c.createServerReference)("40f462e5cdda7aef24962371e8c8daee41230dd660",c.callServer,void 0,c.findSourceMapURL,"deleteCategory"),x=(0,c.createServerReference)("603eff1a0bca72e04fad7545ef062baf12efb6d4d4",c.callServer,void 0,c.findSourceMapURL,"listCategoryProducts"),p={root:"space-y-6",form:"grid grid-cols-1 gap-4 rounded-xl border border-gray-200 bg-white p-5 sm:grid-cols-[2fr_2fr_5rem_auto]",colName:"sm:col-span-1",label:"mb-1 block text-sm font-medium text-gray-700",field:"w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-green-500",formActions:"flex items-end justify-end gap-2",primaryBtn:"rounded-lg bg-green-600 px-5 py-2 text-sm font-medium text-white hover:bg-green-700 disabled:opacity-50",secondaryBtn:"rounded-lg border border-gray-300 px-4 py-2 text-sm font-medium text-gray-600 hover:bg-gray-50",tableWrap:"overflow-hidden rounded-xl border border-gray-200 bg-white",table:"w-full text-sm",thead:"bg-gray-50 text-left text-xs uppercase tracking-wide text-gray-500",th:"px-4 py-2 font-medium",tr:"border-t border-gray-100",td:"px-4 py-2 text-gray-600",tdName:"px-4 py-2 font-medium text-gray-800",tdSlug:"px-4 py-2 font-mono text-xs text-gray-500",tdActions:"px-4 py-2 text-right",linkBtn:"text-xs font-medium text-gray-600 hover:text-gray-900",dangerBtn:"text-red-600 hover:text-red-800 disabled:cursor-not-allowed disabled:opacity-30",empty:"px-4 py-8 text-center text-sm text-gray-400",subTitle:"mb-1 font-display text-[19px] text-strong",subHelp:"mb-3 text-sm text-gray-500"};function g(e){var a,t,n,d;let{categories:c}=e,[x,g]=(0,s.useState)(null),[b,h]=(0,s.useTransition)(),{showToast:f}=(0,o.dj)(),v=(0,l.useRouter)(),j=()=>v.refresh(),N=null===x;return(0,r.jsxs)("div",{className:p.root,children:[(0,r.jsxs)("form",{action:function(e){h(async()=>{let{error:a}=await u(e);if(a)return f(a,"error");f(N?"Categoria criada.":"Categoria atualizada.","success"),g(null),j()})},className:p.form,children:[x&&(0,r.jsx)("input",{type:"hidden",name:"id",value:x.id}),(0,r.jsxs)("div",{className:p.colName,children:[(0,r.jsx)("label",{className:p.label,children:"Nome *"}),(0,r.jsx)("input",{name:"name",required:!0,defaultValue:null!=(a=null==x?void 0:x.name)?a:"",placeholder:"Sementes",className:p.field})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p.label,children:"Slug"}),(0,r.jsx)("input",{name:"slug",defaultValue:null!=(t=null==x?void 0:x.slug)?t:"",placeholder:"(gerado do nome)",className:"".concat(p.field," font-mono text-xs")})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:p.label,children:"Ordem"}),(0,r.jsx)("input",{name:"sort_order",type:"number",defaultValue:null!=(n=null==x?void 0:x.sortOrder)?n:0,className:p.field})]}),(0,r.jsxs)("div",{className:p.formActions,children:[!N&&(0,r.jsx)("button",{type:"button",onClick:()=>g(null),className:p.secondaryBtn,children:"Cancelar"}),(0,r.jsx)("button",{type:"submit",disabled:b,className:p.primaryBtn,children:N?"Adicionar":"Guardar"})]})]},null!=(d=null==x?void 0:x.id)?d:"nova"),(0,r.jsx)("div",{className:p.tableWrap,children:(0,r.jsx)("div",{className:"overflow-x-auto",children:(0,r.jsxs)("table",{className:p.table,children:[(0,r.jsx)("thead",{className:p.thead,children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:p.th,children:"Nome"}),(0,r.jsx)("th",{className:p.th,children:"Slug"}),(0,r.jsx)("th",{className:p.th,children:"Ordem"}),(0,r.jsx)("th",{className:p.th,children:"Em uso"}),(0,r.jsx)("th",{className:"px-4 py-2"})]})}),(0,r.jsxs)("tbody",{children:[c.map(e=>(0,r.jsxs)("tr",{className:p.tr,children:[(0,r.jsx)("td",{className:p.tdName,children:e.name}),(0,r.jsx)("td",{className:p.tdSlug,children:e.slug}),(0,r.jsx)("td",{className:p.td,children:e.sortOrder}),(0,r.jsx)("td",{className:p.td,children:0===e.usageCount?(0,r.jsx)("span",{className:"text-gray-400",children:"—"}):"".concat(e.usageCount)}),(0,r.jsx)("td",{className:p.tdActions,children:(0,r.jsxs)("span",{className:"inline-flex items-center gap-3",children:[(0,r.jsx)("button",{type:"button",onClick:()=>g(e),className:p.linkBtn,children:(null==x?void 0:x.id)===e.id?"A editar":"Editar"}),(0,r.jsx)("button",{type:"button",disabled:b||e.usageCount>0,title:e.usageCount>0?"Em uso por ".concat(e.usageCount," ").concat(1===e.usageCount?"item":"itens"," — mude-os de categoria primeiro"):"Apagar",onClick:()=>{confirm('Apagar a categoria "'.concat(e.name,'"?'))&&h(async()=>{let{error:a}=await m(e.id);if(a)return f(a,"error");f('Categoria "'.concat(e.name,'" apagada.'),"success"),(null==x?void 0:x.id)===e.id&&g(null),j()})},className:p.dangerBtn,"aria-label":"Apagar ".concat(e.name),children:(0,r.jsx)(i.A,{size:14})})]})})]},e.id)),0===c.length&&(0,r.jsx)("tr",{children:(0,r.jsx)("td",{colSpan:5,className:p.empty,children:"Ainda n\xe3o h\xe1 categorias."})})]})]})})}),x&&(0,r.jsx)(y,{category:x})]})}let b=[{key:"name",header:"Produto",isSortable:!0,isFiltrable:!0,priority:"maxima",render:e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"font-medium text-gray-800",children:e.name}),(0,r.jsxs)("span",{className:"block text-xs text-gray-400",children:["/",e.slug]})]})},{key:"status",header:"Estado",isSortable:!0,priority:"media",render:e=>"active"===e.status?"Ativo":"unavailable"===e.status?"Indispon\xedvel":e.status},{key:"visible",header:"Na loja",priority:"baixa",render:e=>e.isVisible?"Sim":"N\xe3o"}],h=[{icon:(0,r.jsx)(n.A,{size:15}),label:"Abrir ficha (nova aba)",href:e=>"/admin/products/".concat(e.id),external:!0}];function y(e){let{category:a}=e,t=(0,s.useCallback)(e=>x(a.id,e),[a.id]);return(0,r.jsxs)("div",{children:[(0,r.jsxs)("h3",{className:p.subTitle,children:["Produtos em “",a.name,"”"]}),(0,r.jsx)("p",{className:p.subHelp,children:"Para poder apagar a categoria, todos estes t\xeam de sair primeiro. Abre a ficha (nova aba), muda a categoria, e carrega em Atualizar aqui."}),(0,r.jsx)(d.z,{columns:b,getData:t,getRowKey:e=>e.id,rowActions:h,paginated:!0,perPage:10,emptyLabel:"Nenhum produto nesta categoria."},a.id)]})}}}]);

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.