PageSourceSearch

https://drophighlight.com/assets/LegalSettings-cFdn92pY.js

js drophighlight.com collected 2026-09-30 06:38:58 UTC 12,987 bytes, 1 lines download raw bytes

1import{G as $,a1 as F,s as u,q as ae,r as c,az as te,j as e,C as N,h as C,o as h,E as Q,B as r,J as o,aa as le,i as R,k as E,l as D,Q as ne,U as ie,V as re,W as ce,Y as oe,Z as de,_ as me,$ as ue}from"./index-P0N1Je5T.js";import{u as ge,i as he,a as xe,B as pe,I as fe,H as je,b as ve,L as ye,c as _e,U as be,R as we,E as Ne}from"./index-CnLQ446M.js";import{u as V}from"./useMutation-DJI0oEf-.js";import{I as x}from"./input-1tKBwIjz.js";import{L as m}from"./label-CoHN_xq2.js";import{s as Ce}from"./sanitizeHtml-CKnUC9-X.js";import{c as Le,r as ke}from"./renderLegalPlaceholders-M5WnXydp.js";import{P as Ae}from"./PageHeader-zjaF7toz.js";import{R as Pe}from"./rotate-ccw-B_LUD4ke.js";import{P as K}from"./pencil-CE5cIgkq.js";import{L as Se}from"./link-B7Q3jauc.js";import{f as O}from"./format-D7UCky8T.js";const Re=a=>$({queryKey:["company-legal-page",a],enabled:!!a,queryFn:async()=>{const{data:n,error:i}=await u.from("company_legal_pages").select("*").eq("company_id",a).maybeSingle();if(i)throw i;return n}}),Ee=a=>$({queryKey:["effective-company-legal",a],enabled:!!a,queryFn:async()=>{const{data:n,error:i}=await u.rpc("get_effective_company_legal",{_company_id:a});if(i)throw i;return(n||[])[0]??null},staleTime:60*1e3}),De=()=>{const a=F();return V({mutationFn:async n=>{var p;const{data:i}=await u.auth.getUser(),{data:d,error:t}=await u.from("company_legal_pages").upsert({company_id:n.company_id,title:n.title,content:n.content,effective_date:n.effective_date,source_template_id:n.source_template_id??null,updated_by:((p=i.user)==null?void 0:p.id)??null},{onConflict:"company_id"}).select().single();if(t)throw t;return d},onSuccess:n=>{a.invalidateQueries({queryKey:["company-legal-page",n.company_id]}),a.invalidateQueries({queryKey:["effective-company-legal",n.company_id]})}})},Fe=()=>{const a=F();return V({mutationFn:async n=>{const{error:i}=await u.from("company_legal_pages").delete().eq("company_id",n);if(i)throw i;return n},onSuccess:n=>{a.invalidateQueries({queryKey:["company-legal-page",n]}),a.invalidateQueries({queryKey:["effective-company-legal",n]})}})},Ye=()=>{const{company:a,refetchProfile:n}=ae(),i=a==null?void 0:a.id,d=a==null?void 0:a.slug,{data:t,isLoading:p}=Ee(i),{data:Y}=Re(i),f=De(),g=Fe(),[j,v]=c.useState(!1),[J,L]=c.useState(!1),[k,q]=c.useState(""),[z,T]=c.useState(new Date().toISOString().slice(0,10));F();const[y,H]=c.useState(""),[_,I]=c.useState(""),[b,M]=c.useState(""),Z=c.useMemo(()=>({...a||{},legal_name:y.trim()||(a==null?void 0:a.legal_name)||null,address:_.trim()||(a==null?void 0:a.address)||null,primary_email:b.trim()||(a==null?void 0:a.primary_email)||null}),[a,y,_,b]),{isComplete:qe,missing:G}=te(),A=l=>G.includes(l),[U,B]=c.useState(!1);c.useEffect(()=>{a&&(H(a.legal_name||""),I(a.address||Le(a)),M(a.primary_email||""))},[a==null?void 0:a.id,a==null?void 0:a.legal_name,a==null?void 0:a.address,a==null?void 0:a.primary_email]);const W=async()=>{if(i){B(!0);try{const{error:l}=await u.rpc("update_company_legal_info",{p_company_id:i,p_legal_name:y,p_address:_,p_primary_email:b});if(l)throw l;await n(),o.success("Legal information saved")}catch(l){o.error(l.message||"Failed to save")}finally{B(!1)}}},s=ge({extensions:[he,xe.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer",target:"_blank"}})],content:"<p></p>",editorProps:{attributes:{class:"prose prose-sm max-w-none min-h-[400px] p-4 focus:outline-none"}}});c.useEffect(()=>{j&&t&&s&&(q(t.title),T(t.effective_date),s.commands.setContent(t.content))},[j,t==null?void 0:t.title,t==null?void 0:t.content,t==null?void 0:t.effective_date,s]);const w=c.useMemo(()=>d?`${window.location.origin}/${d}/legal`:"",[d]);if(!i)return e.jsx("p",{className:"text-muted-foreground",children:"Loading company..."});const X=async()=>{if(s){if(!k.trim()){o.error("Title is required");return}try{await f.mutateAsync({company_id:i,title:k.trim(),content:s.getHTML(),effective_date:z,source_template_id:(t==null?void 0:t.template_id)??null}),o.success("Legal page saved"),v(!1)}catch(l){o.error(l.message||"Failed to save")}}},ee=async()=>{try{await g.mutateAsync(i),o.success("Reset to default template"),L(!1)}catch(l){o.error(l.message||"Failed to reset")}},se=()=>{const l=s==null?void 0:s.getAttributes("link").href,S=window.prompt("URL",l);if(S!==null){if(S===""){s==null||s.chain().focus().extendMarkRange("link").unsetLink().run();return}s==null||s.chain().focus().extendMarkRange("link").setLink({href:S}).run()}},P=!!Y;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ae,{title:"Legal Page",subt
1itle:"Public legal notice shown to fans on your landing page. By default, you inherit the platform template. Edit it to customize"}),!j&&e.jsxs(e.Fragment,{children:[e.jsx(N,{children:e.jsx(C,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[P?e.jsx(h,{className:"bg-primary text-primary-foreground",children:"Customized"}):e.jsx(h,{variant:"secondary",children:"Using default template"}),t&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Last updated ",O(new Date(t.updated_at),"PPp")]})]}),w&&e.jsxs("a",{href:`/${d}/legal`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-primary hover:underline",children:[w,e.jsx(Q,{className:"h-3 w-3"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[w&&e.jsxs(e.Fragment,{children:[e.jsx(r,{variant:"outline",size:"icon",asChild:!0,title:"View public page","aria-label":"View public page",children:e.jsx("a",{href:`/${d}/legal`,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Q,{className:"h-4 w-4"})})}),e.jsx(r,{variant:"outline",size:"icon",title:"Copy link","aria-label":"Copy link",onClick:async()=>{try{await navigator.clipboard.writeText(w),o.success("Link copied")}catch{o.error("Failed to copy link")}},children:e.jsx(le,{className:"h-4 w-4"})})]}),P&&e.jsxs(r,{variant:"outline",onClick:()=>L(!0),disabled:g.isPending,children:[e.jsx(Pe,{className:"h-4 w-4 mr-2"}),"Reset to Default"]}),e.jsxs(r,{onClick:()=>v(!0),children:[e.jsx(K,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})})}),e.jsxs(N,{children:[e.jsxs(C,{children:[e.jsx(R,{children:"Company Legal Information"}),e.jsxs(E,{children:["These values automatically replace placeholders (","{partner_legal_name}",","," ","{partner_address}",", ","{partner_contact_email}",") in the legal text below — no need to edit the template."]})]}),e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{htmlFor:"legal_name",children:"Legal name"}),A("legal_name")&&e.jsx(h,{variant:"destructive",className:"h-5 text-[10px] px-1.5",children:"Required"})]}),e.jsx(x,{id:"legal_name",value:y,onChange:l=>H(l.target.value),placeholder:(a==null?void 0:a.name)||"e.g. Acme Records LTDA",maxLength:200}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:['If left empty, the display name "',a==null?void 0:a.name,'" will be used.']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{htmlFor:"legal_address",children:"Address"}),A("address")&&e.jsx(h,{variant:"destructive",className:"h-5 text-[10px] px-1.5",children:"Required"})]}),e.jsx(x,{id:"legal_address",value:_,onChange:l=>I(l.target.value),placeholder:"Street, number, city, state, ZIP, country",maxLength:300})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{htmlFor:"legal_email",children:"Contact email"}),A("primary_email")&&e.jsx(h,{variant:"destructive",className:"h-5 text-[10px] px-1.5",children:"Required"})]}),e.jsx(x,{id:"legal_email",type:"email",value:b,onChange:l=>M(l.target.value),placeholder:"[email protected]",maxLength:200})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(r,{onClick:W,disabled:U,children:U?"Saving...":"Save legal information"})})]})]}),e.jsxs(N,{children:[e.jsx(C,{children:e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{children:"Preview"}),e.jsx(E,{children:"This is what fans will see on your public legal page. Changes appear instantly here — click Save to apply."})]}),e.jsxs(r,{onClick:()=>v(!0),children:[e.jsx(K,{className:"h-4 w-4 mr-2"}),"Edit"]})]})}),e.jsx(D,{children:p?e.jsx("p",{className:"text-muted-foreground",children:"Loading..."}):t?e.jsxs("div",{className:"border rounded-md bg-background p-6",children:[e.jsx("h2",{className:"text-2xl font-bold mb-1",children:t.title}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["Effective date: ",O(new Date(t.effective_date),"PPP")]}),e.jsx("article",{className:"prose prose-sm max-w-none",dangerouslySetInnerHTML:{__html:Ce(ke(t.content,Z,{highlightMissing:!0}))}})]}):e.jsx("p",{className:"text-muted-foreground",children:"No legal content available yet. Ask the platform admin to publish a default template."})})]})]}),j&&e.jsxs(N,{children:[e.jsxs(C,{children:[e.jsx(R,{children:"Edit Legal Page"}),e.jsx(E,{children:P?"You are editing your customized version.":"Saving will create your own version. The platform template will no longer apply automatically."})]}),e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"md:col-span-2 space-y-2",children:[e.jsx(m,{htmlFor:"title",children:"Title"}),e.jsx(x,{id:"title",value:k,onChange:l=>q(l.target.value),maxLength:200})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{htmlFor:"effective_date",children:"Effective date"}),e.jsx(x,{id:"effective_date",type:"date",value:z,onChange:l=>T(l.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{children:"Content"}),e.jsxs("div",{className:"border rounded-md overflow-hidden bg-background",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-b p-2 bg-muted/30",children:[e.jsx(r,{type:"button",variant:s!=null&&s.isActive("bold")?"secondary":"ghost",size:"sm",onClick:()=>s==null?void 0:s.chain().focus().toggleBold().run(),children:e.jsx(pe,{className:"h-4 w-4"})}),e.jsx(r,{type:"button",variant:s!=null&&s.isActive("italic")?"secondary":"ghost",size:"sm",onClick:()=>s==null?void 0:s.chain().focus().toggleItalic().run(),children:e.jsx(fe,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(r,{type:"button",variant:s!=null&&s.isActive("heading",{level:2})?"secondary":"ghost",size:"sm",onClick:()=>s==null?void 0:s.chain().focus().toggleHeading({level:2}).run(),children:e.jsx(je,{className:"h-4 w-4"})}),e.jsx(r,{type:"button",variant:s!=null&&s.isActive("heading",{level:3})?"secondary":"ghost",size:"sm",onClick:()=>s==null?void 0:s.chain().focus().toggleHeading({level:3}).run(),children:e.jsx(ve,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(r,{type:"button",variant:s!=null&&s.isActive("bulletList")?"secondary":"ghost",size:"sm",onClick:()=>s==null?void 0:s.chain().focus().toggleBulletList().run(),children:e.jsx(ye,{className:"h-4 w-4"})}),e.jsx(r,{type:"button",variant:s!=null&&s.isActive("orderedList")?"secondary":"ghost",size:"sm",onClick:()=>s==null?void 0:s.chain().focus().toggleOrderedList().run(),children:e.jsx(_e,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(r,{type:"button",variant:s!=null&&s.isActive("link")?"secondary":"ghost",size:"sm",onClick:se,children:e.jsx(Se,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-6 bg-border mx-1"}),e.jsx(r,{type:"button",variant:"ghost",size:"sm",onClick:()=>
1s==null?void 0:s.chain().focus().undo().run(),disabled:!(s!=null&&s.can().undo()),children:e.jsx(be,{className:"h-4 w-4"})}),e.jsx(r,{type:"button",variant:"ghost",size:"sm",onClick:()=>s==null?void 0:s.chain().focus().redo().run(),disabled:!(s!=null&&s.can().redo()),children:e.jsx(we,{className:"h-4 w-4"})})]}),s&&e.jsx(Ne,{editor:s})]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(r,{variant:"outline",onClick:()=>v(!1),disabled:f.isPending,children:"Cancel"}),e.jsx(r,{onClick:X,disabled:f.isPending,children:f.isPending?"Saving...":"Save changes"})]})]})]}),e.jsx(ne,{open:J,onOpenChange:L,children:e.jsxs(ie,{children:[e.jsxs(re,{children:[e.jsx(ce,{children:"Reset to default template?"}),e.jsx(oe,{children:"Your customized legal text will be deleted and your public page will start showing the platform default template again. This cannot be undone."})]}),e.jsxs(de,{children:[e.jsx(me,{disabled:g.isPending,children:"Cancel"}),e.jsx(ue,{onClick:ee,disabled:g.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:g.isPending?"Resetting...":"Reset"})]})]})})]})};export{Ye 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.