Fix: Await params in dynamic routes for Next.js 15 compatibility
This commit is contained in:
@@ -3,13 +3,14 @@ import { EditCustomerForm } from "./edit-customer-form"
|
||||
import { createClient } from "@/lib/supabase/server"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
export default async function EditCustomerPage({ params }: { params: { id: string } }) {
|
||||
export default async function EditCustomerPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params
|
||||
const supabase = await createClient()
|
||||
|
||||
const { data: customer } = await supabase
|
||||
.from('customers')
|
||||
.select('*')
|
||||
.eq('id', params.id)
|
||||
.eq('id', id)
|
||||
.single()
|
||||
|
||||
if (!customer) {
|
||||
|
||||
@@ -16,7 +16,7 @@ export default async function ReservationDetailsPage({
|
||||
}: {
|
||||
params: Promise<{ id: string }>
|
||||
}) {
|
||||
const id = (await params).id
|
||||
const { id } = await params
|
||||
const supabase = await createClient()
|
||||
|
||||
const { data: reservation } = await supabase
|
||||
|
||||
@@ -4,7 +4,8 @@ import { createClient } from "@/lib/supabase/server"
|
||||
import { createAdminClient } from "@/lib/supabase/admin"
|
||||
import { notFound } from "next/navigation"
|
||||
|
||||
export default async function EditUserPage({ params }: { params: { id: string } }) {
|
||||
export default async function EditUserPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params
|
||||
const supabase = await createClient()
|
||||
const supabaseAdmin = await createAdminClient()
|
||||
|
||||
@@ -12,7 +13,7 @@ export default async function EditUserPage({ params }: { params: { id: string }
|
||||
const { data: profile } = await supabase
|
||||
.from('profiles')
|
||||
.select('*')
|
||||
.eq('id', params.id)
|
||||
.eq('id', id)
|
||||
.single()
|
||||
|
||||
if (!profile) {
|
||||
@@ -22,7 +23,7 @@ export default async function EditUserPage({ params }: { params: { id: string }
|
||||
// Fetch email from auth.users using admin client
|
||||
let email = undefined
|
||||
if (supabaseAdmin) {
|
||||
const { data: { user }, error } = await supabaseAdmin.auth.admin.getUserById(params.id)
|
||||
const { data: { user }, error } = await supabaseAdmin.auth.admin.getUserById(id)
|
||||
if (user) {
|
||||
email = user.email
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user