29 lines
622 B
TypeScript
29 lines
622 B
TypeScript
'use client'
|
|
|
|
import useSupabaseBrowser from '@/utils/supabase-browser'
|
|
import { getCountryById } from '@/queries/get-country-by-id'
|
|
import { useQuery } from '@supabase-cache-helpers/postgrest-react-query'
|
|
|
|
export default function CountryPage({ params }: { params: { id: number } }) {
|
|
const supabase = useSupabaseBrowser()
|
|
const {
|
|
data: country,
|
|
isLoading,
|
|
isError,
|
|
} = useQuery(getCountryById(supabase, params.id))
|
|
|
|
if (isLoading) {
|
|
return <div>Loading...</div>
|
|
}
|
|
|
|
if (isError || !country) {
|
|
return <div>Error</div>
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h1>{country.name}</h1>
|
|
</div>
|
|
)
|
|
}
|