Skip to content

Commit

Permalink
Upgrade and support next 15
Browse files Browse the repository at this point in the history
  • Loading branch information
cregourd committed Nov 4, 2024
1 parent 6059dc1 commit ba36b45
Show file tree
Hide file tree
Showing 5 changed files with 399 additions and 97 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-beers-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin": patch
---

Support Next 15
14 changes: 7 additions & 7 deletions apps/example/app/[locale]/admin/[[...nextadmin]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Dashboard from "@/components/Dashboard";
import { options } from "@/options";
import { prisma } from "@/prisma";
import schema from "@/prisma/json-schema/json-schema.json";
import { NextAdmin, PageProps } from "@premieroctet/next-admin";
import { NextAdmin, PromisePageProps } from "@premieroctet/next-admin";
import { getNextAdminProps } from "@premieroctet/next-admin/appRouter";
import { Metadata, Viewport } from "next";
import { getMessages } from "next-intl/server";
Expand All @@ -16,11 +16,11 @@ export const metadata: Metadata = {
icons: "/assets/logo.svg",
};

export default async function AdminPage({
params,
searchParams,
}: Readonly<PageProps>) {
const props = await getNextAdminProps({
export default async function AdminPage(props: PromisePageProps) {
const params = await props.params;
const searchParams = await props.searchParams;

const nextAdminProps = await getNextAdminProps({
params: params.nextadmin,
searchParams,
basePath: "/admin",
Expand All @@ -44,7 +44,7 @@ export default async function AdminPage({

return (
<NextAdmin
{...props}
{...nextAdminProps}
dashboard={<Dashboard />}
user={{
data: {
Expand Down
16 changes: 7 additions & 9 deletions apps/example/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { notFound } from "next/navigation";
import { PropsWithChildren } from "react";
import { PropsWithChildren, use } from "react";
import "../../styles.css";

type Props = {
params: {
locale: "en" | "fr";
};
};

type ParamsProps = Promise<{
locale: "en" | "fr";
}>;
const locales = ["en", "fr"];

export default function Layout({
children,
params: { locale },
}: PropsWithChildren<Props>) {
params,
}: PropsWithChildren<{ params: ParamsProps }>) {
const locale = use(params)?.locale;
if (!locales.includes(locale)) {
notFound();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@premieroctet/next-admin": "6.1.6",
"@prisma/client": "5.14.0",
"@tremor/react": "^3.2.2",
"next": "^14.0.3",
"next": "^15.0.2",
"next-intl": "^3.3.2",
"next-superjson": "^1.0.1",
"next-superjson-plugin": "^0.6.3",
Expand Down
Loading

0 comments on commit ba36b45

Please sign in to comment.