add freeze subscription

This commit is contained in:
2026-01-18 12:34:19 -03:00
parent 3f0f7ec1e1
commit ae348377a5
10 changed files with 102 additions and 40 deletions

View File

@@ -1,7 +1,6 @@
'use client'
import { formatCNPJ } from '@brazilian-utils/brazilian-utils'
import { IconRosetteDiscountCheckFilled } from '@tabler/icons-react'
import {
BadgeCheckIcon,
CheckIcon,

View File

@@ -24,7 +24,9 @@ export type WorkspaceContextProps = {
address: Address | null
}
export const workspaceContext = createContext<WorkspaceContextProps>()
export const workspaceContext = createContext<
WorkspaceContextProps & { blocked: boolean }
>()
export const workspaceMiddleware = async (
{ params, request, context }: LoaderFunctionArgs,
@@ -63,7 +65,8 @@ export const workspaceMiddleware = async (
activeWorkspace,
workspaces,
subscription: org?.['subscription'] || null,
address: org?.['address'] || null
address: org?.['address'] || null,
blocked: 'subscription_freeze' in org
})
return await next()

View File

@@ -8,12 +8,19 @@ import { userContext } from '@repo/auth/context'
import { authMiddleware } from '@repo/auth/middleware/auth'
import { ModeToggle, ThemedImage } from '@repo/ui/components/dark-mode'
import { NavUser } from '@repo/ui/components/nav-user'
import {
AlertDialog,
AlertDialogContent,
AlertDialogDescription,
AlertDialogTitle
} from '@repo/ui/components/ui/alert-dialog'
import {
SidebarInset,
SidebarProvider,
SidebarTrigger
} from '@repo/ui/components/ui/sidebar'
import { Toaster } from '@repo/ui/components/ui/sonner'
import { cn } from '@repo/ui/lib/utils'
import { AppSidebar } from '@/components/app-sidebar'
import { WorkspaceProvider } from '@/components/workspace-switcher'
@@ -48,14 +55,7 @@ export function shouldRevalidate({
}
export default function Route({ loaderData }: Route.ComponentProps) {
const {
user,
activeWorkspace,
workspaces,
subscription,
address,
sidebar_state
} = loaderData
const { user, sidebar_state, blocked, ...props } = loaderData
useEffect(() => {
if (typeof window !== 'undefined' && window.rybbit) {
@@ -68,13 +68,23 @@ export default function Route({ loaderData }: Route.ComponentProps) {
}, [])
return (
<WorkspaceProvider
activeWorkspace={activeWorkspace}
workspaces={workspaces}
subscription={subscription}
address={address}
>
<SidebarProvider defaultOpen={sidebar_state === 'true'} className="flex">
<WorkspaceProvider {...props}>
{blocked ? (
<AlertDialog open={true}>
<AlertDialogContent>
<AlertDialogTitle>Serviço com acesso suspenso</AlertDialogTitle>
<AlertDialogDescription>
Seu acesso está temporariamente bloqueado devido a um pagamento em
atraso. Regularize para continuar usando a plataforma.
</AlertDialogDescription>
</AlertDialogContent>
</AlertDialog>
) : null}
<SidebarProvider
defaultOpen={sidebar_state === 'true'}
className={cn('flex', blocked && 'pointer-events-none')}
>
<AppSidebar />
<SidebarInset className="relative flex flex-col flex-1 min-w-0">

View File

@@ -1,7 +1,7 @@
'use client'
import { type ColumnDef } from '@tanstack/react-table'
import { EllipsisIcon, PencilIcon } from 'lucide-react'
import { BadgeCheckIcon, EllipsisIcon, PencilIcon } from 'lucide-react'
import { NavLink } from 'react-router'
import { Abbr } from '@repo/ui/components/abbr'
@@ -38,13 +38,20 @@ export const columns: ColumnDef<Org>[] = [
{
header: 'Empresa',
cell: ({ row }) => {
const { name, email } = row.original
const { name, email, subscription_covered } = row.original
return (
<div className="flex gap-2.5 items-center">
<Avatar className="size-10 hidden lg:block">
<AvatarFallback className="border">{initials(name)}</AvatarFallback>
</Avatar>
<div className="relative">
{subscription_covered ? (
<BadgeCheckIcon className="fill-blue-500 stroke-white absolute size-4 dark:size-3.5 -top-0 -right-0 z-2" />
) : null}
<Avatar className="size-10 hidden lg:block">
<AvatarFallback className="border">
{initials(name)}
</AvatarFallback>
</Avatar>
</div>
<ul>
<li className="font-bold">