Files
supabase/apps/studio/components/interfaces/Organization/BillingSettings/Subscription/MembersExceedLimitModal.tsx
T
Alaister Young e3dae9ec36 chore: only load data in modals when they're visible (#34617)
* chore: only load data in modals when they're visible

* SidePanelGitHubRepoLinker

* scrolling is not my strong suit

* simple loading state for add new secret

* fix button width

* update to use shadcn

* fix ts
2025-04-02 16:41:47 +08:00

57 lines
2.0 KiB
TypeScript

import { useFreeProjectLimitCheckQuery } from 'data/organizations/free-project-limit-check-query'
import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'
import { Button, Modal } from 'ui'
export interface MembersExceedLimitModalProps {
visible: boolean
onClose: () => void
}
const MembersExceedLimitModal = ({ visible, onClose }: MembersExceedLimitModalProps) => {
const selectedOrganization = useSelectedOrganization()
const slug = selectedOrganization?.slug
const { data: membersExceededLimit } = useFreeProjectLimitCheckQuery(
{ slug },
{ enabled: visible }
)
return (
<Modal
hideFooter
visible={visible}
size="medium"
header="Your organization has members who have exceeded their free project limits"
onCancel={onClose}
>
<Modal.Content>
<div className="space-y-2">
<p className="text-sm text-foreground-light">
The following members have reached their maximum limits for the number of active free
plan projects within organizations where they are an administrator or owner:
</p>
<ul className="pl-5 text-sm list-disc text-foreground-light">
{(membersExceededLimit || []).map((member, idx: number) => (
<li key={`member-${idx}`}>
{member.username || member.primary_email} (Limit: {member.free_project_limit} free
projects)
</li>
))}
</ul>
<p className="text-sm text-foreground-light">
These members will need to either delete, pause, or upgrade one or more of these
projects before you're able to downgrade this project.
</p>
</div>
</Modal.Content>
<Modal.Separator />
<Modal.Content className="flex items-center gap-2">
<Button htmlType="button" type="default" onClick={onClose} block>
Understood
</Button>
</Modal.Content>
</Modal>
)
}
export default MembersExceedLimitModal