Skip to content

Commit

Permalink
error fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
bartosz-skejcik committed Dec 22, 2023
1 parent 314506b commit 8398ac7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 0 additions & 7 deletions app/api/edgestore/[...edgestore]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { initEdgeStore } from "@edgestore/server";
import { createEdgeStoreNextHandler } from "@edgestore/server/adapters/next/app";
import { EdgeStoreProvider } from "@edgestore/server/providers/edgestore";

const es = initEdgeStore.create();

Expand All @@ -13,14 +12,8 @@ const edgeStoreRouter = es.router({

const handler = createEdgeStoreNextHandler({
router: edgeStoreRouter,
provider: EdgeStoreProvider({
accessKey: process.env.EDGE_STORE_ACCESS_KEY || "",
secretKey: process.env.EDGE_STORE_SECRET_KEY || "",
}), // this is the default provider and can be omitted
});

export const dynamic = "force-dynamic";

export { handler as GET, handler as POST };

/**
Expand Down
7 changes: 6 additions & 1 deletion app/panel/settings/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { toast } from "react-toastify";
import { useEdgeStore } from "@/lib/edgestore";
import clsx from "clsx";
import { Loader2 } from "lucide-react";
import dynamic from "next/dynamic";

async function handleUserChange(
e: FormData,
Expand Down Expand Up @@ -79,7 +80,7 @@ async function handleUserChange(

type Props = {};

function Account({}: Props) {
function NoSSRAccount({}: Props) {
const { edgestore } = useEdgeStore();
const { data: session } = useSession();
const userAvatar = session?.user?.avatar!;
Expand Down Expand Up @@ -346,4 +347,8 @@ function Account({}: Props) {
);
}

const Account = dynamic(() => Promise.resolve(NoSSRAccount), {
ssr: false,
});

export default Account;
5 changes: 3 additions & 2 deletions lib/edgestore.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use client";

// import { type EdgeStoreRouter } from "@/app/api/edgestore/[...edgestore]/route";
import { type EdgeStoreRouter } from "@/app/api/edgestore/[...edgestore]/route";
import { createEdgeStoreProvider } from "@edgestore/react";

const { EdgeStoreProvider, useEdgeStore } = createEdgeStoreProvider<any>();
const { EdgeStoreProvider, useEdgeStore } =
createEdgeStoreProvider<EdgeStoreRouter>();

export { EdgeStoreProvider, useEdgeStore };

0 comments on commit 8398ac7

Please sign in to comment.