Skip to content

Commit 30e6427

Browse files
committed
fix(billing): close the Chat plan popup when its shell unmounts and name the organization's plan on organization routes
1 parent e137d82 commit 30e6427

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

‎apps/sim/app/workspace/[workspaceId]/home/components/chat-plan-modal/chat-plan-modal.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use client'
22

3+
import { useEffect } from 'react'
34
import {
45
ChipModal,
56
ChipModalBody,
@@ -15,12 +16,15 @@ import { useChatPlanModalStore } from '@/stores/modals/chat-plan/store'
1516

1617
/**
1718
* Answers a send the workspace's plan refuses: Chat is on paid plans, with the way to upgrade
18-
* for a viewer who may, and who to ask for one who may not. Render it once per workspace shell.
19+
* for a viewer who may, and who to ask for one who may not. Render it once per workspace shell;
20+
* leaving the shell closes it, so a refusal never reopens in the next workspace or organization.
1921
*/
2022
export function ChatPlanModal() {
2123
const isOpen = useChatPlanModalStore((state) => state.isOpen)
2224
const close = useChatPlanModalStore((state) => state.close)
2325

26+
useEffect(() => close, [close])
27+
2428
return (
2529
<ChipModal
2630
open={isOpen}

‎apps/sim/app/workspace/[workspaceId]/home/hooks/use-plan-upgrade-link.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ export function usePlanUpgradeLink(data: PlanUpgradeLinkInput): PlanUpgradeLink
6363
const action = planRequired
6464
? 'upgrade this workspace’s plan'
6565
: 'manage this workspace’s usage limits'
66-
const unavailableMessage =
67-
organizationContext && !planRequired
68-
? 'Contact an organization admin to manage usage limits.'
69-
: organizationContext || hostContext?.hostOrganizationId
70-
? `Contact an organization admin to ${action}.`
71-
: `Only the workspace owner can ${action}.`
66+
const unavailableMessage = organizationContext
67+
? planRequired
68+
? 'Contact an organization admin to upgrade this organization’s plan.'
69+
: 'Contact an organization admin to manage usage limits.'
70+
: hostContext?.hostOrganizationId
71+
? `Contact an organization admin to ${action}.`
72+
: `Only the workspace owner can ${action}.`
7273

7374
return {
7475
href,

0 commit comments

Comments
 (0)