PageSourceSearch

https://getvoltr.com/app/assets/WorkspaceManagementModal-C43x2iVF.js

js getvoltr.com collected 2026-10-02 05:01:32 UTC 10,980 bytes, 1 lines download raw bytes

1import{r as g,j as a}from"./react-BJCrwb27.js";import{a as X}from"./tanstack-BOscu_PA.js";import{bU as ee,dq as I,bH as c,bG as ae,bY as re,bZ as ne}from"./index-Cok8iJMB.js";import{B as t,M as ie,S as te,a1 as Y,b as oe,a as se}from"./route-support-BEJAjkqU.js";import{L as ce,l as le}from"./LifecycleBillingNotice-cyo8Bc8w.js";import"./vendor-DIeMxnSD.js";const de={rename:"rename",remove:"leave",delete_empty:"delete_empty",reactivate:"reactivate"};function pe(n){return de[n]||null}function _(n){return String(n||"").replace(/\s+/g," ").trim()}function me(n,f){const l=_(f);return l.length>=2&&l!==_(n)}const ue={overview:"Edit workspace",rename:"Rename workspace",remove:"Remove workspace from my account",delete_empty:"Delete empty workspace",reactivate:"Restore workspace"},he={workspace_archived:"Restore this workspace before changing its active access.",workspace_not_archived:"This workspace is already active.",workspace_billing_adjustment_pending:"The prior billing change is still reconciling. Restore becomes available after it completes.",last_workspace_admin:"Assign another owner or admin before removing yourself so the workspace keeps an administrator.",last_workspace_member:"The last member cannot remove themselves because that would orphan the workspace.",last_workspace:"You need another workspace before deleting this one.",workspace_admin_required:"Only a workspace owner or admin can manage this workspace.",workspace_owner_required:"Only the workspace owner can delete it while an owner is assigned.",workspace_has_other_members:"Remove or transfer the other members before deleting this workspace.",billing_workspace_has_children:"Linked client workspaces must be moved before this billing workspace can be deleted.",billing_history_requires_support:"This workspace has billing history and requires a reviewed support removal.",primary_managed_workspace_requires_support:"The primary workspace for a managed contract cannot be deleted here.",managed_workspace_requires_support:"This managed workspace requires a reviewed support removal.",workspace_billing_admin_required:"Only an admin of the managed account can delete this empty workspace.",workspace_has_invite_history:"This workspace has invitation history and requires a reviewed support removal.",workspace_has_legacy_users:"This workspace still anchors another account and requires a reviewed support removal.",workspace_has_data:"This workspace contains brand data. You can remove your own membership, but the workspace cannot be deleted here.",workspace_delete_billing_change_requires_support:"This deletion would affect billing and requires a reviewed support removal.",workspace_delete_unavailable:"Voltr could not verify that this workspace is empty, so deletion is disabled."};function P(n){return n?he[n]||"This action is unavailable until the workspace is safe to change.":""}function ge(){return`${"/app/".replace(/\/$/,"")}/dashboard`}function ve(){return`${"/app/".replace(/\/$/,"")}/settings?tab=billing`}function je({activeId:n,onClose:f,workspaces:l}){var W,F,M,O,V,B,L,A,D;const{showToast:J}=ee(),[d,R]=g.useState(n||((W=l[0])==null?void 0:W.id)||""),[i,S]=g.useState("overview"),[x,j]=g.useState(""),[C,q]=g.useState(""),[o,E]=g.useState(!1),[m,b]=g.useState("");g.useEffect(()=>{var r;l.some(y=>y.id===d)||R(n||((r=l[0])==null?void 0:r.id)||"")},[n,d,l]);const s=X({queryKey:["workspace-management",d],placeholderData:void 0,queryFn:({signal:r})=>se(`/api/auth?action=workspaces&sub=manage&brand_id=${encodeURIComponent(d)}`,{signal:r}),enabled:!!d,staleTime:15e3}),e=s.data,v=s.isLoading||s.isFetching||s.isError||!e,u=l.find(r=>r.id===d);function K(r){R(r),S("overview"),j(""),q(""),b("")}function w(r){S(r),b(""),q(""),r==="rename"&&j(_((e==null?void 0:e.workspace.name)??(u==null?void 0:u.name)))}async function Q(r){var y;if(!(!d||o||v)){E(!0),b("");try{r!=="rename"&&re();const h=await oe(`/api/auth?action=workspaces&sub=${r}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({brand_id:d,...r==="rename"?{name:_(x)}:{},...r==="delete_empty"?{confirmation_name:_(C)}:{},...r==="leave"&&((y=e==null?void 0:e.leave_billing)!=null&&y.change_required)?{billing_fingerprint:e.leave_billing.fingerprint,billing_mode:e.leave_billing.mode}:{}})}),p=await h.json().catch(()=>({}));
1if(!h.ok){if((p.code==="billing_confirmation_required"||p.code==="billing_impact_changed")&&await s.refetch(),r==="reactivate"&&h.status===402&&p.code==="workspace_addon_required")throw new Error("Additional workspace purchases are not currently available.");if(r==="reactivate"&&h.status===402&&p.code==="workspace_seat_capacity_required"){const U=Math.max(1,Number(p.additional_seats_required)||1);throw new Error(`Add ${U} paid seat${U===1?"":"s"} in Billing before restoring every member.`)}throw new Error(p.error||"Could not update the workspace.")}const Z=le(p.billing_adjustment);J(Z||(r==="rename"?"Workspace renamed":r==="leave"?"Workspace removed from your account":r==="delete_empty"?"Empty workspace deleted":"Workspace restored with its existing data"),p.billing_adjustment&&!["applied","scheduled_cancel"].includes(p.billing_adjustment.status)?"yellow":"green"),ne(),window.location.assign(ge())}catch(h){E(!1),b(h instanceof Error?h.message:"Could not update the workspace.")}}}const z=ue[i],T=_((e==null?void 0:e.workspace.name)??(u==null?void 0:u.name)),N=I(u),G=!!(e!=null&&e.workspace.archived_at),$=pe(i);function k(){$&&Q($)}const H=i==="overview"?null:a.jsxs(a.Fragment,{children:[a.jsx(t,{disabled:o,onClick:()=>w("overview"),type:"button",variant:"secondary",children:"Back"}),i==="rename"?a.jsx(t,{disabled:o||v||!(e!=null&&e.can_rename)||!me(T,x),onClick:k,type:"button",variant:"volt",children:o?"Saving...":"Save name"}):i==="remove"?a.jsx(t,{disabled:o||v||!(e!=null&&e.can_leave),onClick:k,type:"button",variant:"danger",children:o?"Removing...":"Remove"}):i==="delete_empty"?a.jsx(t,{disabled:o||v||!(e!=null&&e.can_delete_empty)||C!==T,onClick:k,type:"button",variant:"danger",children:o?"Deleting...":"Delete workspace"}):i==="reactivate"?a.jsx(t,{disabled:o||v||!(e!=null&&e.can_reactivate)||(((F=e==null?void 0:e.reactivation_capacity)==null?void 0:F.additional_workspace_addons_required)||0)>0,onClick:k,type:"button",variant:"volt",children:o?"Restoring...":(((M=e==null?void 0:e.reactivation_capacity)==null?void 0:M.additional_workspace_addons_required)||0)>0?"Workspace purchases unavailable":"Restore workspace"}):null]});return a.jsxs(ie,{footer:H,onClose:()=>{o||f()},title:z,width:"520px",children:[i!=="overview"&&v?a.jsx(c,{title:"Checking workspace safety",children:s.isError?a.jsx(t,{onClick:()=>{s.refetch()},type:"button",variant:"secondary",children:"Retry"}):"Refreshing roles and billing boundaries…"}):null,i==="overview"?a.jsxs("div",{className:"grid gap-4",children:[a.jsxs("label",{className:"grid gap-1.5 text-xs font-semibold text-text2",children:["Workspace",a.jsx(ae,{ariaLabel:"Workspace to edit",onChange:K,options:l.map(r=>({value:r.id,label:`${I(r)} · ${r.role||"member"}${r.archived_at?" · archived":""}`})),value:d})]}),s.isLoading||s.isFetching?a.jsx(te,{count:3,label:"Checking workspace safety",variant:"rows"}):s.isError||!e?a.jsxs(c,{title:"Could not verify this workspace",tone:"danger",children:["Nothing was changed. ",a.jsx(t,{onClick:()=>{s.refetch()},type:"button",variant:"secondary",children:"Retry"})]}):a.jsx("div",{className:"grid gap-2",children:G?a.jsxs(a.Fragment,{children:[a.jsx(t,{disabled:!e.can_reactivate,onClick:()=>w("reactivate"),type:"button",variant:"volt",children:"Restore workspace"}),e.can_reactivate?null:a.jsx("div",{className:"text-xs leading-5 text-yellow",children:P(e.reactivate_block_code)})]}):a.jsxs(a.Fragment,{children:[a.jsx(t,{disabled:!e.can_rename,onClick:()=>w("rename"),type:"button",variant:"secondary",children:"Rename"}),a.jsx(t,{disabled:!e.can_leave,onClick:()=>w("remove"),type:"button",variant:"danger",children:"Remove from my account"}),e.can_delete_empty?a.jsx(t,{onClick:()=>w("delete_empty"),type:"button",variant:"danger",children:"Delete empty workspace"}):null,e.can_leave?null:a.jsx("div",{className:"text-xs leading-5 text-yellow",children:P(e.leave_block_code)})]})})]}):i==="rename"?a.jsxs("div",{className:"grid gap-4",children:[a.jsxs("label",{className:"grid gap-1.5 text-xs font-semibold text-text2",children:["Workspace name",a.jsx(Y,{autoFocus:!0,maxLength:100,onChange:r=>j(r.target.value),value:x})]}),m?a.jsx(c,{tone:"danger",children:m}):null]}):i==="remove"?a.jsxs("div",{className:"grid gap-4",children:[a.jsx(c,{title:`Remove ${N} from your account?`,tone:"warning",children:"Only your membership is removed. The workspace, its data, and other members stay unchanged, and an admin can invite you back. Any paid-seat change is shown below before you confirm."}),a.jsx(ce,{impact:e==null?void 0:e.leave_billing}),m?a.jsx(c,{tone:"danger",children:m}):null]}):i==="delete_empty"?a.jsxs("div",{className:"grid gap-4",children:[a.jsx(c,{title:`Permanently delete ${N}?`,tone:"danger",children:"Voltr verified that this workspace has no brand data, integrations, billing history, invitations, or other members. Deleting it removes only this empty workspace and its automatically generated setup re
1cords. Your other workspaces, managed contract, and billing stay unchanged."}),a.jsxs("label",{className:"grid gap-1.5 text-xs font-semibold text-text2",children:["Type ",a.jsx("span",{className:"font-mono text-text",children:T})," to confirm",a.jsx(Y,{autoComplete:"off",autoFocus:!0,onChange:r=>q(r.target.value),value:C})]}),m?a.jsx(c,{tone:"danger",children:m}):null]}):a.jsxs("div",{className:"grid gap-4",children:[a.jsx(c,{title:`Restore ${N}?`,children:"This restores the existing workspace and its data."}),(((O=e==null?void 0:e.reactivation_capacity)==null?void 0:O.additional_workspace_addons_required)||0)>0?a.jsx(a.Fragment,{children:a.jsx(c,{title:"Workspace purchase required",tone:"warning",children:"No prepaid workspace slot is available, and additional workspace purchases are temporarily unavailable. The existing workspace and all of its data remain archived and unchanged."})}):null,(((V=e==null?void 0:e.reactivation_capacity)==null?void 0:V.additional_seats_required)||0)>0?a.jsxs(c,{title:"Seat capacity required",tone:"warning",children:["Add ",(B=e==null?void 0:e.reactivation_capacity)==null?void 0:B.additional_seats_required," paid seat",((L=e==null?void 0:e.reactivation_capacity)==null?void 0:L.additional_seats_required)===1?"":"s"," in Billing before all ",(A=e==null?void 0:e.reactivation_capacity)==null?void 0:A.projected_seat_usage," retained members can safely regain access."]}):null,(((D=e==null?void 0:e.reactivation_capacity)==null?void 0:D.additional_seats_required)||0)>0?a.jsx(t,{onClick:()=>window.location.assign(ve()),type:"button",variant:"secondary",children:"Manage seats"}):null,m?a.jsx(c,{tone:"danger",children:m}):null]})]})}export{je as WorkspaceManagementModal};

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.