import { useParams } from 'common' import { Badge } from 'ui' import { DOCS_RESOURCE_CONTENT } from '../ProjectAPIDocs.constants' import ResourceContent from '../ResourceContent' import type { ContentProps } from './Content.types' import { useBucketInfoQueryPreferCached } from '@/data/storage/buckets-query' import { formatBytes } from '@/lib/helpers' import { useAppStateSnapshot } from '@/state/app-state' export const Bucket = ({ language, apikey, endpoint }: ContentProps) => { const { ref } = useParams() const snap = useAppStateSnapshot() const resource = snap.activeDocsSection[1] const bucket = useBucketInfoQueryPreferCached(resource, ref) const allowedMimeTypes = bucket?.allowed_mime_types const maxFileSizeLimit = bucket?.file_size_limit if (bucket === undefined) return null return (

{bucket.name}

{bucket.public ? 'Public' : 'Private'}

Allowed MIME types:{' '} {allowedMimeTypes === null ? 'All types are allowed' : (allowedMimeTypes ?? []).length === 0 ? 'No types are allowed' : (allowedMimeTypes ?? []).length > 1 ? (allowedMimeTypes ?? []).join(', ') : 'Unknown'}

Max file size limit:{' '} {maxFileSizeLimit === null ? 'No limit' : `${formatBytes(maxFileSizeLimit)}`}

{bucket.public ? ( ) : ( )}
) }