PageSourceSearch

https://living-corporate.com/assets/admin-brand-sponsors-VYmx3iE7.js

js living-corporate.com collected 2026-10-02 05:01:19 UTC 12,988 bytes, 1 lines download raw bytes

1import{e as J,p as W,v as V,r as j,f as X,i as v,j as e,B as r,o as w,C as Y,E as ee,I as c,aO as f}from"./index-QiiZ-xPT.js";import{A as te}from"./AppLayout-DS32LUNS.js";import{B as k}from"./badge-IOHUIid2.js";import{C as D,a as S,b as L,c as T}from"./card-DkXabqFf.js";import{D as q,a as I,b as O,c as M}from"./dialog-D2VXyQJN.js";import{T as se}from"./textarea-Bd1mcSz8.js";import{L as n}from"./label-BA9Xin3m.js";import{S as ie}from"./switch-RlnlRyqa.js";import{C as ae}from"./checkbox-CrGTwbPu.js";import{P as z}from"./plus-BG3Uc6gN.js";import{P as ne}from"./pencil-C6vIE4g4.js";import{T as re}from"./trash-2-D3MslYjV.js";import"./chevron-left-BlU_Pgs7.js";import"./chevron-right-f4G5e4zR.js";import"./gift-DGFeQbUI.js";import"./log-out-CqAuLeet.js";import"./library-DGVSHwk6.js";import"./history-Db1-bwk2.js";import"./video-DCxcvy3M.js";import"./Combination-TP2Egp2x.js";import"./index-DqZlRfV5.js";import"./check-KTa2Xihg.js";const le=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],de=J("image",le),E=[{key:"homepage",label:"Homepage",maxSlots:3},{key:"podcast",label:"Podcast Episodes",maxSlots:1,exclusive:!0},{key:"learning",label:"Learning Modules",maxSlots:1,exclusive:!0},{key:"jobs",label:"Job Board",maxSlots:2},{key:"content",label:"Content Pages",maxSlots:2},{key:"footer",label:"Footer",maxSlots:3}],U={name:"",logoUrl:"",websiteUrl:"",tagline:"",description:"",zones:[],priority:0,startDate:"",endDate:""};function Be(){const{toast:l}=W(),x=V(),[Q,y]=j.useState(!1),[m,b]=j.useState(null),[i,a]=j.useState(U),[N,u]=j.useState(null),{data:g=[],isLoading:H}=X({queryKey:["/api/admin/brand-sponsors"]}),$=v({mutationFn:async t=>{await f("POST","/api/admin/brand-sponsors",{...t,tagline:t.tagline||null,description:t.description||null,startDate:t.startDate||null,endDate:t.endD
1ate||null})},onSuccess:()=>{x.invalidateQueries({queryKey:["/api/admin/brand-sponsors"]}),l({title:"Brand created successfully"}),p()},onError:t=>{l({title:"Failed to create brand",description:t.message,variant:"destructive"})}}),B=v({mutationFn:async({id:t,data:s})=>{await f("PATCH",`/api/admin/brand-sponsors/${t}`,{...s,tagline:s.tagline||null,description:s.description||null,startDate:s.startDate||null,endDate:s.endDate||null})},onSuccess:()=>{x.invalidateQueries({queryKey:["/api/admin/brand-sponsors"]}),l({title:"Brand updated successfully"}),p()},onError:t=>{l({title:"Failed to update brand",description:t.message,variant:"destructive"})}}),K=v({mutationFn:async({id:t,isActive:s})=>{await f("PATCH",`/api/admin/brand-sponsors/${t}/toggle`,{isActive:s})},onSuccess:()=>{x.invalidateQueries({queryKey:["/api/admin/brand-sponsors"]}),l({title:"Brand status updated"})},onError:t=>{l({title:"Failed to toggle brand",description:t.message,variant:"destructive"})}}),C=v({mutationFn:async t=>{await f("DELETE",`/api/admin/brand-sponsors/${t}`)},onSuccess:()=>{x.invalidateQueries({queryKey:["/api/admin/brand-sponsors"]}),l({title:"Brand deleted successfully"}),u(null)},onError:t=>{l({title:"Failed to delete brand",description:t.message,variant:"destructive"})}});function p(){y(!1),b(null),a(U)}function F(){b(null),a(U),y(!0)}function Z(t){b(t),a({name:t.name,logoUrl:t.logoUrl,websiteUrl:t.websiteUrl,tagline:t.tagline||"",description:t.description||"",zones:t.zones||[],priority:t.priority,startDate:t.startDate||"",endDate:t.endD
1ate||""}),y(!0)}function R(t){t.preventDefault(),!(!i.name||!i.logoUrl||!i.websiteUrl)&&(m?B.mutate({id:m.id,data:i}):$.mutate(i))}function _(t){a(s=>({...s,zones:s.zones.includes(t)?s.zones.filter(o=>o!==t):[...s.zones,t]}))}function A(t){return g.filter(s=>s.isActive&&s.zones?.includes(t))}const P=$.isPending||B.isPending;return e.jsx(te,{children:e.jsxs("div",{className:"p-6 max-w-7xl mx-auto space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold","data-testid":"text-page-title",children:"Brand Sponsorship Manager"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage brand sponsors and zone assignments"})]}),e.jsxs(r,{onClick:F,className:"gap-2","data-testid":"button-add-brand",children:[e.jsx(z,{size:16}),"Add Brand"]})]}),H?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(w,{className:"w-8 h-8 animate-spin text-muted-foreground"})}):g.length===0?e.jsx(D,{children:e.jsxs(S,{className:"py-12 text-center",children:[e.jsx(de,{size:48,className:"mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2","data-testid":"text-empty-state",children:"No brand sponsors yet"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Add your first brand sponsor to get started."}),e.jsxs(r,{onClick:F,className:"gap-2","data-testid":"button-add-brand-empty",children:[e.jsx(z,{size:16}),"Add Brand"]})]})}):e.jsxs(D,{children:[e.jsx(L,{children:e.jsxs(T,{className:"flex items-center gap-2",children:[e.jsx(Y,{size:20}),"Brand Sponsors (",g.length,")"]})}),e.jsx(S,{children:e.jsx("div",{className:"divide-y divide-border",children:g.map(t=>e.jsxs("div",{className:"flex items-center gap-4 py-4 first:pt-0 last:pb-0","data-testid":`row-brand-${t.id}`,children:[e.jsx("img",{src:t.logoUrl,alt:t.name,className:"w-[40px] h-[30px] object-contain rounded border bg-white","data-testid":`img-logo-${t.id}`,onError:s=>{s.target.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='30' fill='%23ccc'%3E%3Crect width='40' height='30'/%3E%3C/svg%3E"}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium truncate","data-testid":`text-brand-name-${t.id}`,children:t.name}),e.jsx(k,{variant:t.isActive?"default":"secondary",className:t.isActive?"bg-green-600 hover:bg-green-700":"","data-testid":`badge-status-${t.id}`,children:t.isActive?"Active":"Inactive"})]}),e.jsx("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:t.zones?.map(s=>e.jsx(k,{variant:"outline",className:"text-xs","data-testid":`badge-zone-${t.id}-${s}`,children:E.find(o=>o.key===s)?.label||s},s))})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"text-center","data-testid":`stat-clicks-${t.id}`,children:[e.jsx("div",{className:"font-semibold text-foreground",children:t.clickCount}),e.jsx("div",{className:"text-xs",children:"Clicks"})]}),e.jsxs("div",{className:"text-center","data-testid":`stat-impressions-${t.id}`,children:[e.jsx("div",{className:"font-semibold text-foreground",children:t.impressionCount}),e.jsx("div",{className:"text-xs",children:"Impressions"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{checked:t.isActive,onCheckedChange:s=>K.mutate({id:t.id,isActive:s}),"data-testid":`switch-toggle-${t.id}`}),e.jsx(r,{variant:"ghost",size:"icon",onClick:()=>Z(t),"data-testid":`button-edit-${t.id}`,children:e.jsx(ne,{size:16})}),e.jsx(r,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>u(t.id),"data-testid":`button-delete-${t.id}`,children:e.jsx(re,{size:16})}),e.jsx("a",{href:t.websiteUrl,target:"_blank",rel:"noopener noreferrer","data-testid":`link-website-${t.id}`,children:e.jsx(r,{variant:"ghost",size:"icon",children:e.jsx(ee,{size:16})})})]})]},t.id))})})]}),e.jsxs(D,{children:[e.jsx(L,{children:e.jsx(T,{children:"Zone Overview"})}),e.jsx(S,{children:e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-4",children:E.map(t=>{const s=A(t.key),o=s.length>=t.maxSlots;return e.jsxs("div",{className:"p-4 rounded-lg border","data-testid":`zone-card-${t.key}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"font-medium",children:t.label}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${o?"bg-yellow-500":"bg-green-500"}`,"data-testid":`status-zone-${t.key}`}),e.jsxs("span",{className:"text-sm text-muted-foreground","data-testid":`text-zone-slots-${t.key}`,children:[s.length,"/",t.maxSlots]})]})]}),t.exclusive&&e.jsx(k,{variant:"outline",className:"text-xs mb-2",children:"Exclusive"}),s.length>0?e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:s.map(d=>e.jsxs("div",{className:"flex items-center gap-1.5","data-testid":`zone-brand-${t.key}-${d.id}`,children:[e.jsx("img",{src:d.logoUrl,alt:d.name,className:"w-6 h-4 object-contain rounded border bg-white",onError:h=>{h.target.src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='16' fill='%23ccc'%3E%3Crect width='24' height='16'/%3E%3C/svg%3E"}}),e.jsx("span",{className:"text-xs",children:d.name})]},d.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No brands assigned"})]},t.key)})})})]}),e.jsx(q,{open:Q,onOpenChange:t=>{t||p()},children:e.jsxs(I,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(O,{children:e.jsx(M,{"data-testid":"text-dialog-title",children:m?"Edit Brand":"Add Brand"})}),e.jsxs("form",{onSubmit:R,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"name",children:"Brand Name *"}),e.jsx(c,{id:"name",value:i.name,onChange:t=>a({...i,name:t.target.value}),required:!0,"data-testid":"input-brand-name"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"logoUrl",children:"Logo URL *"}),e.jsx(c,{id:"logoUrl",value:i.logoUrl,onChange:t=>a({...i,logoUrl:t.target.value}),required:!0,"data-testid":"input-logo-url"}),i.logoUrl&&e.jsx("img",{src:i.logoUrl,alt:"Preview",className:"mt-2 w-[60px] h-[40p
1x] object-contain rounded border bg-white","data-testid":"img-logo-preview",onError:t=>{t.target.style.display="none"}})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"websiteUrl",children:"Website URL *"}),e.jsx(c,{id:"websiteUrl",value:i.websiteUrl,onChange:t=>a({...i,websiteUrl:t.target.value}),required:!0,"data-testid":"input-website-url"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"tagline",children:"Tagline"}),e.jsx(c,{id:"tagline",value:i.tagline,onChange:t=>a({...i,tagline:t.target.value}),"data-testid":"input-tagline"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"description",children:"Description"}),e.jsx(se,{id:"description",value:i.description,onChange:t=>a({...i,description:t.target.value}),rows:3,"data-testid":"input-description"})]}),e.jsxs("div",{children:[e.jsx(n,{className:"mb-2 block",children:"Zone Assignments"}),e.jsx("div",{className:"space-y-2",children:E.map(t=>{const s=A(t.key).filter(G=>G.id!==m?.id).length,o=t.maxSlots-s,d=i.zones.includes(t.key),h=!d&&o<=0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ae,{id:`zone-${t.key}`,checked:d,onCheckedChange:()=>_(t.key),disabled:h,"data-testid":`checkbox-zone-${t.key}`}),e.jsxs(n,{htmlFor:`zone-${t.key}`,className:"flex items-center gap-2 cursor-pointer",children:[t.label,e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(max ",t.maxSlots,t.exclusive?" — exclusive":"",")",h&&" — full"]})]})]},t.key)})})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"priority",children:"Priority (0-10)"}),e.jsx(c,{id:"priority",type:"number",min:0,max:10,value:i.priority,onChange:t=>a({...i,priority:Number(t.target.value)}),"data-testid":"input-priority"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(n,{htmlFor:"startDate",children:"Start Date"}),e.jsx(c,{id:"startDate",type:"date",value:i.startDate,onChange:t=>a({...i,startDate:t.target.value}),"data-testid":"input-start-date"})]}),e.jsxs("div",{children:[e.jsx(n,{htmlFor:"endDate",children:"End Date"}),e.jsx(c,{id:"endDate",type:"date",value:i.endDate,onChange:t=>a({...i,endDate:t.target.value}),"data-testid":"input-end-date"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(r,{type:"button",variant:"outline",onClick:p,"data-testid":"button-cancel",children:"Cancel"}),e.jsxs(r,{type:"submit",disabled:P,"data-testid":"button-save",children:[P&&e.jsx(w,{size:16,className:"mr-2 animate-spin"}),m?"Update":"Create"]})]})]})]})}),e.jsx(q,{open:!!N,onOpenChange:t=>{t||u(null)},children:e.jsxs(I,{children:[e.jsx(O,{children:e.jsx(M,{"data-testid":"text-delete-confirm-title",children:"Delete Brand"})}),e.jsx("p",{className:"text-muted-foreground",children:"Are you sure you want to delete this brand sponsor? This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(r,{variant:"outline",onClick:()=>u(null),"data-testid":"button-cancel-delete",children:"Cancel"}),e.jsxs(r,{variant:"destructive",onClick:()=>N&&C.mutate(N),disabled:C.isPending,"data-testid":"button-confirm-delete",children:[C.isPending&&e.jsx(w,{size:16,className:"mr-2 animate-spin"}),"Delete"]})]})]})})]})})}export{Be 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.