PageSourceSearch

https://giftlove-novo.lovable.app/assets/PartnerServicesAdmin-DRE95rGl.js

js giftlove-novo.lovable.app collected 2026-10-03 03:28:32 UTC 4,793 bytes, 1 lines download raw bytes

1import{j as s}from"./vendor-motion-D_eWtC2i.js";import{r as m,L as _}from"./vendor-react-C5-rmG_I.js";import{l as C,b as S,h as b,m as f,K as x,B as v,N as j,p as g}from"./index-BB35H7Wo.js";import{I as L}from"./input-ChxEbcIp.js";import{B as w}from"./badge-Bh_ckV5a.js";import{P as $}from"./PageHeader-B-h5e2bL.js";import{F as B}from"./FilterChips-41WWVW41.js";import{f as F,a as P}from"./adminWhatsappLink-B0i_4nG4.js";import{m as q}from"./masks-CtGf3qEv.js";import{C as I}from"./wifi-Cx6xWYpT.js";import"./vendor-supabase-CfDyWxaF.js";import"./vendor-charts-BzSnLuq2.js";function A(o,d){if(!o)return"Sob consulta";const n=`R$ ${o.toFixed(2).replace(".",",")}`;return d==="hourly"?`${n}/h`:n}function G(){const[o,d]=m.useState("all"),[n,N]=m.useState(""),{data:r,isLoading:y}=C({queryKey:["admin-partner-services"],queryFn:async()=>{const{data:a,error:e}=await g.from("partner_services").select("id, name, category, price, price_type, is_active, created_at, partner_id").order("created_at",{ascending:!1}).limit(500);if(e)throw e;const i=[...new Set((a??[]).map(c=>c.partner_id))],t={};if(i.length>0){const{data:c,error:l}=await g.from("partners").select("id, name, contact_name, phone, email, city, state").in("id",i);if(l)throw l;for(const p of c??[])t[p.id]=p}return{services:a??[],partners:t}}}),h=m.useMemo(()=>{let a=(r==null?void 0:r.services)??[];o==="active"?a=a.filter(i=>i.is_active):o==="inactive"&&(a=a.filter(i=>!i.is_active));const e=n.trim().toLowerCase();return e&&(a=a.filter(i=>{var c,l;const t=r==null?void 0:r.partners[i.partner_id];return i.name.toLowerCase().includes(e)||(((c=t==null?void 0:t.name)==null?void 0:c.toLowerCase().includes(e))??!1)||(((l=t==null?void 0:t.contact_name)==null?void 0:l.toLowerCase().includes(e))??!1)||((t==null?void 0:t.phone)??"").replace(/\D/g,"").includes(e.replace(/\D/g,"")||" ")})),a},[r,o,n]),u=m.useMemo(()=>{const a=(r==null?void 0:r.services)??[];return{all:a.length,active:a.filter(e=>e.is_active).length,inactive:a.filter(e=>!e.is_active).length}},[r]);return s.jsxs("div",{className:"space-y-4",children:[s.jsx($,{title:"Serviços Cadastrados",description:"Serviços criados pelos parceiros, com contato de quem cadastrou"}),s.jsx(B,{value:o,onChange:d,options:[{value:"all",label:`Todos (${u.all})`},{value:"active",label:`Ativos (${u.active})`},{value:"inactive",label:`Inativos (${u.inactive})`}]}),s.jsxs("div",{className:"relative max-w-sm",children:[s.jsx(S,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),s.jsx(L,{placeholder:"Buscar por serviço, parceiro ou telefone...",value:n,onChange:a=>N(a.target.value),className:"pl-9"})]}),y?s.jsx("div",{className:"flex justify-center py-16",children:s.jsx(b,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):h.length===0?s.jsx(f,{children:s.jsxs(x,{className:"py-16 text-center text-muted-foreground",children:[s.jsx(I,{className:"h-8 w-8 mx-auto mb-3 opacity-40"}),"Nenhum serviço encontrado"]})}):s.jsx("div",{className:"space-y-2",children:h.map(a=>{const e=r==null?void 0:r.partners[a.partner_id],i=F(e==null?void 0:e.contact_name)||(e==null?void 0:e.name)||"",t=P(e==null?void 0:e.phone,`Oi${i?`, ${i}`:""}! Aqui é da GIFT & LOVE 😊 Vi seu serviço cadastrado no painel. Posso te ajudar em algo?`);return s.jsx(f,{className:"hover:shadow-sm transition-shadow",children:s.jsxs(x,{className:"p-4 flex flex-col sm:flex-row sm:items-center gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"font-medium truncate",children:a.name}),a.category&&s.jsx(w,{variant:"outline",children:a.category}),s.jsx(w,{variant:a.is_active?"default":"secondary",children:a.is_active?"Ativo":"Inativo"}),s.jsx("span",{className:"text-sm text-muted-foreground",children:A(a.price,a.price_type)})]}),s.jsxs("div",{className:"text-sm text-muted-foreground mt-1 flex flex-wrap gap-x-3",children:[s.jsx("span",{className:"font-medium text-foreground",children:(e==null?void 0:e.contact_name)||(e==null?void 0:e.name)||"Parceiro desconhecido"}),(e==null?void 0:e.contact_name)&&(e==null?void 0:e.name)&&s.jsx("span",{children:e.name}),(e==null?void 0:e.phone)&&s.jsx("span",{children:q.phone(e.phone)}),(e==null?void 0:e.city)&&s.jsxs("span",{children:[e.city,e.state?`/${e.state}`:""]}),s.jsxs("span",{children:["Cadastrado em ",new Date(a.created_at).toLocaleDateString("pt-BR")]})]})]}),s.jsx("div",{className:"shrink-0",children:t?s.jsx(v,{size:"sm",asChild:!0,children:s.jsxs(_,{to:t,children:[s.jsx(j,{className:"h-4 w-4 mr-1.5"}),"WhatsApp"]})}):s.jsxs(v,{size:"sm",disabled:!0,title:"Parceiro sem telefone cadastrado",children:[s.jsx(j,{className:"h-4 w-4 mr-1.5"}),"Sem telefone"]})})]})},a.id)})})]})}export{G 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.