2
0

🛂 (billing) Disable sub update when workspace is past due

This commit is contained in:
Baptiste Arnaud
2024-01-25 16:35:16 +01:00
parent 7baaf59b52
commit 0f245b8e57
2 changed files with 17 additions and 9 deletions

View File

@ -49,7 +49,7 @@ export const updateSubscription = authenticatedProcedure
id: workspaceId,
},
select: {
isQuarantined: true,
isPastDue: true,
stripeId: true,
members: {
select: {
@ -59,6 +59,12 @@ export const updateSubscription = authenticatedProcedure
},
},
})
if (workspace?.isPastDue)
throw new TRPCError({
code: 'BAD_REQUEST',
message:
'You have unpaid invoices. Please head over your billing portal to pay it.',
})
if (
!workspace?.stripeId ||
isAdminWriteWorkspaceForbidden(workspace, user)

View File

@ -37,7 +37,7 @@ export const DashboardHeader = () => {
/>
</Link>
<HStack>
{user && workspace && (
{user && workspace && !workspace.isPastDue && (
<WorkspaceSettingsModal
isOpen={isOpen}
onClose={onClose}
@ -45,13 +45,15 @@ export const DashboardHeader = () => {
workspace={workspace}
/>
)}
<Button
leftIcon={<SettingsIcon />}
onClick={onOpen}
isLoading={isNotDefined(workspace)}
>
{t('dashboard.header.settingsButton.label')}
</Button>
{!workspace?.isPastDue && (
<Button
leftIcon={<SettingsIcon />}
onClick={onOpen}
isLoading={isNotDefined(workspace)}
>
{t('dashboard.header.settingsButton.label')}
</Button>
)}
<WorkspaceDropdown
currentWorkspace={workspace}
onLogoutClick={logOut}