PageSourceSearch

https://customer-all-in-one.lovable.app/assets/MarketingSocialLinks-B6eP9cNd.js

js customer-all-in-one.lovable.app collected 2026-10-03 03:24:46 UTC 6,090 bytes, 1 lines download raw bytes

1import{aa as C,r as v,a as P,ax as w,j as e,B as p,G as I,n as S,q as L,d as q,bn as T,D as A,di as E,J as D,K as F,O as K,Q as R,L as _,v as O,w as Q,x as z,y as B,z as Y,R as G,a1 as U,A as V,s as b,k as y}from"./index-DH-BokCi.js";import{u as W,f as X,M as H}from"./MarketingSectionModeBanner-DwDMGftf.js";import{S as N}from"./share-2-DTTi71Id.js";import{P as J}from"./plus-BpzaYYvs.js";import{S as Z}from"./square-pen-k58n3rdf.js";import"./alert-dialog-B-SXSf4z.js";import"./globe-D82z6n_O.js";import"./rotate-ccw-BYH458wJ.js";const M=[{value:"facebook",label:"Facebook"},{value:"instagram",label:"Instagram"},{value:"linkedin",label:"LinkedIn"},{value:"youtube",label:"YouTube"},{value:"tiktok",label:"TikTok"},{value:"twitter",label:"X (Twitter)"},{value:"podcast",label:"Podcast"},{value:"website",label:"Webseite"},{value:"whatsapp",label:"WhatsApp"},{value:"telegram",label:"Telegram"},{value:"xing",label:"XING"},{value:"other",label:"Sonstige"}],g="marketing-social-links";function ce(){const m=C(),a=W("marketing_social_links",g),[n,u]=v.useState(!1),[k,j]=v.useState(null),{data:l,isLoading:x}=P({queryKey:[g,a.isAdmin,a.userId],queryFn:()=>X("marketing_social_links",{isAdmin:a.isAdmin,userId:a.userId})}),o=(l==null?void 0:l.rows)??[],d=(l==null?void 0:l.mode)??"global",r=!a.isAdmin&&d==="global",h=w({mutationFn:async({id:s,is_active:i})=>{const{error:f}=await b.from("marketing_social_links").update({is_active:i}).eq("id",s);if(f)throw f},onSuccess:()=>m.invalidateQueries({queryKey:[g]})}),t=w({mutationFn:async s=>{const{error:i}=await b.from("marketing_social_links").delete().eq("id",s);if(i)throw i},onSuccess:()=>{y.success("Link gelöscht"),m.invalidateQueries({queryKey:[g]})}}),c=s=>{var i;return((i=M.find(f=>f.value===s))==null?void 0:i.label)||s};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(N,{className:"h-5 w-5"}),"Social Media & Links"]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Kanäle verlinken, die auf Angebotsseiten angezeigt werden"})]}),e.jsxs(p,{onClick:()=>{j(null),u(!0)},className:"gap-1.5",children:[e.jsx(J,{className:"h-4 w-4"}),r?"Eigenen Link anlegen":"Neuer Link"]})]}),e.jsx(H,{mode:d,isAdmin:a.isAdmin,onReset:a.resetToGlobal,resetting:a.resetting,sectionLabel:"Social-Media-Links"}),x?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(I,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):o.length===0?e.jsx(S,{children:e.jsxs(L,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(N,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"font-medium",children:"Noch keine Social-Media-Links"}),e.jsx("p",{className:"text-sm mt-1",children:"Verlinke deine Kanäle wie YouTube, LinkedIn, Instagram oder deinen Podcast."})]})}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:o.map(s=>e.jsx(S,{className:s.is_active?"":"opacity-60",children:e.jsx(L,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(N,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(q,{variant:"secondary",className:"text-xs",children:c(s.platform)})}),e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary truncate block mt-0.5",onClick:i=>i.stopPropagation(),children:s.url})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx(T,{checked:s.is_active,disabled:r,onCheckedChange:i=>h.mutate({id:s.id,is_active:i})}),e.jsx(p,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",disabled:r,onClick:()=>{j(s),u(!0)},children:e.jsx(Z,{className:"h-3.5 w-3.5"})}),e.jsx(p,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive",disabled:r,onClick:()=>t.mutate(s.id),children:e.jsx(A,{className:"h-3.5 w-3.5"})})]})]})})},s.id))}),e.jsx($,{open:n,onOpenChange:u,link:k,userId:a.userId,salespersonId:a.insertSalespersonId})]})}function $({open:m,onOpenChange:a,link:n,userId:u,salespersonId:k}){const j=C(),l=!!n,[x,o]=v.useState(""),[d,r]=v.useState("");E.useEffect(()=>{n?(o(n.platform),r(n.url)):(o(""),r(""))},[n,m]);const h=w({mutationFn:async()=>{const t={platform:x,url:d,updated_at:new Date().toISOString()};if(l){const{error:c}=await b.from("marketing_social_links").update(t).eq("id",n.id);if(c)throw c}else{t.created_by=u,t.salesperson_id=k;const{error:c}=await b.from("marketing_social_links").insert(t);if(c)throw c}},onSuccess:()=>{y.success(l?"Link aktualisiert":"Link erstellt"),j.invalidateQueries({queryKey:[g]}),a(!1)},onError:t=>y.error("Fehler",{description:t.message})});return e.jsx(D,{open:m,onOpenChange:a,children:e.jsxs(F,{className:"sm:max-w-sm",children:[e.jsx(K,{children:e.jsx(R,{children:l?"Link bearbeiten":"Neuer Social-Media-Link"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_,{children:"Plattform *"}),e.jsxs(O,{value:x,onValueChange:o,children:[e.jsx(Q,{children:e.jsx(z,{placeholder:"Plattform wählen..."})}),e.jsx(B,{children:M.map(t=>e.jsx(Y,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(_,{children:"URL *"}),e.jsx(G,{placeholder:"https://...",value:d,onChange:t=>r(t.target.value)})]})]}),e.jsxs(U,{children:[e.jsx(p,{variant:"outline",onClick:()=>a(!1),children:"Abbrechen"}),e.jsxs(p,{onClick:()=>h.mutate(),disabled:h.isPending||!x||!d,className:"gap-1.5",children:[h.isPending?e.jsx(I,{className:"h-4 w-4 animate-spin"}):e.jsx(V,{className:"h-4 w-4"}),"Speichern"]})]})]})})}export{ce as MarketingSocialLinks};

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.