Skip to content

Commit

Permalink
Update old storage example
Browse files Browse the repository at this point in the history
  • Loading branch information
nezaj committed Nov 26, 2024
1 parent 7590603 commit 90697e8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions client/sandbox/react-nextjs/pages/play/storage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Head from "next/head";
import { useRouter } from "next/router";
import { init } from "@instantdb/react";

import Login from "../../components/Login";
import config from "../../config";

const DEFAULT_APP_ID = "524bc106-1f0d-44a0-b222-923505264c47";
Expand All @@ -13,6 +14,15 @@ const App = ({ appId }: { appId: string }) => {
appId: appId,
});

const { isLoading, error, user } = db.useAuth();
if (isLoading) { return <div>Loading...</div>; }
if (error) { return <div>Uh oh! {error.message}</div>; }
if (!user) { return <Login auth={db.auth} />; }

return <Main db={db} />;
}

function Main({ db }: { db: any }) {
const [files, setFiles] = React.useState<File[]>([]);
const [imageUrl, setImageUrl] = React.useState<string | null>(null);
const [imageStatus, setImageStatus] = React.useState<
Expand Down Expand Up @@ -53,8 +63,6 @@ const App = ({ appId }: { appId: string }) => {
setImageUrl(url);
setImageStatus("pending");
}
// Reset input
setFiles([]);
} catch (error) {
console.error("Error uploading file:", error);
}
Expand Down

0 comments on commit 90697e8

Please sign in to comment.