The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
import { useState } from 'react'
import { Button, DialogFooter, DialogSection, DialogSectionSeparator } from 'ui'
import { CodeEditor } from '@/components/ui/CodeEditor/CodeEditor'
const ReviewEmptyState = () => {
return (
<div className="my-10 flex items-center justify-center space-x-2 opacity-50">
<p>There are no changes made to this policy</p>
</div>
)
}
interface StoragePoliciesReviewProps {
policyStatements: any[]
onSelectBack: any
onSelectSave: any
}
export const StoragePoliciesReview = ({
policyStatements = [],
onSelectBack = () => {},
onSelectSave = () => {},
}: StoragePoliciesReviewProps) => {
const [isSaving, setIsSaving] = useState(false)
const onSavePolicy = () => {
setIsSaving(true)
onSelectSave()
}
return (
<>
<DialogSection className="space-y-6">
<div className="flex items-center justify-between space-y-8 space-x-4">
<div className="flex flex-col">
<p className="text-sm text-foreground-light">
These are the SQL statements that will be used to create your policies. The suffix
appended to the end of your policy name (<code>[hashString]_[number]</code>) just
functions as a unique identifier for each of your policies.
</p>
</div>
</div>
<div className="space-y-4 overflow-y-auto" style={{ maxHeight: '25rem' }}>
{policyStatements.length === 0 && <ReviewEmptyState />}
{policyStatements.map((policy, idx) => {
let formattedSQLStatement = policy.statement || ''
return (
<div key={`policy_${idx}`} className="space-y-2">
<p className="text-sm">{policy.description}</p>
<div className="h-40">
<CodeEditor
hideLineNumbers
isReadOnly
language="pgsql"
defaultValue={formattedSQLStatement}
/>
</div>
</div>
)
})}
</div>
</DialogSection>
<DialogSectionSeparator />
<DialogFooter>
<Button onClick={onSelectBack}>Back to edit</Button>
{policyStatements.length > 0 && (
<Button variant="primary" onClick={onSavePolicy} loading={isSaving}>
Save policy
</Button>
)}
</DialogFooter>
</>
)
}