From 8e49fed48b93530c9f896c5a2bdcb6db468e7867 Mon Sep 17 00:00:00 2001 From: Ishaan Dey Date: Wed, 22 May 2024 20:06:16 -0700 Subject: [PATCH] fix new user error + add wrangler.toml examples --- backend/ai/wrangler.toml.example | 10 ++++++++++ backend/database/drizzle/meta/_journal.json | 7 +++++++ backend/database/src/schema.ts | 1 + backend/database/wrangler.toml.example | 12 ++++++++++++ backend/storage/wrangler.toml.example | 13 +++++++++++++ frontend/components/dashboard/index.tsx | 11 +++++++++-- 6 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 backend/ai/wrangler.toml.example create mode 100644 backend/database/wrangler.toml.example create mode 100644 backend/storage/wrangler.toml.example diff --git a/backend/ai/wrangler.toml.example b/backend/ai/wrangler.toml.example new file mode 100644 index 0000000..316d498 --- /dev/null +++ b/backend/ai/wrangler.toml.example @@ -0,0 +1,10 @@ +name = "ai" +main = "src/index.ts" +compatibility_date = "2024-05-12" +compatibility_flags = ["nodejs_compat"] + +[ai] +binding = "AI" + +[vars] +KEY = "" diff --git a/backend/database/drizzle/meta/_journal.json b/backend/database/drizzle/meta/_journal.json index 4a81b4d..352aca6 100644 --- a/backend/database/drizzle/meta/_journal.json +++ b/backend/database/drizzle/meta/_journal.json @@ -43,6 +43,13 @@ "when": 1714950365718, "tag": "0005_last_the_twelve", "breakpoints": true + }, + { + "idx": 6, + "version": "5", + "when": 1716432225404, + "tag": "0006_lively_mattie_franklin", + "breakpoints": true } ] } \ No newline at end of file diff --git a/backend/database/src/schema.ts b/backend/database/src/schema.ts index ac52c82..4403b96 100644 --- a/backend/database/src/schema.ts +++ b/backend/database/src/schema.ts @@ -28,6 +28,7 @@ export const sandbox = sqliteTable("sandbox", { name: text("name").notNull(), type: text("type", { enum: ["react", "node"] }).notNull(), visibility: text("visibility", { enum: ["public", "private"] }), + createdAt: integer("createdAt", { mode: "timestamp_ms" }), userId: text("user_id") .notNull() .references(() => user.id), diff --git a/backend/database/wrangler.toml.example b/backend/database/wrangler.toml.example new file mode 100644 index 0000000..27cb2c6 --- /dev/null +++ b/backend/database/wrangler.toml.example @@ -0,0 +1,12 @@ +#:schema node_modules/wrangler/config-schema.json +name = "database" +main = "src/index.ts" +compatibility_date = "2024-04-05" +compatibility_flags = ["nodejs_compat"] + +services = [{ binding = "STORAGE", service = "storage" }] + +[[d1_databases]] +binding = "DB" +database_name = "" +database_id = "" diff --git a/backend/storage/wrangler.toml.example b/backend/storage/wrangler.toml.example new file mode 100644 index 0000000..33ed573 --- /dev/null +++ b/backend/storage/wrangler.toml.example @@ -0,0 +1,13 @@ +#:schema node_modules/wrangler/config-schema.json +name = "storage" +main = "src/index.ts" +compatibility_date = "2024-04-05" +compatibility_flags = ["nodejs_compat"] + +account_id = "" +workers_dev = true + +[[r2_buckets]] +binding = 'R2' +bucket_name = '' +preview_bucket_name = '' diff --git a/frontend/components/dashboard/index.tsx b/frontend/components/dashboard/index.tsx index 6d06a60..569ff03 100644 --- a/frontend/components/dashboard/index.tsx +++ b/frontend/components/dashboard/index.tsx @@ -10,13 +10,13 @@ import { Settings, Users, } from "lucide-react"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { Sandbox } from "@/lib/types"; import DashboardProjects from "./projects"; import DashboardSharedWithMe from "./shared"; import NewProjectModal from "./newProject"; import Link from "next/link"; -import { useSearchParams } from "next/navigation"; +import { useRouter, useSearchParams } from "next/navigation"; import AboutModal from "./about"; import { toast } from "sonner"; @@ -47,6 +47,13 @@ export default function Dashboard({ const searchParams = useSearchParams(); const q = searchParams.get("q"); + const router = useRouter(); + + useEffect(() => { + if (!sandboxes) { + router.refresh(); + } + }, [sandboxes]); return ( <>