PageSourceSearch

https://hotelvilainglesa.com.br/assets/AccommodationsManager-YHTO0vVW.js

js hotelvilainglesa.com.br collected 2026-09-26 10:28:04 UTC 15,253 bytes, 1 lines download raw bytes

1import{j as e,a as X,u as Y,b as _}from"./vendor-query-CO_QYTkO.js";import{a as F,r as A}from"./vendor-react-DJfEFaqw.js";import{m as u,X as I,Y as T,Z as P,$ as Q,a0 as k,W as R,c as j,w as g,D as Z,x as J,y as ee,z as se,am as ae,I as D,T as re,V as z,s as f}from"./index-BuBFkYNO.js";import{C as E,a as ie,b as te,d as q}from"./card-6llgUU3N.js";import{S as ne}from"./scroll-area-CMwJyNM9.js";import{u as oe}from"./useAccommodationDisplaySettings-Dg3z5qGy.js";import{aq as V,b8 as le,b7 as de,b6 as ce,P as B,X as me,D as M,a6 as ue,as as xe,aa as pe}from"./vendor-icons-BmcpZVdY.js";import{u as he,a as H,D as ge,c as je,S as ve,v as fe,d as be,C as Ne,K as ye,P as Ce,b as Se}from"./vendor-dnd-Ds4KDHQQ.js";import"./vendor-ui-CCUQhf4y.js";import"./vendor-supabase-MEHSyf2E.js";import"./vendor-router-CkFJCvFZ.js";import"./vendor-helmet-Cc4zoVvE.js";import"./vendor-sanitize-D9RiKzGB.js";import"./vendor-codemirror-kF8_xaBD.js";import"./vendor-carousel-DpjaRhUe.js";const _e=[{value:"4:3",label:"4:3 (Paisagem)"},{value:"1:1",label:"1:1 (Quadrado)"},{value:"3:4",label:"3:4 (Retrato)"},{value:"16:9",label:"16:9 (Widescreen)"},{value:"9:16",label:"9:16 (Vertical)"}],K=[{key:"mobile",label:"Mobile",icon:le},{key:"tablet",label:"Tablet",icon:de},{key:"desktop",label:"Desktop",icon:ce}],we=()=>{const{settings:i,isLoading:b,updateSettings:x,isUpdating:p}=oe(),[l,a]=F.useState(i);F.useEffect(()=>{a(i)},[i]);const m=(r,t)=>{a(d=>({...d,imageAspectRatio:{...d.imageAspectRatio,[r]:t}}))},o=(r,t)=>{a(d=>({...d,cardBorderRadius:{...d.cardBorderRadius,[r]:t[0]}}))},N=()=>{x(l,{onSuccess:()=>g.success("Configurações de exibição salvas!"),onError:()=>g.error("Erro ao salvar configurações")})};return b?null:e.jsxs(E,{children:[e.jsx(ie,{children:e.jsx(te,{className:"text-lg",children:"Configurações de Exibição"})}),e.jsxs(q,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(u,{className:"text-sm font-semibold",children:"Proporção da Imagem"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:K.map(({key:r,label:t,icon:d})=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(d,{className:"w-4 h-4"}),e.jsx("span",{children:t})]}),e.jsxs(I,{value:l.imageAspectRatio[r],onValueChange:h=>m(r,h),children:[e.jsx(T,{children:e.jsx(P,{})}),e.jsx(Q,{children:_e.map(h=>e.jsx(k,{value:h.value,children:h.label},h.value))})]})]},r))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(u,{className:"text-sm font-semibold",children:"Arredondamento do Card (px)"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:K.map(({key:r,label:t,icon:d})=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(d,{className:"w-4 h-4"}),e.jsxs("span",{children:[t," — ",l.cardBorderRadius[r],"px"]})]}),e.jsx(R,{value:[l.cardBorderRadius[r]],onValueChange:h=>o(r,h),min:0,max:40,step:2})]},r))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"text-sm font-semibold",children:"Ordem por Tipo de Prédio"}),e.jsxs(I,{value:l.buildingTypeOrder||"historico_first",onValueChange:r=>a(t=>({...t,buildingTypeOrder:r})),children:[e.jsx(T,{children:e.jsx(P,{})}),e.jsxs(Q,{children:[e.jsx(k,{value:"historico_first",children:"Alternado: Histórico → Contemporâneo"}),e.jsx(k,{value:"contemporaneo_first",children:"Alternado: Contemporâneo → Histórico"}),e.jsx(k,{value:"none",children:"Sem alternância (ordem manual)"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define a ordem alternada de exibição dos apartamentos por tipo de prédio."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"text-sm font-semibold",children:"Tamanho da Etiqueta (Histórico/Contemporâneo)"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R,{value:[l.badgeFontSize??7],onValueChange:r=>a(t=>({...t,badgeFontSize:r[0]})),min:4,max:48,step:1,className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"number",min:1,max:200,value:l.badgeFontSize??7,onChange:r=>{const t=parseInt(r.target.value,10);a(d=>({...d,badgeFontSize:Number.isNaN(t)?7:t}))},className:"w-20 h-9 px-2 text-sm rounded-md border border-input bg-background"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"px"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Tamanho da fonte da etiqueta exibida sobre as imagens das acomodações. Você pode digitar qualquer valor."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"text-sm font-semibold",children:"Cor de Fundo da Página"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:l.pageBackgroun
1dColor||"#173745",onChange:r=>a(t=>({...t,pageBackgroundColor:r.target.value})),className:"w-12 h-10 rounded-md border border-input cursor-pointer"}),e.jsx("input",{type:"text",value:l.pageBackgroundColor||"#173745",onChange:r=>a(t=>({...t,pageBackgroundColor:r.target.value})),className:"flex-1 h-10 px-3 text-sm rounded-md border border-input bg-background"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"text-sm font-semibold",children:"Cor de Fundo dos Cards"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:l.cardBackgroundColor||"#f5f0e6",onChange:r=>a(t=>({...t,cardBackgroundColor:r.target.value})),className:"w-12 h-10 rounded-md border border-input cursor-pointer"}),e.jsx("input",{type:"text",value:l.cardBackgroundColor||"#f5f0e6",onChange:r=>a(t=>({...t,cardBackgroundColor:r.target.value})),className:"flex-1 h-10 px-3 text-sm rounded-md border border-input bg-background"})]})]})]}),e.jsxs(j,{onClick:N,disabled:p,className:"w-full",children:[e.jsx(V,{className:"w-4 h-4 mr-2"}),p?"Salvando...":"Salvar Configurações de Exibição"]})]})]})},Me=()=>{const i=X(),[b,x]=A.useState(!1),[p,l]=A.useState(null),[a,m]=A.useState({name:"",description:"",price:"",image_url:"",image_alt:"",link:"",is_enabled:!0,building_type:"Histórico"}),{data:o,isLoading:N}=Y({queryKey:["accommodations-admin"],queryFn:async()=>{const{data:s,error:n}=await f.from("accommodations").select("*").order("sort_order");if(n)throw n;return s}}),r=_({mutationFn:async s=>{const n=(o==null?void 0:o.length)||0,{error:c}=await f.from("accommodations").insert([{name:s.name,price:s.price,description:s.description,image_url:s.image_url,image_alt:s.image_alt,link:s.link,is_enabled:s.is_enabled,building_type:s.building_type||"Histórico",sort_order:n}]);if(c)throw c},onSuccess:()=>{i.invalidateQueries({queryKey:["accommodations-admin"]}),i.invalidateQueries({queryKey:["accommodations"]}),g.success("Acomodação criada com sucesso!"),y()},onError:s=>{g.error("Erro ao criar acomodação: "+s.message)}}),t=_({mutationFn:async({id:s,data:n})=>{const{error:c}=await f.from("accommodations").update(n).eq("id",s);if(c)throw c},onSuccess:()=>{i.invalidateQueries({queryKey:["accommodations-admin"]}),i.invalidateQueries({queryKey:["accommodations"]}),g.success("Acomodação atualizada com sucesso!"),y()},onError:s=>{g.error("Erro ao atualizar acomodação: "+s.message)}}),d=_({mutationFn:async s=>{const{error:n}=await f.from("accommodations").delete().eq("id",s);if(n)throw n},onSuccess:()=>{i.invalidateQueries({queryKey:["accommodations-admin"]}),i.invalidateQueries({queryKey:["accommodations"]}),g.success("Acomodação removida com sucesso!")},onError:s=>{g.error("Erro ao remover acomodação: "+s.message)}}),h=_({mutationFn:async({id:s,is_enabled:n})=>{const{error:c}=await f.from("accommodations").update({is_enabled:n}).eq("id",s);if(c)throw c},onSuccess:()=>{i.invalidateQueries({queryKey:["accommodations-admin"]}),i.invalidateQueries({queryKey:["accommodations"]})}}),O=_({mutationFn:async s=>{const n=s.map(({id:C,sort_order:w})=>f.from("accommodations").update({sort_order:w}).eq("id",C)),v=(await Promise.all(n)).find(C=>C.error);if(v!=null&&v.error)throw v.error},onSuccess:()=>{i.invalidateQueries({queryKey:["accommodations-admin"]}),i.invalidateQueries({queryKey:["accommodations"]})}}),L=he(H(Ce,{activationConstraint:{distance:5}}),H(ye)),$=s=>{const{active:n,over:c}=s;if(!c||n.id===c.id||!o)return;const v=o.findIndex(S=>S.id===n.id),C=o.findIndex(S=>S.id===c.id),w=Se(o,v,C);i.setQueryData(["accommodations-admin"],w),O.mutate(w.map((S,W)=>({id:S.id,sort_order:W})))},y=()=>{m({name:"",description:"",price:"",image_url:"",image_alt:"",link:"",is_enabled:!0,building_type:"Histórico"}),l(null),x(!1)},G=s=>{l(s.id),m({name:s.name,description:s.description||"",price:s.price,image_url:s.image_url||"",image_alt:s.image_alt||"",link:s.link||"",is_enabled:s.is_enabled,building_type:s.building_type||"Histórico"}),x(!0)},U=s=>{if(s.preventDefault(),!a.name||!a.price){g.error("Nome e preço são obrigatórios");return}p?t.mutate({id:p,data:a}):r.mutate(a)};return N?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Acomodações"}),e.jsx("p",{className:"text-muted-foreground",children:"Gerencie as acomodações do hotel"})]}),e.jsxs(j,{onClick:()=>{y(),x(!0)},children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"Nova Acomodação"]})]}),e.jsx(we,{}),e.jsx(Z,{open:b,onOpenChange:s=>{s?x(!0):y()},children:e.jsxs(J,{className:"max-w-2xl max-h-[90vh]",children:[e.jsx(ee,{children:e.jsx(se,{children:p?"Editar Acomodação":"Nova Acomodação"})}),e.jsx(ne,{className:"max-h-[calc(90vh-120px)] pr-4",children:e.jsxs("form",{onSubmit:U,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{className:"text-sm font-medium",children:"Imagem da Acomodação"}),e.jsx(ae,{value:a.image_url||"",onChange:s=>m({...a,image_url:s}),altValue:a.image_alt||"",onAltChange:s=>m({...a,image_alt:s})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"name",children:"Nome *"}),e.jsx(D,{id:"name",value:a.name,onChange:s=>m({...a,name:s.target.value}),placeholder:"Ex: Standard, Superior, Luxo"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"price",children:"Preç
1o *"}),e.jsx(D,{id:"price",value:a.price,onChange:s=>m({...a,price:s.target.value}),placeholder:"Ex: R$ 1.324,40"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"building_type",children:"Tipo de Prédio"}),e.jsxs("select",{id:"building_type",value:a.building_type||"Histórico",onChange:s=>m({...a,building_type:s.target.value}),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"Histórico",children:"Histórico"}),e.jsx("option",{value:"Contemporâneo",children:"Contemporâneo"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"description",children:"Descrição"}),e.jsx(re,{id:"description",value:a.description||"",onChange:s=>m({...a,description:s.target.value}),placeholder:"Descrição detalhada da acomodação...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(u,{htmlFor:"link",children:"Link de Reserva"}),e.jsx(D,{id:"link",value:a.link||"",onChange:s=>m({...a,link:s.target.value}),placeholder:"/acomodacoes/standard ou https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{children:[e.jsx(u,{htmlFor:"is_enabled",className:"font-medium",children:"Acomodação Ativa"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Desative para ocultar do site"})]}),e.jsx(z,{id:"is_enabled",checked:a.is_enabled,onCheckedChange:s=>m({...a,is_enabled:s})})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t",children:[e.jsxs(j,{type:"button",variant:"outline",onClick:y,className:"flex-1",children:[e.jsx(me,{className:"w-4 h-4 mr-2"}),"Cancelar"]}),e.jsxs(j,{type:"submit",className:"flex-1",children:[e.jsx(V,{className:"w-4 h-4 mr-2"}),p?"Salvar Alterações":"Criar Acomodação"]})]})]})})]})}),e.jsxs("div",{className:"grid gap-3",children:[(o==null?void 0:o.length)===0&&e.jsx(E,{children:e.jsxs(q,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(M,{className:"w-12 h-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Nenhuma acomodação cadastrada"}),e.jsxs(j,{onClick:()=>x(!0),children:[e.jsx(B,{className:"w-4 h-4 mr-2"}),"Criar primeira acomodação"]})]})}),o&&o.length>0&&e.jsx(ge,{sensors:L,collisionDetection:je,onDragEnd:$,children:e.jsx(ve,{items:o.map(s=>s.id),strategy:fe,children:o.map(s=>e.jsx(ke,{accommodation:s,onEdit:G,onDelete:n=>{confirm("Tem certeza que deseja remover esta acomodação?")&&d.mutate(n)},onToggle:(n,c)=>h.mutate({id:n,is_enabled:c})},s.id))})})]})]})};function ke({accommodation:i,onEdit:b,onDelete:x,onToggle:p}){const{attributes:l,listeners:a,setNodeRef:m,transform:o,transition:N,isDragging:r}=be({id:i.id}),t={transform:Ne.Transform.toString(o),transition:N,zIndex:r?50:void 0,opacity:r?.8:void 0};return e.jsx(E,{ref:m,style:t,className:`${i.is_enabled?"":"opacity-60"} ${r?"shadow-lg":""}`,children:e.jsx(q,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{...l,...a,className:"cursor-grab active:cursor-grabbing mt-2 flex-shrink-0 touch-none",children:e.jsx(ue,{className:"w-5 h-5 text-muted-foreground"})}),e.jsx("div",{className:"w-24 h-16 rounded overflow-hidden bg-muted flex-shrink-0",children:i.image_url?e.jsx("img",{src:i.image_url,alt:i.image_alt||i.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(M,{className:"w-6 h-6 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-foreground",children:i.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 bg-primary/10 text-primary rounded",children:i.building_type||"Histórico"}),!i.is_enabled&&e.jsx("span",{className:"text-xs px-2 py-0.5 bg-muted rounded",children:"Inativo"})]}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:i.description||"Sem descrição"}),e.jsxs("p",{className:"text-sm font-medium text-primary",children:["A partir de ",i.price]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(z,{checked:i.is_enabled,onCheckedChange:d=>p(i.id,d)}),e.jsx(j,{variant:"ghost",size:"icon",onClick:()=>b(i),children:e.jsx(xe,{className:"w-4 h-4"})}),e.jsx(j,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>x(i.id),children:e.jsx(pe,{className:"w-4 h-4"})})]})]})})})}export{Me 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.