Files
supabase/apps/docs/features/ui/AuthErrorCodes.tsx
Charis 37d92e81c3 refactor(docs): turn auth error codes table into data file (#35857)
* refactor(docs): turn auth error codes table into data file

Take the Markdown error codes table and turn it into a data file
instead. This makes it easy to parse and reuse in other places besides
Markdown documents.

* Update apps/docs/content/errorCodes/authErrorCodes.toml

Co-authored-by: Terry Sutton <saltcod@gmail.com>

---------

Co-authored-by: Terry Sutton <saltcod@gmail.com>
2025-05-27 14:10:40 +00:00

50 lines
1.5 KiB
TypeScript

import Link from 'next/link'
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from 'ui'
import _errorCodes from '~/content/errorCodes/authErrorCodes.toml'
interface ErrorCodeDefinition {
description: string
references: Array<{ href: string; description: string }>
}
const errorCodes: Record<string, ErrorCodeDefinition> = _errorCodes
export function AuthErrorCodes() {
return (
<Table>
<TableHeader>
<TableRow>
<TableHead>Error code</TableHead>
<TableHead>Description</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{Object.entries(errorCodes)
.sort(([aCode], [bCode]) => aCode.localeCompare(bCode))
.map(([code, definition]) => (
<TableRow key={code}>
<TableCell>
<code className="whitespace-nowrap">{code}</code>
</TableCell>
<TableCell>
<p>{definition.description}</p>
{!!definition.references && (
<>
<p>Learn more:</p>
<ul>
{definition.references.map((reference) => (
<li key={reference.href}>
<Link href={reference.href}>{reference.description}</Link>
</li>
))}
</ul>
</>
)}
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
)
}