Files
parakasa/lib/data.ts
2026-01-25 02:13:46 +03:00

32 lines
798 B
TypeScript

import { cache } from 'react'
import { createClient } from '@/lib/supabase-server'
export const getProfile = cache(async (userId: string) => {
const supabase = createClient()
const { data } = await supabase
.from('profiles')
.select('*')
.eq('id', userId)
.single()
return data
})
export const getSiteContents = cache(async () => {
const supabase = createClient()
const { data } = await supabase
.from('site_contents')
.select('*')
// Convert to a simpler key-value map for easier usage in components
const contentMap: Record<string, string> = {}
if (data) {
data.forEach((item: { key: string; value: string }) => {
contentMap[item.key] = item.value
})
}
return contentMap
})