PageSourceSearch

https://taxease360.ai/assets/SuperAccountants-gxHNe_QB.js

js taxease360.ai collected 2026-10-05 14:25:40 UTC 12,491 bytes, 7 lines download raw bytes

1import{c as Q,r as d,j as t,q as h,v as V,e as W,L as $,a7 as X,y as Y,an as Z,aO as A,ac as ee,ag as te,a1 as ae,t as F,p as x,bh as r}from"./index-CfXbMZ_V.js";import{I as se}from"./InviteAccountantDialog-DcKBNe4S.js";import{D as ne,a as ie,b as le,c as re,d as de}from"./dialog-D3H816yE.js";import{C as ce}from"./circle-alert-DPw7Scbn.js";import{A as oe}from"./archive-restore-C_Z0fNFm.js";import{P as S}from"./power-4s9LtUWg.js";import"./textarea-D5CbgVJ9.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const ue=[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],xe=Q("PowerOff",ue);function ye(){var w,_,k,C,I,R,z,D;const[T,O]=d.useState(null),[P,U]=d.useState(!0),[b,L]=d.useState(""),[u,f]=d.useState("all"),[E,y]=d.useState(!1),[i,l]=d.useState(null),[a,c]=d.use
6State(null),M=async e=>{var s,p;l(e.id);try{await x.functions.invoke("inviteAccountant",{email:e.email,owner_name:e.owner_name||"",company_id:e.company_id||"",company_name:e.company_name||"",message:"",app_base_url:window.location.origin}),r({title:"Invite resent",description:`Sent to ${e.email}`}),o()}catch(n){r({title:"Failed to resend",description:((p=(s=n==null?void 0:n.response)==null?void 0:s.data)==null?void 0:p.error)||(n==null?void 0:n.message),variant:"destructive"})}finally{l(null)}},B=async e=>{l(e.id);try{await x.entities.Franchisee.update(e.id,{status:"Inactive"}),r({title:"Access revoked",description:`${e.email} can no longer log in.`}),o()}catch(s){r({title:"Failed to revoke",description:s==null?void 0:s.message,variant:"destructive"})}finally{l(null)}},q=async e=>{l(e.id);try{await x.entities.Franchisee.update(e.id,{archived:!0}),r({title:"Archived",description:`${e.email} moved to the archived list.`}),f("archived"),o()}catch(s){r({title:"Failed to archive",description:s==null?void 0:s.message,variant:"destructive"})}finally{l(null)}},H=async e=>{l(e.id);try{await x.entities.Franchisee.update(e.id,{archived:!1}),r({title:"Restored",description:`${e.email} is back in the active list.`}),o()}catch(s){r({title:"Failed to restore",description:s==null?void 0:s.message,variant:"destructive"})}finally{l(null)}},G=async()=>{var s,p;if(!a)return;const e=a.accountant;l(e.id);try{await x.functions.invoke("manageStaffAccount",{target_user_id:e.user_id,action:a.action}),r({title:`Account ${{activate:"activated",deactivate:"deactivated",delete:"deleted",restore:"restored"}[a.action]}`,description:`${e.email||e.owner_name}`}),o()}catch(n){r({title:"Action failed",description:((p=(s=n==null?void 0:n.response)==null?void 0:s.data)==null?void 0:p.error)||(n==null?void 0:n.message),variant:"destructive"})}finally{l(null),c(null)}},o=async()=>{try{const e=await x.functions.invoke("superAdminDashboard",{});O(e.data)}catch(e){L(e.message||"Failed to load")}finally{U(!1)}};if(d.useEffect(()=>{o()},[]),P)return t.jsx("div",{className:"flex justify-center py-16",children:t.jsx(h,{className:"w-6 h-6 text-violet-500 animate-spin"})});if(b)return t.jsxs("div",{className:"flex flex-col items-center py-16 text-center",children:[t.jsx(ce,{size:28,className:"text-red-400 mb-2"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:b})]});const{accountants:m,companies:j,unassigned:J}=T,g=m.filter(e=>e.archived===!0),v=m.filter(e=>!e.archived&&e.status!=="Inactive"&&!e.user_id),N=m.filter(e=>u==="archived"?e.archived===!0:e.archived?!1:u==="all"?!0:u==="pending"?e.status!=="Inactive"&&!e.user_id:u==="unassigned"?!e.company_id:e.company_id===u),K=[{id:"all",name:"All accountants"},{id:"pending",name:`Pending invites${v.length?` (${v.length})`:""}`},{id:"unassigned",name:"Unassigned"},...j.map(e=>({id:e.id,name:e.name})),{id:"archived",name:`Archived${g.length?` (${g.length})`:""}`}];return t.jsxs("div",{className:"space-y-4 pb-10",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-xl font-bold text-foreground",children:"Accountants"}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[m.length," total · ",v.length," pending · ",J.length," unassigned · ",g.length," archived"]})]}),t.jsxs("button",{onClick:()=>y(!0),className:"inline-flex items-center gap-1.5 bg-violet-600 hover:bg-violet-700 text-foreground rounded-xl px-3 py-2 text-xs font-semibold",children:[t.jsx(V,{size:14})," Invite"]})]}),t.jsx(se,{open:E,onOpenChange:y,companies:j,onDone:o}),t.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1 -mx-1 px-1",children:K.map(e=>t.jsx("button",{onClick:()=>f(e.id),className:`shrink-0 px-3 py-1.5 rounded-full text-xs font-medium whitespace-nowrap transition-colors
7              ${u===e.id?"bg-violet-600 text-foreground":"bg-card border border-border text-muted-foreground"}`,children:e.name},e.id))}),N.length===0?t.jsxs("div",{className:"bg-card border border-border rounded-2xl p-8 text-center",children:[t.jsx(W,{size:28,className:"mx-auto text-gray-600 mb-2"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No accountants in this view."})]}):t.jsx("div",{className:"space-y-3",children:N.map(e=>t.jsxs("div",{className:"bg-card border border-border rounded-2xl p-4",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs($,{to:`/super/accountants/${encodeURIComponent(e.email||e.id)}`,className:"min-w-0 group flex-1",children:[t.jsx("p",{className:"font-semibold text-foreground truncate group-hover:text-violet-300 transition-colors",children:e.owner_name||"Unnamed accountant"}),e.email&&t.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[t.jsx(X,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.email})]})]}),e.user_id&&t.jsx($,{to:`/super/accountants/${encodeURIComponent(e.email||e.id)}`,className:"shrink-0 text-gray-600 hover:text-violet-300 transition-colors",children:t.jsx(Y,{size:16})}),t.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.company_name?t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-violet-500/15 text-violet-300 whitespace-nowrap",children:e.company_name}):t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-amber-500/15 text-amber-400 whitespace-nowrap",children:"Unassigned"}),e.archived&&t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-gray-500/15 text-muted-foreground whitespace-nowrap",children:"Archived"}),e.account_status==="deleted"?t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-gray-500/15 text-muted-foreground whitespace-nowrap",children:"Deleted"}):e.status==="Inactive"?t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-red-500/15 text-red-400 whitespace-nowrap",children:"Inactive"}):e.user_id?t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-emerald-500/15 text-emerald-400 whitespace-nowrap",children:"Active"}):t.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-sky-500/15 text-sky-400 whitespace-nowrap",children:"Invited"})]})]}),t.jsxs("div",{className:"flex items-center justify-between mt-3",children:[t.jsxs("div",{className:"flex items-center gap-1 text-xs text-emerald-400",children:[t.jsx(Z,{size:12}),t.jsx("span",{className:"font-medium",children:e.client_count}),t.jsx("span",{className:"text-muted-foreground",children:"clients"})]}),t.jsxs("div",{className:"flex items-center gap-1 flex-wrap justify-end",children:[e.archived?t.jsxs("button",{onClick:()=>H(e),disabled:i===e.id,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-muted hover:bg-accent text-xs text-foreground disabled:opacity-50","aria-label":"Restore accountant",children:[i===e.id?t.jsx(h,{size:13,className:"animate-spin"}):t.jsx(oe,{size:13}),"Restore"]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>M(e),disabled:i===e.id,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-muted hover:bg-accent text-xs text-foreground disabled:opacity-50","aria-label":e.status==="Inactive"?"Reactivate invite":"Resend invite",children:[i===e.id?t.jsx(h,{size:13,className:"animate-spin"}):t.jsx(A,{size:13}),e.status==="Inactive"?"Reactivate":"Resend"]}),(e.user_id||e.status==="Inactive")&&t.jsxs("button",{onClick:()=>q(e),disabled:i===e.id,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-muted hover:bg-accent text-xs text-foreground disabled:opacity-50","aria-label":"Archive invitation",children:[t.jsx(ee,{size:13})," Archive"]}),e.status!=="Inactive"&&t.jsxs("button",{onClick:()=>B(e),disabled:i===e.id,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-red-500/10 hover:bg-red-500/20 text-xs text-red-400 disabled:opacity-50","aria-label":"Revoke access",children:[t.jsx(te,{size:13})," Revoke"]})]}),e.user_id&&e.account_status==="deleted"&&t.jsxs("button",{onClick:()=>c({accountant:e,action:"restore"}),disabled:i===e.id,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-emerald-500/10 hover:bg-emerald-500/20 text-xs text-emerald-400 disabled:opacity-50","aria-label":"Restore deleted account",children:[t.jsx(S,{size:13})," Restore"]}),e.user_id&&e.account_status!=="deleted"&&(e.account_status==="inactive"||e.status==="Inactive"?t.jsxs("button",{onClick:()=>c({accountant:e,action:"activate"}),disabled:i===e.id,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-emerald-500/10 hover:bg-emerald-500/20 text-xs text-emerald-400 disabled:opacity-50","aria-label":"Activate account",children:[t.jsx(S,{size:13})," Activate"]}):t.jsxs("button",{onClick:()=>c({accountant:e,action:"deactivate"}),disabled:i===e.id,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-amber-500/10 hover:bg-amber-500/20 text-xs text-amber-400 disabled:opacity-50","aria-label":"Deactivate account",children:[t.jsx(xe,{size:13})," Disable"]})),e.user_id&&e.account_status!=="deleted"&&t.jsxs("button",{onClick:()=>c({accountant:e,action:"delete"}),disabled:i===e.id,className:"inline-flex items-center gap-1 px-2 py-1 rounded-lg bg-red-500/10 hover:bg-red-500/20 text-xs text-red-400 disabled:opacity-50","aria-label":"Permanently delete account",children:[t.jsx(ae,{size:13})," Delete"]})]})]})]},e.id))}),t.jsx(ne,{open:!!a,onOpenChange:e=>!e&&c(null),children:t.jsxs(ie,{className:"bg-card border-border text-foreground",children:[t.jsx(le,{children:t.jsx(re,{className:"text-foreground",children:(a==null?void 0:a.action)==="delete"?"Permanently delete account":(a==null?void 0:a.action)==="deactivate"?"Deactivate account":(a==null?void 0:a.action)==="restore"?"Restore deleted account":"Activate account"})}),t.jsx("p",{className:"text-sm text-muted-foreground",children:(a==null?void 0:a.action)==="delete"?`This will permanently remove login access for ${((w=a==null?void 0:a.accountant)==null?void 0:w.email)||((_=a==null?void 0:a.accountant)==null?void 0:_.owner_name)}. The accountant profile will be archived. This cannot be undone.`:(a==null?void 0:a.action)==="deactivate"?`This will disable login access for ${((k=a==null?void 0:a.accountant)==null?void 0:k.email)||((C=a==null?void 0:a.accountant)==null?void 0:C.owner_name)}. They will no longer be able to sign in until reactivated.`:(a==null?void 0:a.action)==="restore"?`This will re-enable login access for ${((I=a==null?void 0:a.accountant)==null?void 0:I.email)||((R=a==null?void 0:a.accountant)==null?void 0:R.owner_name)}. Their profile will be unarchived and restored to active status.`:`This will re-enable login access for ${((z=a==null?void 0:a.accountant)==null?void 0:z.email)||((D=a==null?void 0:a.accountant)==null?void 0:D.owner_name)}.`}),t.jsxs(de,{className:"gap-2",children:[t.jsx(F,{variant:"outline",onClick:()=>c(null),className:"bg-transparent border-gray-600 text-foreground",children:"Cancel"}),t.jsxs(F,{onClick:G,disabled:i!==null,className:(a==null?void 0:a.action)==="delete"?"bg-red-600 hover:bg-red-700 text-foreground":"bg-violet-600 hover:bg-violet-700 text-foreground",children:[i!==null?t.jsx(h,{size:14,className:"animate-spin mr-1"}):null,(a==null?void 0:a.action)==="delete"?"Delete account":(a==null?void 0:a.action)==="deactivate"?"Deactivate":(a==null?void 0:a.action)==="restore"?"Restore account":"Activate"]})]})]})})]})}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.