ReadOnlyBadge.tsx17 lines · main
1import { Badge } from 'ui'
2
3import { useProfile } from '@/lib/profile'
4import { useSqlEditorV2StateSnapshot } from '@/state/sql-editor-v2'
5
6export type ReadOnlyBadgeProps = { id: string }
7const ReadOnlyBadge = ({ id }: ReadOnlyBadgeProps) => {
8 const { profile } = useProfile()
9 const snapV2 = useSqlEditorV2StateSnapshot()
10
11 const snippet = snapV2.snippets[id]
12 const isSnippetOwner = profile?.id === snippet?.snippet.owner_id
13
14 return <>{isSnippetOwner ? null : <Badge>Read-only</Badge>}</>
15}
16
17export default ReadOnlyBadge