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 { createClient } from "@/lib/supabase/server"
|
||||||
import { notFound } from "next/navigation"
|
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 supabase = await createClient()
|
||||||
|
|
||||||
const { data: customer } = await supabase
|
const { data: customer } = await supabase
|
||||||
.from('customers')
|
.from('customers')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('id', params.id)
|
.eq('id', id)
|
||||||
.single()
|
.single()
|
||||||
|
|
||||||
if (!customer) {
|
if (!customer) {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export default async function ReservationDetailsPage({
|
|||||||
}: {
|
}: {
|
||||||
params: Promise<{ id: string }>
|
params: Promise<{ id: string }>
|
||||||
}) {
|
}) {
|
||||||
const id = (await params).id
|
const { id } = await params
|
||||||
const supabase = await createClient()
|
const supabase = await createClient()
|
||||||
|
|
||||||
const { data: reservation } = await supabase
|
const { data: reservation } = await supabase
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { createClient } from "@/lib/supabase/server"
|
|||||||
import { createAdminClient } from "@/lib/supabase/admin"
|
import { createAdminClient } from "@/lib/supabase/admin"
|
||||||
import { notFound } from "next/navigation"
|
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 supabase = await createClient()
|
||||||
const supabaseAdmin = await createAdminClient()
|
const supabaseAdmin = await createAdminClient()
|
||||||
|
|
||||||
@@ -12,7 +13,7 @@ export default async function EditUserPage({ params }: { params: { id: string }
|
|||||||
const { data: profile } = await supabase
|
const { data: profile } = await supabase
|
||||||
.from('profiles')
|
.from('profiles')
|
||||||
.select('*')
|
.select('*')
|
||||||
.eq('id', params.id)
|
.eq('id', id)
|
||||||
.single()
|
.single()
|
||||||
|
|
||||||
if (!profile) {
|
if (!profile) {
|
||||||
@@ -22,7 +23,7 @@ export default async function EditUserPage({ params }: { params: { id: string }
|
|||||||
// Fetch email from auth.users using admin client
|
// Fetch email from auth.users using admin client
|
||||||
let email = undefined
|
let email = undefined
|
||||||
if (supabaseAdmin) {
|
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) {
|
if (user) {
|
||||||
email = user.email
|
email = user.email
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user