PageSourceSearch

https://www.xpark.ai/assets/AdminPricing-BxEGlmdS.js

js xpark.ai collected 2026-10-05 14:02:29 UTC 8,083 bytes, 3 lines download raw bytes

1import{j as e,a0 as b,a5 as R,r as m,f as h,a6 as w,a7 as A,a8 as g,B as C,a9 as E,I as c,J as I,a3 as L,d as T,g as j}from"./index-FWKSGZPO.js";import{T as P,a as B,b as _,c as y}from"./tabs-BQ8VhpUK.js";import{C as q,c as k}from"./card-DTQVPU97.js";import{S}from"./save-BrOyRopU.js";function $(){const p=b(),{data:d,isLoading:f}=R(),[N,x]=m.useState([]),[o,u]=m.useState(null);m.useEffect(()=>{d&&x(d)},[d]);const l=(a,n)=>x(i=>i.map(r=>r.id===a?{...r,...n}:r)),v=async a=>{u(a.id);const{error:n}=await T.from("locations").update({name:a.name,price_per_day:Number(a.rate_1_6)||0,rate_1_6:a.rate_1_6,rate_7_12:a.rate_7_12,fixed_13_17:a.fixed_13_17,fixed_18_30:a.fixed_18_30,rate_31_plus:a.rate_31_plus,features:a.features,sort_order:a.sort_order,public_description:a.public_description,status:a.status}).eq("id",a.id);if(u(null),n){j.error("Falha ao salvar",{description:n.message});return}j.success("Tier atualizado"),p.invalidateQueries({queryKey:["tiers"]})};if(f)return e.jsx("div",{className:"flex justify-center py-10",children:e.jsx(h,{className:"h-5 w-5 animate-spin"})});const s=new Map;for(const a of N)s.has(a.airport_code)||s.set(a.airport_code,[]),s.get(a.airport_code).push(a);const t=(a,n)=>e.jsx(c,{type:"number",step:"0.01",value:a??0,onChange:i=>n(Number(i.target.value)),className:"h-9 w-full text-right text-sm"});return e.jsx("div",{className:"space-y-6",children:Array.from(s.entries()).map(([a,n])=>e.jsx(q,{children:e.jsxs(k,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Aeroporto"}),e.jsx("h2",{className:"text-lg font-semibold",children:w(a)})]}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-sm text-right",children:"Edite os preços por tipo de vaga e por faixa de diárias. Salve cada linha individualmente."})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm table-fixed",children:[e.jsxs("colgroup",{children:[e.jsx("col",{}),e.jsx("col",{className:"w-32"}),e.jsx("col",{className:"w-32"}),e.jsx("col",{className:"w-32"}),e.jsx("col",{className:"w-32"}),e.jsx("col",{className:"w-32"}),e.jsx("col",{className:"w-20"}),e.jsx("col",{className:"w-20"})]}),e.jsx("thead",{className:"text-muted-foreground",children:e.jsxs("tr",{className:"border-b",children:[e.jsx("th",{className:"py-2 pr-3 text-left font-medium",children:"Tipo de vaga"}),e.jsx("th",{className:"py-2 px-2 text-center font-medium",children:"1–6 (R$/dia)"}),e.jsx("th",{className:"py-2 px-2 text-center font-medium",children:"7–12 (R$/dia)"}),e.jsx("th",{className:"py-2 px-2 text-center font-medium",children:"13–17 (total)"}),e.jsx("th",{className:"py-2 px-2 text-center font-medium",children:"18–30 (total)"}),e.jsx("th",{className:"py-2 px-2 text-center font-medium",children:"31+ (R$/dia)"}),e.jsx("th",{className:"py-2 px-2 text-center font-medium",children:"Ativo"}),e.jsx("th",{className:"py-2 px-2 text-center font-medium",children:"Ação"})]})}),e.jsx("tbody",{children:n.map(i=>e.jsxs("tr",{className:"border-b align-middle",children:[e.jsxs("td",{className:"py-2 pr-3",children:[e.jsx("div",{className:"font-medium",children:A[i.category]??i.category}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:i.name})]}),e.jsx("td",{className:"py-2 px-2",children:t(i.rate_1_6,r=>l(i.id,{rate_1_6:r}))}),e.jsx("td",{className:"py-2 px-2",children:t(i.rate_7_12,r=>l(i.id,{rate_7_12:r}))}),e.jsx("td",{className:"py-2 px-2",children:t(i.fixed_13_17,r=>l(i.id,{fixed_13_17:r}))}),e.jsx("td",{className:"py-2 px-2",children:t(i.fixed_18_30,r=>l(i.id,{fixed_18_30:r}))}),e.jsx("td",{className:"py-2 px-2",children:t(i.rate_31_plus,r=>l(i.id,{rate_31_plus:r}))}),e.jsx("td",{className:"py-2 px-2 text-center",children:e.jsx(g,{checked:i.status==="active",onCheckedChange:r=>l(i.id,{status:r?"active":"draft"})})}),e.jsx("td",{className:"py-2 px-2 text-center",children:e.jsx(C,{onClick:()=>v(i),disabled:o===i.id,size:"sm",variant:"outline",children:o===i.id?e.jsx(h,{className:"h-4 w-4 animate-spin"}):e.jsx(S,{className:"h-4 w-4"})})})]},i.id))})]})})]})},a))})}function z(){const p=b(),{data:d,isLoading:f}=E({includeInactive:!0}),[N,x]=m.useState([]),[o,u]=m.useState(null);m.useEffect(()=>{d&&x(d)},[d]);const l=(s,t)=>x(a=>a.map(n=>n.id===s?{...n,...t}:n)),v=async s=>{u(s.id);const{error:t}=await T.from("plans").update({name:s.name,tagline:s.tagline,freq:s.freq,monthly_price:s.monthly_price,yearly_price:s.yearly_price,includes:s.includes,recommended:s.recommended,sort_order:s.sort_order,active:s.active}).eq("id",s.id);if(u(null),t){j.error("Falha ao salvar",{description:t.message});return}j.success("Plano atualizado"),p.invalidateQueries({queryKey:["plans"]})};return f?e.jsx("div",{className:"flex justify-center py-10",children:e.jsx(h,{className:"h-5 w-5 animate-spin"})}):e.jsx("div",{className:"space-y-4",children:N.map(s=>e.jsx(q,{children:e.jsxs(k,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:s.slug}),e.jsx(c,{className:"mt-1 font-medium",value:s.name,onChange:t=>l(s.id,{name:t.target.value})})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx(g,{checked:s.recommended,onCheckedChange:t=>l(s.id,{recommended:t})})," Recomendado"]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx(g,{checked:s.active,onCheckedChange:t=>l(s.id,{active:t})})," Ativo"]})]})]}),e.jsx(c,{placeholder:"Tagline",value:s.tagline,onChange:t=>l(s.id,{tagline:t.target.value})}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Frequência"}),e.jsx(c,{value:s.freq,onChange:t=>l(s.id,{freq:t.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Mensal (R$)"}),e.jsx(c,{type:"number",step:"0.01",value:s.monthly_price,onChange:t=>l(s.id,{monthly_price:Number(t.target.value)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Total/ano (R$)"}),e.jsx(c,{type:"number",step:"0.01",value:s.yearly_price,onChange:t=>l(s.id,{yearly_price:Number(t.target.value)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Ordem"}),e.jsx(c,{type:"number",value:s.sort_order,onChange:t=>l(s.id,{sort_order:Number(t.target.value)})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:"Benefícios (um por linha)"}),e.jsx(I,{rows:4,value:(s.includes??[]).join(`
2`),onChange:t=>l(s.id,{includes:t.target.value.split(`
3`).map(a=>
3a.trim()).filter(Boolean)})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Cobrado no checkout: ",e.jsx("span",{className:"font-medium text-foreground",children:L(Number(s.yearly_price))})]}),e.jsxs(C,{onClick:()=>v(s),disabled:o===s.id,size:"sm",children:[o===s.id?e.jsx(h,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),"Salvar"]})]})]})},s.id))})}function O(){return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Preços"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Os valores ajustados aqui aparecem imediatamente nas páginas de reserva e de planos."})]}),e.jsxs(P,{defaultValue:"tiers",children:[e.jsxs(B,{children:[e.jsx(_,{value:"tiers",children:"Tiers de estacionamento"}),e.jsx(_,{value:"plans",children:"Planos de assinatura"})]}),e.jsx(y,{value:"tiers",className:"mt-4",children:e.jsx($,{})}),e.jsx(y,{value:"plans",className:"mt-4",children:e.jsx(z,{})})]})]})}export{O 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.