PageSourceSearch

https://www.etecplus.ai/_next/static/chunks/app/admin/partners/%5Bid%5D/page-3f27b34e1e6f3b47.js

js etecplus.ai collected 2026-10-05 14:26:06 UTC 46,434 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2149],{9199:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(78340).A)("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]])},10241:(e,t,s)=>{"use strict";s.d(t,{LZ:()=>i,gg:()=>r,oy:()=>l,vQ:()=>n});var a=s(27529);class n extends a.E6{extra;constructor(e,t,s,a){super(e,t,s),this.name="PartnerApiError",this.extra=a}}async function r(e,t){let s=await fetch(e,{...t,headers:{"Content-Type":"application/json",...t?.headers||{}}}),a=await s.text(),r={};if(a)try{r=JSON.parse(a)}catch{r={}}if(!s.ok){let e=r?.error,t=e&&"object"==typeof e?e:{},a="string"==typeof e?e:"string"==typeof t.message?t.message:"",i="string"==typeof t.code?t.code:void 0;throw new n(a||`Request failed (${s.status})`,i,s.status,t)}return r}function i(e){if(!(e instanceof n))return{};let t=e.extra.errors;if(!t||"object"!=typeof t||Array.isArray(t))return{};let s={};for(let[e,a]of Object.entries(t))"string"==typeof a&&a&&(s[e]=a);return s}function l(e){if(!(e instanceof n))return[];let t=e.extra.missing;return Array.isArray(t)?t.filter(e=>"string"==typeof e):[]}},36261:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(78340).A)("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]])},45049:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(78340).A)("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]])},47162:(e,t,s)=>{Promise.resolve().then(s.bind(s,77791))},48368:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(78340).A)("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]])},49387:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(78340).A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},60285:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(78340).A)("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]])},66088:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(78340).A)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},67635:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(78340).A)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},68459:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(78340).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},72264:(e,t,s)=>{"use strict";s.d(t,{SQ:()=>o,_2:()=>c,lp:()=>m,mB:()=>u,rI:()=>l,ty:()=>d});var a=s(95155),n=s(12115),r=s(28001),i=s(40980);let l=r.bL,d=r.l9;r.YJ;let o=n.forwardRef(({className:e,sideOffset:t=4,...s},n)=>(0,a.jsx)(r.ZL,{children:(0,a.jsx)(r.UC,{ref:n,sideOffset:t,className:(0,i.cn)("z-50 min-w-[10rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...s})}));o.displayName=r.UC.displayName;let c=n.forwardRef(({className:e,inset:t,variant:s="default",...n},l)=>(0,a.jsx)(r.q7,{ref:l,className:(0,i.cn)("relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8","destructive"===s&&"text-destructive focus:bg-destructive/10 focus:text-destructive",e),...n}));c.displayName=r.q7.displayName;let m=n.forwardRef(({className:e,...t},s)=>(0,a.jsx)(r.JU,{ref:s,className:(0,i.cn)("px-2 py-1.5 text-xs font-medium text-muted-foreground",e),...t}));m.displayName=r.JU.displayName;let u=n.forwardRef(({className:e,...t},s)=>(0,a.jsx)(r.wv,{ref:s,className:(0,i.cn)("-mx-1 my-1 h-px bg-border",e),...t}));u.displayName=r.wv.displayName},77791:(e,t,s)=>{"use strict";s.d(t,{PartnerDetailPanel:()=>ex});var a=s(95155),n=s(12115),r=s(98500),i=s.n(r),l=s(9199),d=s(49387),o=s(997),c=s(60285),m=s(67635),u=s(21362),p=s(66609),h=s(55554),x=s(48875),g=s(41585),b=s(6296),y=s(83765),f=s(10241),j=s(89239),v=s(42763),_=s(60529),N=s(77977),w=s(10240),k=s(95894),S=s(40980);let A={auto:"Their payments are sent with no admin step.",approval:"Every payment to them waits for an admin to approve it.",hold:"Nothing is sent to them until an admin lifts the hold."};function C(e){return{legal_name:e.legal_name??"",preferred_name:e.preferred_name??"",phone:e.phone??"",entity_type:e.entity_type??"",abn:e.abn?(0,w.PT)(e.abn):"",trading_name:e.trading_name??"",gst_registered:null===e.gst_registered?"":e.gst_registered?"yes":"no",address_line1:e.address_line1??"",address_line2:e.address_line2??"",suburb:e.suburb??"",state:e.state??"",postcode:e.postcode??""}}function P(e){return e.replace(/\s+/g," ").trim()}function T(e){return{legal_name:P(e.legal_name)||null,preferred_name:P(e.preferred_name)||null,phone:P(e.phone)||null,entity_type:e.entity_type||null,abn:(0,w.Zj)(e.abn)||null,trading_name:P(e.trading_name)||null,gst_registered:""===e.gst_registered?null:"yes"===e.gst_registered,address_line1:P(e.address_line1)||null,address_line2:P(e.address_line2)||null,suburb:P(e.suburb)||null,state:e.state||null,postcode:e.postcode.trim()||null}}function $({partner:e,open:t,onOpenChange:s,onSaved:r,abrAvailable:i=!0}
1){let[l,d]=(0,n.useState)(!1);return(0,a.jsx)(v.lG,{open:t,onOpenChange:e=>!l&&s(e),children:(0,a.jsx)(v.Cf,{className:"sm:max-w-2xl",children:t&&(0,a.jsx)(M,{partner:e,busy:l,setBusy:d,onClose:()=>s(!1),onSaved:r,abrAvailable:i})})})}function R({label:e,value:t,onChange:s,error:r,disabled:i,optional:l,className:d,...o}){let c=(0,n.useId)();return(0,a.jsxs)("label",{className:(0,S.cn)("block text-sm font-medium",d),children:[e,l&&(0,a.jsx)("span",{className:"ml-1.5 font-normal text-muted-foreground",children:"Optional"}),(0,a.jsx)(_.p,{className:(0,S.cn)("mt-1.5 font-normal",r&&"border-destructive focus-visible:ring-destructive"),value:t,onChange:e=>s(e.target.value),disabled:i,"aria-invalid":!!r,"aria-describedby":r?c:void 0,...o}),r&&(0,a.jsx)("span",{id:c,role:"alert",className:"mt-1.5 block text-xs font-normal text-destructive",children:r})]})}function E({label:e,value:t,onChange:s,options:r,error:i,disabled:l,className:d}){let o=(0,n.useId)();return(0,a.jsxs)("label",{className:(0,S.cn)("block text-sm font-medium",d),children:[e,(0,a.jsxs)("select",{className:(0,S.cn)(y.p5,"font-normal",i&&"border-destructive focus-visible:ring-destructive"),value:t,onChange:e=>s(e.target.value),disabled:l,"aria-invalid":!!i,"aria-describedby":i?o:void 0,children:[(0,a.jsx)("option",{value:"",children:"Select…"}),r.map(e=>(0,a.jsx)("option",{value:e.value,children:e.label},e.value))]}),i&&(0,a.jsx)("span",{id:o,role:"alert",className:"mt-1.5 block text-xs font-normal text-destructive",children:i})]})}let z=N.$k.map(e=>({value:e,label:N.ym[e]})),B=N.Uo.map(e=>({value:e,label:e})),O=[{value:"yes",label:"Yes, registered"},{value:"no",label:"No, not registered"}];function M({partner:e,busy:t,setBusy:s,onClose:r,onSaved:i,abrAvailable:l}
1){let[d,o]=(0,n.useState)(e.handle??""),[c,m]=(0,n.useState)(null),[u,h]=(0,n.useState)(e.role_type),[x,_]=(0,n.useState)(e.stage),[P,$]=(0,n.useState)(e.payout_mode),[I,L]=(0,n.useState)(()=>C(e)),[q,Q]=(0,n.useState)(""),[D,G]=(0,n.useState)({}),[U,K]=(0,n.useState)(null),H=(0,n.useRef)(null);function V(e,t){L(s=>({...s,[e]:t})),G(t=>t[e]?{...t,[e]:void 0}:t),K(null),H.current=null}let J=d!==(e.handle??""),F={...J?{handle:d}:{},...u!==e.role_type?{role_type:u}:{},...x!==e.stage?{stage:x}:{},...P!==e.payout_mode?{payout_mode:P}:{}},W=T(C(e)),X=T(I),Y=k.rl.filter(e=>W[e]!==X[e]),Z=Y.includes("abn")||Y.includes("gst_registered"),ee=!!I.entity_type&&"sole_trader"!==I.entity_type,et=!J||null===(0,y.Iw)(d),es=(Object.keys(F).length>0||Y.length>0)&&et&&q.length<=1e3;async function ea(){let a;if(!es||t)return;let n=(a={},Y.includes("abn")&&X.abn&&!(0,w.O4)(String(X.abn))&&(a.abn="That ABN isn't valid. Check the 11 digits."),Y.includes("postcode")&&X.postcode&&!/^[0-9]{4}$/.test(String(X.postcode))&&(a.postcode="Enter a 4-digit postcode."),ee&&!X.trading_name&&(Y.includes("entity_type")||Y.includes("trading_name"))&&(a.trading_name="A company, partnership or trust needs the name its ABN is registered to."),a);if(Object.keys(n).length)return void G(n);s(!0),K(null);let l={...F};if(Y.length){for(let e of(H.current??=crypto.randomUUID(),Y))l[e]=X[e];l.request_id=H.current,q.trim()&&(l.note=q.trim())}try{let t=await (0,f.gg)(`/api/admin/partners/${e.id}`,{method:"PATCH",body:JSON.stringify(l)});H.current=null,"confirmed"===t.gst?p.oR.success("Saved. The register confirmed their GST registration, so GST is added to what they are paid."):"unconfirmed"===t.gst&&!0===t.partner.gst_registered?p.oR.warning("Saved. Their GST registration is NOT confirmed: they are paid without GST until it is."):p.oR.success("Saved"),r(),await i()}catch(t){t instanceof f.vQ&&(H.current=null);let e=(0,f.LZ)(t);t instanceof f.vQ&&"handle_taken"===t.code?m(t.message):t instanceof f.vQ&&"partner_changed"===t.code?(p.oR.error(t.message),r(),await i()):Object.keys(e).length?(G(e),K("Some details need another look. Nothing was saved.")):K(t.message||"The save didn't go through. Nothing was changed.")}finally{s(!1)}}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(v.c7,{children:[(0,a.jsxs)(v.L3,{children:["Edit ",(0,y.M)(e)]}),(0,a.jsx)(v.rr,{children:"Every change is recorded with the value it replaced: in the audit log, and for their details in the change history on this page."})]}),(0,a.jsxs)("form",{noValidate:!0,className:"space-y-6",onSubmit:e=>{e.preventDefault(),ea()},children:[(0,a.jsxs)("section",{className:"space-y-5","aria-labelledby":"edit-partner-admin",children:[(0,a.jsx)("h3",{id:"edit-partner-admin",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Set by ETEC+"}),(0,a.jsx)(y.Jg,{value:d,onChange:e=>{o(e),m(null)},error:J?c:null,disabled:t}),J&&e.handle&&"approved"===e.status&&(0,a.jsxs)("p",{className:"-mt-2 flex items-start gap-2 rounded-lg border border-warning-border bg-warning-surface p-3 text-xs",children:[(0,a.jsx)(g.A,{className:"mt-0.5 size-3.5 shrink-0 text-warning","aria-hidden":!0}),(0,a.jsxs)("span",{children:["Their current link, /partner/",e.handle,", stops working. Anyone who opened it and hasn't signed up yet is no longer counted as theirs, so tell them the new link."]})]}),(0,a.jsxs)("div",{className:"grid gap-4 sm:grid-cols-3",children:[(0,a.jsxs)("label",{className:"block text-sm font-medium",children:["How they sell",(0,a.jsx)("select",{className:(0,S.cn)(y.p5,"font-normal"),value:u,onChange:e=>h(e.target.value),disabled:t,children:N.wb.map(e=>(0,a.jsx)("option",{value:e,children:N.n[e]},e))})]}),(0,a.jsxs)("label",{className:"block text-sm font-medium",children:["Stage",(0,a.jsx)("select",{className:(0,S.cn)(y.p5,"font-normal"),value:x,onChange:e=>_(e.target.value),disabled:t,children:N.Rc.map(e=>(0,a.jsx)("option",{value:e,children:N.J4[e]},e))})]}),(0,a.jsxs)("label",{className:"block text-sm font-medium",children:["Payout mode",(0,a.jsx)("select",{className:(0,S.cn)(y.p5,"font-normal"),value:P,onChange:e=>$(e.target.value),disabled:t,children:N.Fx.map(e=>(0,a.jsx)("option",{value:e,children:N.PM[e]},e))})]})]}),(0,a.jsxs)("p",{className:"-mt-2 text-xs text-muted-foreground",children:[A[P]," How they sell only decides what their link produces for new clients. It doesn't change the clients already attributed to them.","full"===x&&"trial"===e.stage?" Moving them to full emails them that they have been promoted.":""]})]}),(0,a.jsxs)("section",{className:"space-y-4 border-t pt-5","aria-labelledby":"edit-partner-details",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{id:"edit-partner-details",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Their details"}),(0,a.jsx)("p",{className:"mt-1 text-xs text-muted-foreground",children:"What they declared when they applied. They can change these themselves in the partner portal; they are emailed when any of them changes. Statements already issued keep the details they were issued with. Bank and identity details stay with Stripe."})]}),(0,a.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,a.jsx)(R,{label:"Legal name",value:I.legal_name,onChange:e=>V("legal_name",e),error:D.legal_name,disabled:t,maxLength:120}
1),(0,a.jsx)(R,{label:"Preferred name",optional:!0,value:I.preferred_name,onChange:e=>V("preferred_name",e),error:D.preferred_name,disabled:t,maxLength:60}),(0,a.jsx)(R,{label:"Phone",type:"tel",inputMode:"tel",value:I.phone,onChange:e=>V("phone",e),error:D.phone,disabled:t,maxLength:30}),(0,a.jsx)("div",{className:"hidden sm:block","aria-hidden":!0}),(0,a.jsx)(R,{label:"Address line 1",value:I.address_line1,onChange:e=>V("address_line1",e),error:D.address_line1,disabled:t,maxLength:120}),(0,a.jsx)(R,{label:"Address line 2",optional:!0,value:I.address_line2,onChange:e=>V("address_line2",e),error:D.address_line2,disabled:t,maxLength:120})]}),(0,a.jsxs)("div",{className:"grid gap-4 sm:grid-cols-3",children:[(0,a.jsx)(R,{label:"Suburb",value:I.suburb,onChange:e=>V("suburb",e),error:D.suburb,disabled:t,maxLength:80}),(0,a.jsx)(E,{label:"State",value:I.state,onChange:e=>V("state",e),options:B,error:D.state,disabled:t}),(0,a.jsx)(R,{label:"Postcode",inputMode:"numeric",value:I.postcode,onChange:e=>V("postcode",e.replace(/\D/g,"").slice(0,4)),error:D.postcode,disabled:t,maxLength:4})]})]}),(0,a.jsxs)("section",{className:"space-y-4 border-t pt-5","aria-labelledby":"edit-partner-business",children:[(0,a.jsx)("h3",{id:"edit-partner-business",className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Their business"}),(0,a.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,a.jsx)(E,{label:"Business type",value:I.entity_type,onChange:e=>V("entity_type",e),options:z,error:D.entity_type,disabled:t}),(0,a.jsx)(R,{label:"ABN",inputMode:"numeric",value:I.abn,onChange:e=>V("abn",e.replace(/[^\d\s]/g,"")),onBlur:()=>L(e=>({...e,abn:(0,w.PT)(e.abn)})),error:D.abn,disabled:t,maxLength:20,placeholder:"51 824 753 556",autoComplete:"off"}),(0,a.jsx)(R,{label:ee?"Registered business name":"Trading name",optional:!ee,value:I.trading_name,onChange:e=>V("trading_name",e),error:D.trading_name,disabled:t,maxLength:120}),(0,a.jsx)(E,{label:"Registered for GST",value:I.gst_registered,onChange:e=>V("gst_registered","yes"===e?"yes":"no"===e?"no":""),options:O,error:D.gst_registered,disabled:t})]}),Z&&(0,a.jsxs)("p",{role:"status",className:"flex items-start gap-2 rounded-lg border border-warning-border bg-warning-surface p-3 text-xs",children:[(0,a.jsx)(g.A,{className:"mt-0.5 size-3.5 shrink-0 text-warning","aria-hidden":!0}),(0,a.jsxs)("span",{children:["Changing the ABN or the GST registration clears their GST confirmation."," ",l?"The Australian Business Register is asked when you save, and the registration is confirmed straight away if the register backs it.":"The ABN lookup isn’t set up here, so nothing can confirm it on save: confirm it by hand on this page afterwards."," ","Until it is confirmed they are paid without GST. Lines already on their ledger don't change."]})]})]}),Y.length>0&&(0,a.jsxs)("label",{className:"block text-sm font-medium",children:["Why",(0,a.jsx)("span",{className:"ml-1.5 font-normal text-muted-foreground",children:"Optional"}),(0,a.jsx)("textarea",{className:(0,S.cn)(y.pc,"font-normal"),rows:2,value:q,onChange:e=>Q(e.target.value),maxLength:1e3,disabled:t,placeholder:"They rang to say the company name changed"}),(0,a.jsx)("span",{className:"mt-1.5 block text-xs font-normal text-muted-foreground",children:"Kept with the change in the history and the audit log. Never shown to the partner."})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-x-3 gap-y-2 border-t pt-4",children:[U&&(0,a.jsx)("p",{role:"alert",className:"mr-auto min-w-0 text-xs text-destructive",children:U}),(0,a.jsx)(j.$,{type:"button",variant:"outline",onClick:r,disabled:t,children:"Cancel"}),(0,a.jsxs)(j.$,{type:"submit",disabled:t||!es,children:[t&&(0,a.jsx)(b.A,{className:"animate-spin"}),"Save"]})]})]})]})}var I=s(87757),L=s(21628),q=s(53487),Q=s(61732),D=s(45160),G=s(86846),U=s(27529);function K({partnerId:e}){let[t,s]=(0,n.useState)(null),[r,i]=(0,n.useState)(!1),l=(0,n.useRef)(!1),d=(0,n.useCallback)(async()=>{try{s(await (0,U.nr)(`/api/admin/partners/${e}/changes`)),l.current=!0,i(!1)}catch(e){l.current?p.oR.error(`Couldn't reload the change history: ${e.message}`):i(!0)}},[e]);return(0,n.useEffect)(()=>{d()},[d]),(0,a.jsx)(Q.Panel,{title:"Changes to their details",description:"Every change since they applied, newest first: who made it, and each detail from what it was to what it is now. Statements already issued keep the details they were issued with.",flush:!0,children:!t&&r?(0,a.jsx)("div",{className:"border-t",children:(0,a.jsx)(q.mz,{what:"the change history",onRetry:()=>void d()})}):t?t.available?0===t.changes.length?(0,a.jsx)("p",{className:"border-t px-5 py-10 text-center text-sm text-muted-foreground",children:"Nothing has been changed since they applied. A change made by them in the partner portal, or by an admin with Edit, appears here."}):(0,a.jsx)("ul",{className:"divide-y border-t",children:t.changes.map(e=>(0,a.jsx)(H,{change:e},e.id))}):(0,a.jsx)("div",{className:"border-t px-5 py-4",children:(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-warning-border bg-warning-surface px-4 py-3 text-sm",children:[(0,a.jsx)(g.A,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":!0}),(0,a.jsxs)("p",{children:["Changing a partner's details, and the history of those changes, isn't available in this database yet. Apply"," ",(0,a.jsx)("code",{className:"font-mono text-xs",children:"supabase/migrations/0079_partner_details_emails.sql"})," and reload. Everything else on this page works as before."]})]})}):(0,a.jsx)("div",{className:"border-t px-5 py-4",children:(0,a.jsx)(G.E,{className:"h-16"})})})}function H({change:e}){let t=k.rl.filter(t=>void 0!==e.changes[t]),s=t.some(e=>k.Yk.includes(e));return(0,a.jsxs)("li",{className:"px-5 py-4",children:[(0,a.jsxs)("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",children:[(0,a.jsx)(D.E,{variant:"partner"===e.actor?"outline":"muted",children:"partner"===e.actor?"Partner":"Admin"}),(0,a.jsx)("span",{className:"font-medium text-foreground",children:e.by}),(0,a.jsx)("span",{title:(0,Q.KQ)(e.created_at),children:(0,Q.BM)(e.created_at)}),s&&(0,a.jsx)("span",{children:"Reset the GST confirmation"})]}),(0,a.jsx)("dl",{className:"mt-2.5 space-y-1.5",children:t.map(t=>(0,a.jsxs)("div",{className:"grid gap-x-4 gap-y-0.5 text-sm sm:grid-cols-[11rem_1fr]",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:k.y1[t]}),(0,a.jsxs)("dd",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[(0,a.jsx)("span",{className:"break-words text-muted-foreground line-through decoration-muted-foreground
1/50",children:(0,k.X8)(t,e.changes[t]?.from)}),(0,a.jsx)(L.A,{className:"size-3.5 shrink-0 text-muted-foreground","aria-label":"changed to"}),(0,a.jsx)("span",{className:"break-words font-medium",children:(0,k.X8)(t,e.changes[t]?.to)})]})]},t))}),e.note&&(0,a.jsxs)("p",{className:"mt-2.5 whitespace-pre-wrap rounded-lg border bg-muted/30 px-3 py-2 text-xs",children:[(0,a.jsx)("span",{className:"font-medium",children:"Why: "}),e.note]})]})}var V=s(83740),J=s(20986);let F={suspended:"Suspended",reinstated:"Reinstated",ended:"Partnership ended",promoted:"Promoted",reopened:"Application reopened",claim_accepted:"Claim accepted",claim_dismissed:"Claim not accepted",client_recorded:"Client recorded",payment_held:"Payment on hold",payment_taken_back:"Payment taken back",payouts_ready:"Payouts ready",stripe_needs_info:"Stripe needs more",payout_setup_reminder:"Payout setup reminder",details_changed:"Details changed",gst_confirmed:"GST confirmed"},W={sent:{label:"Sent",variant:"success"},failed:{label:"Failed",variant:"destructive"},skipped:{label:"Not sent",variant:"muted"}};function X({partnerId:e}){let{data:t,loading:s,failed:n,reload:r}=(0,I.aV)(`/api/admin/partners/${e}/emails`,"the emails sent to this partner"),i=t?.emails??[];return(0,a.jsx)(Q.Panel,{title:"Emails sent",description:"What they were told by email about their partnership and their money, and whether each one went. Each event is emailed once: one that failed is not sent again.",action:(0,a.jsxs)(j.$,{size:"sm",variant:"outline",disabled:s,onClick:()=>void r(),children:[(0,a.jsx)(J.A,{"aria-hidden":!0}),"Refresh"]}),flush:!0,children:!t&&n?(0,a.jsx)("div",{className:"border-t",children:(0,a.jsx)(q.mz,{what:"the emails sent to this partner",onRetry:()=>void r()})}):t?t.available?i.length?(0,a.jsx)("ul",{className:"divide-y border-t",children:i.map((e,t)=>{let s=W[e.status]??W.skipped;return(0,a.jsxs)("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 px-5 py-3 text-sm",children:[(0,a.jsxs)("span",{className:"min-w-0 flex-1 basis-56",children:[(0,a.jsx)("span",{className:"block truncate font-medium",children:F[e.kind]??e.kind}),(0,a.jsx)("span",{className:"block truncate text-xs text-muted-foreground",title:e.subject,children:e.subject}),"sent"!==e.status&&e.error&&(0,a.jsx)("span",{className:"mt-0.5 block text-xs text-muted-foreground [overflow-wrap:anywhere]",children:e.error})]}),(0,a.jsx)(D.E,{variant:s.variant,children:s.label}),(0,a.jsx)("span",{className:"w-40 text-right text-xs text-muted-foreground tabular-nums",children:(0,Q.KQ)(e.created_at)})]},`${e.created_at}:${t}`)})}):(0,a.jsx)("p",{className:"border-t px-5 py-10 text-center text-sm text-muted-foreground",children:"Nothing yet. An email is listed here when something happens to their partnership or their money."}):(0,a.jsx)("div",{className:"border-t px-5 py-4",children:(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-xl border border-warning-border bg-warning-surface px-4 py-3 text-sm",children:[(0,a.jsx)(g.A,{className:"mt-0.5 size-4 shrink-0 text-warning","aria-hidden":!0}),(0,a.jsxs)("p",{children:["Partner emails aren't switched on in this database yet. Apply"," ",(0,a.jsx)("code",{className:"font-mono text-xs",children:"supabase/migrations/0079_partner_details_emails.sql"})," and reload. Until then a partner is only emailed about their application and their statements."]})]})}):(0,a.jsx)(I._N,{className:"border-t",rows:2})})}var Y=s(45049),Z=s(36261),ee=s(68459),et=s(75230);function es({partnerId:e}){let[t,s]=(0,n.useState)(null),[r,i]=(0,n.useState)(!1),[l,d]=(0,n.useState)(""),[o,c]=(0,n.useState)(!1),[m,u]=(0,n.useState)(null),h=(0,n.useRef)(null),x=(0,n.useRef)(!1),g=(0,n.useCallback)(async()=>{try{s(await (0,U.nr)(`/api/admin/partners/${e}/notes`)),x.current=!0,i(!1)}catch(e){x.current?p.oR.error(`Couldn't reload the notes: ${e.message}`):i(!0)}},[e]);function y(e){e instanceof U.E6&&"migration_required"===e.code?s({available:!1,notes:[]}):p.oR.error(e.message)}async function f(){let t=l.trim();if(t&&!o){c(!0),h.current??=crypto.randomUUID();try{await (0,U.nr)(`/api/admin/partners/${e}/notes`,{method:"POST",body:JSON.stringify({body:t,request_id:h.current})}),h.current=null,d(""),await g()}catch(e){y(e)}finally{c(!1)}}}async function v(t,s){try{await (0,U.nr)(`/api/admin/partners/${e}/notes/${t.id}`,{method:"PATCH",body:JSON.stringify({pinned:s})}),await g()}catch(e){y(e)}}return(0,n.useEffect)(()=>{g()},[g]),(0,a.jsxs)(Q.Panel,{title:"Internal notes",description:"Only super admins see these. Never shown or sent to the partner. Pin what the next person should read first.",children:[!t&&r?
1(0,a.jsx)("div",{className:"-mx-5 -my-3",children:(0,a.jsx)(q.mz,{what:"this partner's notes",onRetry:()=>void g()})}):t?t.available?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),f()},children:[(0,a.jsx)("textarea",{value:l,onChange:e=>{h.current=null,d(e.target.value)},rows:3,maxLength:4e3,placeholder:"Who referred them, what was agreed, what to watch for…","aria-label":"New note",disabled:o,className:"w-full resize-y rounded-lg border bg-transparent px-3 py-2 text-sm outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60"}),(0,a.jsx)("div",{className:"mt-2 flex justify-end",children:(0,a.jsxs)(j.$,{size:"sm",type:"submit",disabled:o||!l.trim(),children:[o&&(0,a.jsx)(b.A,{className:"animate-spin"}),"Add note"]})})]}),(0,a.jsxs)("ul",{className:"mt-4 space-y-3",children:[t.notes.map(e=>(0,a.jsxs)("li",{className:(0,S.cn)("rounded-lg border p-3",e.pinned&&"border-foreground/25 bg-accent/30"),children:[(0,a.jsx)("p",{className:"whitespace-pre-wrap break-words text-sm",children:e.body}),(0,a.jsxs)("div",{className:"mt-2 flex items-center gap-2 text-xs text-muted-foreground",children:[e.pinned&&(0,a.jsx)(Y.A,{className:"size-3 shrink-0","aria-label":"Pinned"}),(0,a.jsxs)("span",{className:"min-w-0 flex-1 truncate",title:(0,Q.KQ)(e.createdAt),children:[e.author," \xb7 ",(0,Q.BM)(e.createdAt)]}),(0,a.jsx)("button",{type:"button",onClick:()=>void v(e,!e.pinned),className:"rounded p-1.5 transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":e.pinned?"Unpin this note":"Pin this note",children:e.pinned?(0,a.jsx)(Z.A,{className:"size-3.5"}):(0,a.jsx)(Y.A,{className:"size-3.5"})}),(0,a.jsx)("button",{type:"button",onClick:()=>u(e),className:"rounded p-1.5 transition-colors hover:bg-accent hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-label":"Delete this note",children:(0,a.jsx)(ee.A,{className:"size-3.5"})})]})]},e.id)),!t.notes.length&&(0,a.jsx)("li",{className:"py-6 text-center text-sm text-muted-foreground",children:"No notes yet."})]})]}):(0,a.jsx)(V.A,{what:"Notes on a partner"}):(0,a.jsx)(G.E,{className:"h-24"}),(0,a.jsx)(et.T,{open:!!m,onOpenChange:e=>!e&&u(null),title:"Delete this note?",description:"It leaves this list for everyone. The audit log keeps a record that a note was deleted, not what it said.",confirmText:"Delete note",destructive:!0,onConfirm:async()=>{m&&(await (0,U.nr)(`/api/admin/partners/${e}/notes/${m.id}`,{method:"DELETE"}),await g())}})]})}var ea=s(48368),en=s(66088),er=s(13909);let ei={rcti:"Recipient created tax invoice",remittance:"Remittance advice"},el={commission:"Commission",bonus:"Bonus",adjustment:"Adjustment",clawback:"Recovered"};function ed({partnerId:e,partnerName:t}){let{data:s,failed:r,migrationRequired:i,reload:l}=(0,I.aV)(`/api/admin/partners/${e}/statements`,"the statements"),[d,o]=(0,n.useState)(!1),[c,m]=(0,n.use
1State)(()=>crypto.randomUUID()),[u,h]=(0,n.useState)(null);async function x(){let t=await (0,U.nr)(`/api/admin/partners/${e}/statements`,{method:"POST",body:JSON.stringify({request_id:c})});t.statement?p.oR.success(`Statement ${t.statement.number} issued.`):p.oR.success("Nothing has been sent since the last statement, so none was issued."),await l()}let g=s?.statements??[];return(0,a.jsxs)(Q.Panel,{title:"Statements",description:"What they were paid, as numbered documents: a recipient created tax invoice for a partner registered for GST, a remittance advice otherwise. One is issued each week when something was sent.",action:(0,a.jsxs)(j.$,{size:"sm",variant:"outline",disabled:!s,onClick:()=>{m(crypto.randomUUID()),o(!0)},children:[(0,a.jsx)(ea.A,{}),"Issue a statement now"]}),flush:!0,children:[i?(0,a.jsx)("div",{className:"border-t px-5 pt-4",children:(0,a.jsx)(I.I,{})}):!s&&r?(0,a.jsx)("div",{className:"border-t",children:(0,a.jsx)(q.mz,{what:"this partner's statements",onRetry:()=>void l()})}):s?g.length?(0,a.jsx)("ul",{className:"divide-y border-t",children:g.map(e=>{let t=e.lines??[],s=t.length>0,n=u===e.id&&s,r=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"min-w-0 flex-1 basis-48",children:[(0,a.jsx)("span",{className:"block truncate font-mono text-xs font-medium",children:e.number}),(0,a.jsxs)("span",{className:"block truncate text-xs text-muted-foreground",children:["Issued ",(0,Q.KQ)(e.issued_at),e.period_start||e.period_end?` \xb7 payments from ${(0,I.XV)(e.period_start)} to ${(0,I.XV)(e.period_end)}`:""]})]}),(0,a.jsx)(D.E,{variant:"outline",children:ei[e.kind]??e.kind}),"emailed_at"in e&&(0,a.jsx)(D.E,{variant:e.emailed_at?"muted":"warning",children:e.emailed_at?"Emailed":"Not emailed"}),(0,a.jsx)("span",{className:"w-28 text-right font-medium tabular-nums",children:(0,er.Bs)(e.total_cents)}),s&&(0,a.jsx)(en.A,{className:(0,S.cn)("size-4 text-muted-foreground transition-transform",n&&"rotate-180"),"aria-hidden":!0})]});return(0,a.jsxs)("li",{children:[s?(0,a.jsx)("button",{type:"button","aria-expanded":n,onClick:()=>h(n?null:e.id),className:"flex w-full flex-wrap items-center gap-x-4 gap-y-1.5 px-5 py-3 text-left text-sm transition-colors hover:bg-accent/50",children:r}):(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5 px-5 py-3 text-sm",children:r}),n&&(0,a.jsxs)("div",{className:"border-t bg-muted/20 px-5 py-3",children:[(0,a.jsx)("ul",{className:"divide-y text-sm",children:t.map((e,t)=>(0,a.jsxs)("li",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-0.5 py-1.5",children:[(0,a.jsxs)("span",{className:"min-w-0 flex-1 truncate",children:[e.recovery?"Recovered":el[e.kind]??e.kind,(0,a.jsxs)("span",{className:"text-muted-foreground",children:[" ","\xb7 ",e.client_name??"Deleted workspace"," \xb7 ",(0,I.XV)(e.at),"offset"===e.recovery?" \xb7 taken off a payment":"reversal"===e.recovery?" \xb7 pulled back from Stripe":""]})]}),(0,a.jsxs)("span",{className:"shrink-0 tabular-nums",children:[(0,er.Bs)(e.amount_cents),(0,a.jsx)("span",{className:"ml-1 text-xs text-muted-foreground",children:e.gst_cents?`GST ${(0,er.Bs)(e.gst_cents)}`:"no GST"})]})]},`${e.line_id}:${t}`))}),null!=e.amount_cents&&null!=e.gst_cents&&(0,a.jsxs)("p",{className:"mt-2 border-t pt-2 text-right text-xs text-muted-foreground",children:[(0,er.Bs)(e.amount_cents)," excluding GST \xb7 ",(0,er.Bs)(e.gst_cents)," GST \xb7 ",(0,a.jsxs)("span",{className:"font-medium text-foreground",children:[(0,er.Bs)(e.total_cents)," total"]})]})]})]},e.id)})}):(0,a.jsx)("p",{className:"border-t px-5 py-10 text-center text-sm text-muted-foreground",children:"No statements yet. The first is issued the week after something is sent to them."}):(0,a.jsx)(I._N,{className:"border-t",rows:2}),(0,a.jsx)(et.T,{open:d,onOpenChange:o,title:`Issue a statement for ${t} now?`,description:"It covers everything sent to them, and anything recovered from them, since their last statement. It gets the next document number, which can't be reused or withdrawn. If nothing has been sent since the last one, no statement is issued.",confirmText:"Issue statement",onConfirm:x})]})}var eo=s(19029),ec=s(80054),em=s(72264);let eu={link:"Partner link, at sign-up",checkout:"Partner link, at checkout",admin:"Allocated by an admin"},ep={full_cycle:"Full cycle",setter:"Setter",closer:"Closer"};function eh(e){return e.replace(/\./g," › ").replace(/_/g," ")}function ex({partnerId:e}
1){let[t,s]=(0,n.useState)(null),[r,m]=(0,n.useState)(!1),[u,g]=(0,n.useState)(!1),[b,f]=(0,n.useState)(!1),[v,_]=(0,n.useState)(!1),[k,S]=(0,n.useState)(null),A=(0,y.LR)(),C=!1!==(0,h.T_)().abrConfigured,P=(0,n.useCallback)(async()=>{try{s(await (0,U.nr)(`/api/admin/partners/${e}`))}catch(e){404===e.status?m(!0):p.oR.error(e.message)}},[e]);(0,n.useEffect)(()=>{P()},[P]);let T=(0,n.useCallback)(async()=>{A(),await P()},[P,A]);if(r)return(0,a.jsxs)("div",{className:"py-24 text-center",children:[(0,a.jsx)("p",{className:"text-sm font-medium",children:"Partner not found"}),(0,a.jsx)(j.$,{asChild:!0,variant:"outline",size:"sm",className:"mt-4",children:(0,a.jsx)(i(),{href:"/admin/partners",children:"All partners"})})]});let R=t?.partner,E=R?(0,y.M)(R):void 0,z=R&&t?(0,y.x$)(R,t.canBePaid):null;return(0,a.jsxs)("div",{children:[(0,a.jsx)(Q.BI,{items:[{label:"Partners",href:"/admin/partners"},{label:E??"…"}]}),(0,a.jsx)(h.wc,{title:R?(0,a.jsxs)("span",{className:"flex flex-wrap items-center gap-3",children:[E,(0,a.jsx)(y.KN,{status:R.status}),(0,y.X6)(R.status)&&(0,a.jsx)(y.mW,{stage:R.stage}),z&&(0,a.jsxs)(D.E,{variant:t?.canBePaid?"success":"warning",children:["Payouts: ",z.toLowerCase()]})]}):(0,a.jsx)(G.E,{className:"h-8 w-56"}),description:R?`${R.email} \xb7 application started ${(0,Q.KQ)(R.created_at)}`:void 0,actions:(0,a.jsxs)(a.Fragment,{children:[R?.status==="submitted"&&(0,a.jsx)(j.$,{size:"sm",onClick:()=>f(!0),children:"Review application"}),R?.status==="rejected"&&(0,a.jsxs)(j.$,{size:"sm",variant:"outline",onClick:()=>_(!0),children:[(0,a.jsx)(l.A,{}),"Reopen"]}),(0,a.jsxs)(j.$,{size:"sm",variant:"outline",onClick:()=>g(!0),disabled:!R,children:[(0,a.jsx)(d.A,{}),"Edit"]}),(0,a.jsx)(j.$,{asChild:!0,size:"sm",variant:"outline",children:(0,a.jsxs)(i(),{href:`/admin/audit?target=${e}`,children:[(0,a.jsx)(o.A,{}),"Audit log"]})}),(R?.status==="approved"||R?.status==="suspended")&&(0,a.jsxs)(em.rI,{children:[(0,a.jsx)(em.ty,{asChild:!0,children:(0,a.jsx)(j.$,{size:"icon",variant:"outline",className:"size-8","aria-label":"More actions for this partner",children:(0,a.jsx)(c.A,{})})}),(0,a.jsxs)(em.SQ,{align:"end",children:["approved"===R.status?(0,a.jsx)(em._2,{onSelect:()=>S("suspend"),children:"Suspend"}):(0,a.jsx)(em._2,{onSelect:()=>S("reinstate"),children:"Reinstate"}),(0,a.jsx)(em.mB,{}),(0,a.jsx)(em._2,{className:"text-destructive focus:text-destructive",onSelect:()=>S("terminate"),children:"End partnership"})]})]})]})}),t&&R?(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,a.jsx)(Q.Panel,{title:"Profile",children:(0,a.jsx)(Q.At,{className:"sm:grid-cols-2 lg:grid-cols-2",items:[{label:"Legal name",value:R.legal_name??"—"},{label:"Preferred name",value:R.preferred_name??"—"},{label:"Email",value:(0,a.jsx)("a",{href:`mailto:${R.email}`,className:"hover:underline",children:R.email})},{label:"Phone",value:R.phone?(0,a.jsx)("a",{href:`tel:${R.phone}`,className:"hover:underline",children:R.phone}):"—"},{label:"How they sell",value:N.n[R.role_type]??R.role_type},{label:"Stage",value:(0,y.X6)(R.status)?N.J4[R.stage]??R.stage:"Set at approval"},{label:"Payout mode",value:N.PM[R.payout_mode]??R.payout_mode},{label:"Partner link",value:(0,a.jsx)(eg,{partner:R})},{label:"Sign-in account",value:t.user?t.user.email:R.user_id?"Unknown":"Deleted"},{label:"Last signed in",value:t.user?(0,Q.BM)(t.user.lastSignInAt):"—"}]})}),(0,a.jsx)(Q.Panel,{title:"Business",description:(0,x.zc)(R),children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(y.jT,{matches:t.duplicateAbn}),(0,a.jsx)(Q.At,{className:"sm:grid-cols-2 lg:grid-cols-2",items:[{label:"Business type",value:R.entity_type?N.ym[R.entity_type]??R.entity_type:"—"},{label:"ABN",value:R.abn?(0,w.PT)(R.abn):"—"},{label:R.entity_type&&"sole_trader"!==R.entity_type?"Registered name":"Trading name",value:R.trading_name??"—"},{label:"Registered for GST",value:(0,x.p$)(R)},{label:"Address",value:(0,a.jsxs)("span",{className:"block whitespace-normal",children:[[R.address_line1,R.address_line2].filter(
1Boolean).join(", ")||"—",(0,y.Ev)(R)&&(0,a.jsx)("span",{className:"block",children:(0,y.Ev)(R)})]})}]}),(0,a.jsx)(x.aP,{partner:R,available:C,onChecked:P},R.abn??"none")]})}),(0,a.jsx)(Q.Panel,{title:"Application",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(Q.At,{className:"sm:grid-cols-2 lg:grid-cols-2",items:[{label:"Started",value:(0,Q.KQ)(R.created_at)},{label:"Submitted",value:(0,Q.KQ)(R.submitted_at)},{label:"Reviewed",value:R.reviewed_at?(0,Q.KQ)(R.reviewed_at):"—"},{label:"Reviewed by",value:t.reviewedByEmail??(R.reviewed_by?"Unknown":"—")},...R.approved_at?[{label:"Approved",value:(0,Q.KQ)(R.approved_at)}]:[],...R.suspended_at?[{label:"Suspended",value:(0,Q.KQ)(R.suspended_at)}]:[],...R.terminated_at?[{label:"Ended",value:(0,Q.KQ)(R.terminated_at)}]:[],...R.commission_until?[{label:"Commission until",value:(0,Q.KQ)(R.commission_until)}]:[]]}),R.review_note&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Internal note (never shown to the partner)"}),(0,a.jsx)("p",{className:"mt-1.5 whitespace-pre-wrap rounded-lg border bg-muted/30 p-3 text-sm",children:R.review_note})]}),(0,a.jsx)(y.wq,{answers:R.answers})]})}),(0,a.jsx)(Q.Panel,{title:"Stripe payouts",description:"Copied from Stripe each time their account changes. Bank and identity details stay with Stripe.",children:(0,a.jsx)(ey,{partner:R,canBePaid:t.canBePaid})})]}),(0,a.jsx)(Q.Panel,{title:"Agreement",description:"What they accepted, as recorded when they signed. A record can't be edited or removed.",action:(0,a.jsx)(i(),{href:"/partner/agreement",target:"_blank",className:"text-xs font-medium text-muted-foreground hover:text-foreground",children:"Read the current agreement"}),children:t.agreements.length?(0,a.jsx)("ul",{className:"space-y-5",children:t.agreements.map(e=>(0,a.jsx)(ef,{agreement:e},e.id))}):(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"applying"===R.status?"They haven't signed yet: the agreement is the last step of the application.":"No signed agreement on file."})}),(0,a.jsx)(Q.Panel,{title:"Clients",description:"Workspaces attributed to this partner, newest first. An ended attribution stays as history.",flush:!0,children:t.clients.length?(0,a.jsx)("ul",{className:"divide-y border-t",children:t.clients.map(e=>(0,a.jsx)(ej,{client:e},e.attribution_id))}):(0,a.jsx)("p",{className:"border-t px-5 py-10 text-center text-sm text-muted-foreground",children:"approved"===R.status?"No clients yet. One appears here when someone signs up through their link, or an admin allocates one.":"No clients are attributed to this partner."})}),(0,y.X6)(R.status)&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(V.z,{partner:R,onChanged:P},`demos:${R.stage}`),(0,a.jsx)(q.Eg,{partnerId:R.id},`ledger:${R.status}`),(0,a.jsx)(eo.w,{partner:{id:R.id,name:E??R.email}}),(0,a.jsx)(ed,{partnerId:R.id,partnerName:E??R.email})]}),(0,a.jsx)(K,{partnerId:R.id},`changes:${R.updated_at}`),(0,a.jsx)(X,{partnerId:R.id}),(0,a.jsx)(es,{partnerId:R.id})]}):(0,a.jsx)("div",{className:"grid gap-4 lg:grid-cols-2",children:Array.from({length:4}).map((e,t)=>(0,a.jsx)(G.E,{className:"h-48 w-full rounded-xl"},t))}),R&&(0,a.jsx)($,{partner:R,open:u,onOpenChange:g,onSaved:P,abrAvailable:C}),R&&(0,a.jsx)(I.uw,{partner:R,action:k,onOpenChange:e=>!e&&S(null),onDone:P}),(0,a.jsx)(ec.H,{partner:b&&R?R:null,duplicateAbn:t?.duplicateAbn,abrAvailable:C,onOpenChange:e=>!e&&f(!1),onDone:T}),(0,a.jsx)(et.T,{open:v,onOpenChange:_,title:`Reopen ${E??"this"}'s application?`,description:"It goes back to in progress, so they can sign in, change their details and submit again. They aren't emailed about this, so let them know. The agreement they already signed stays on file: if they sign again with a different name or GST registration, the new submit is refused until you sort it out with them.",confirmText:"Reopen",onConfirm:async()=>{await (0,U.nr)(`/api/admin/partners/${e}/review`,{method:"POST",body:JSON.stringify({action:"reopen"})}),p.oR.success("Application reopened"),await T()}})]})}function eg({partner:e}){if(!e.handle)return(0,a.jsx)(a.Fragment,{children:"Set at approval"});let t=`/partner/${e.handle}`;return(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)("span",{className:"truncate font-mono text-xs",children:t}),"approved"!==e.status&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"(not live)"}),(0,a.jsx)("button",{type:"button",onClick:()=>navigator.clipboard.writeText(`${window.location.origin}${t}`).then(()=>p.oR.success("Partner link copied"),()=>p.oR.error("Couldn't copy the link")),className:"rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground","aria-label":"Copy the partner link",children:(0,a.jsx)(m.A,{className:"size-3.5"})})]})}function eb({ids:e}){return e.length?(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[1===e.length?"An earlier Str
1ipe account is no longer connected: ":"Earlier Stripe accounts are no longer connected: ",(0,a.jsx)("span",{className:"font-mono",children:e.join(", ")})]}):null}function ey({partner:e,canBePaid:t}){let s=e.stripe_previous_account_ids??[];if(!e.stripe_account_id)return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:"approved"===e.status?"Not connected. Their Stripe account is created when they open payout setup in the partner portal.":"Not connected. Payout setup opens to a partner once their application is approved."}),(0,a.jsx)(eb,{ids:s})]});let n=e.stripe_requirements?.past_due??[],r=(e.stripe_requirements?.currently_due??[]).filter(e=>!n.includes(e));return(0,a.jsxs)("div",{className:"space-y-4",children:["approved"===e.status&&!t&&(0,a.jsx)("p",{className:"rounded-lg border border-warning-border bg-warning-surface px-3 py-2 text-xs",children:e.stripe_details_submitted?e.stripe_requirements?.past_due?.length||e.stripe_requirements?.currently_due?.length?"Stripe is waiting on them for the items below.":"Stripe hasn't switched on transfers to their account yet.":"They started payout setup with Stripe and haven't finished it."}),(0,a.jsx)(Q.At,{className:"sm:grid-cols-2 lg:grid-cols-2",items:[{label:"Connected account",value:e.stripe_account_id,mono:!0},{label:"Can be paid",value:t?"Yes":"approved"===e.status?"Not yet":"No, not an approved partner"},{label:"Transfers",value:e.stripe_transfers_status?e.stripe_transfers_status.replace(/_/g," "):"Not synced yet"},{label:"Payouts to their bank",value:e.stripe_payouts_enabled?"Enabled":"Not enabled"},{label:"Details submitted",value:e.stripe_details_submitted?"Yes":"No"},{label:"Last synced",value:e.stripe_synced_at?(0,a.jsx)("span",{title:(0,Q.KQ)(e.stripe_synced_at),children:(0,Q.BM)(e.stripe_synced_at)}):"Never"}]}),(n.length>0||r.length>0||e.stripe_requirements?.disabled_reason)&&(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"What Stripe still needs from them"}),(0,a.jsxs)("ul",{className:"mt-1.5 space-y-1 text-sm",children:[n.map(e=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center gap-2",children:[eh(e),(0,a.jsx)(D.E,{variant:"destructive",children:"Overdue"})]},e)),r.map(e=>(0,a.jsx)("li",{children:eh(e)},e))]}),e.stripe_requirements?.disabled_reason&&(0,a.jsxs)("p",{className:"mt-2 text-xs text-muted-foreground",children:["Stripe's reason the account is restricted: ",eh(e.stripe_requirements.disabled_reason)]})]}),(0,a.jsx)(eb,{ids:s})]})}function ef({agreement:e}){return(0,a.jsxs)("li",{className:"space-y-3",children:[(0,a.jsx)(y.lZ,{agreement:e}),(0,a.jsx)(y.oJ,{ids:e.declarations??[]}),(0,a.jsx)(Q.At,{className:"sm:grid-cols-2 lg:grid-cols-3",items:[{label:"Network address",value:e.ip??"—",mono:!!e.ip},{label:"Browser",value:e.user_agent?(0,a.jsx)("span",{title:e.user_agent,children:e.user_agent}):"—"},{label:"Hash of the text they were shown",value:(0,a.jsx)("span",{title:e.content_sha256,children:e.content_sha256}),mono:!0}]})]})}function ej({client:e}){let t=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,a.jsx)("span",{className:"block truncate font-medium",children:e.workspace_name??"Deleted workspace"}),(0,a.jsxs)("span",{className:"block truncate text-xs text-muted-foreground",children:[eu[e.source]??e.source," \xb7 since ",(0,Q.KQ)(e.created_at),e.ended_at?` \xb7 ended ${(0,Q.KQ)(e.ended_at)}`:""]})]}),(0,a.jsx)(D.E,{variant:"outline",children:"split"===e.deal_type?`Split deal \xb7 ${ep[e.role]}`:"Full cycle"}),e.ended_at&&(0,a.jsx)(D.E,{variant:"muted",children:"Ended"})]});return e.workspace_name?(0,a.jsx)("li",{children:(0,a.jsxs)(i(),{href:`/admin/workspaces/${e.workspace_id}`,className:"group flex flex-wrap items-center gap-x-4 gap-y-1 px-5 py-3 text-sm transition-colors hover:bg-accent/50",children:[t,(0,a.jsx)(u.A,{className:"size-4 text-muted-foreground/60 transition-transform group-hover:translate-x-0.5","aria-hidden":!0})]})}):(0,a.jsx)("li",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 px-5 py-3 text-sm text-muted-foreground",children:t})}},95894:(e,t,s)=>{"use strict";s.d(t,{X8:()=>o,Yk:()=>d,nw:()=>r,rl:()=>i,y1:()=>l});var a=s(77977),n=s(10240);let r=20,i=["legal_name","preferred_name","phone","entity_type","abn","trading_name","gst_registered","address_line1","address_line2","suburb","state","postcode"],l={legal_name:"Legal name",preferred_name:"Preferred name",phone:"Phone",entity_type:"Business type",abn:"ABN",trading_name:"Registered business name",gst_registered:"GST registration",address_line1:"Address line 1",address_line2:"Address line 2",suburb:"Suburb",state:"State",postcode:"Postcode"},d=["abn","gst_registered"];function o(e,t){return null==t||""===t?"Not given":"gst_registered"===e?!0===t?"Registered":"Not registered":"string"!=typeof t?String(t):"abn"===e?(0,n.PT)(t):"entity_type"===e?a.ym[t]??t:t}}},e=>{e.O(0,[5730,8409,8500,6609,8755,8495,2619,8384,3339,8001,3985,9742,9440,5554,1893,9076,8441,5254,7358],()=>e(e.s=47162)),_N_E=e.O()}]);

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.