Files
supabase/apps/studio/components/layouts/AppLayout/RestrictionBanner.tsx
Alaister YoungandKevin Grüneberg 70da0f1d1d chore: cleanup packages (#27770)
* chore: cleanup packages

- Avoid circular imports
- Export API-types as types
- pg-format without depending on Node internal Buffer (not browser-compatible)
- Avoid importing from barrel files in ui dir

* chore: avoid barrel file imports in studio (#27771)

* chore: avoid barrel file imports

- Removes some unused imports
- Avoids barrel file import for faster builds + less memory

* add eslint rule

* type fixes

* delete layouts barrel

* delete components/grid barrel file

* delete components/grid/utils barrel file

* delete components/grid/components/common barrel file

* delete components/grid/components/editor barrel file

* delete components/grid/components/formatter barrel file

* delete components/grid/components/grid barrel file

* delete components/grid/components/header/filter barrel file

* remote components/grid/store barrel file

* remove components/interfaces/Auth/Policies barrel file

* delete components/interfaces/Settings/Logs barrel file

* delete components/ui/CodeEditor barrel file

* delete components/ui/Forms barrel file

* delete components/ui/Shimmers barrel file

* delete data/analytics barrel file

* delete hooks barrel file

* cleanup lib/common/fetch barrel file

* final * barral files cleanup

* global react-data-grid styles

* remove console.log

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>

* fix build

---------

Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
2024-07-04 14:48:10 +08:00

41 lines
1.8 KiB
TypeScript

import dayjs from 'dayjs'
import Link from 'next/link'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { AlertTitle_Shadcn_, Alert_Shadcn_, Button } from 'ui'
import { CriticalIcon, WarningIcon } from 'ui-patterns/Icons/StatusIcons'
import { useSelectedProject } from 'hooks/misc/useSelectedProject'
/**
* Shown on projects in organization which are above their qouta
*/
export const RestrictrionBanner = () => {
const project = useSelectedProject()
const { data } = useOrganizationsQuery()
const currentOrg = data?.find((org) => org.id === project?.organization_id)
if (!currentOrg?.restriction_status) return null
return (
<Alert_Shadcn_
variant={currentOrg.restriction_status === 'restricted' ? 'destructive' : 'warning'}
className="rounded-none border-l-0 border-r-0 h-[44px] p-0 flex items-center justify-center"
>
<AlertTitle_Shadcn_ className="flex items-center gap-x-4">
{currentOrg.restriction_status === 'restricted' ? <CriticalIcon /> : <WarningIcon />}
<span>
{currentOrg.restriction_status === 'grace_period' &&
`Your organization has exceeded its quota. You are given a grace period until ${dayjs(currentOrg.restriction_data['grace_period_end']).format('DD MMM, YYYY')}`}
{currentOrg.restriction_status === 'grace_period_over' &&
`Your grace period is over and your project will not be able to serve requests when you used up your quota.`}
{currentOrg.restriction_status === 'restricted' &&
'Your project is unable to serve any requests as your organization has used up its quota.'}
</span>
<Button asChild type="default">
<Link href={`/org/${currentOrg.slug}/billing`}>More information</Link>
</Button>
</AlertTitle_Shadcn_>
</Alert_Shadcn_>
)
}