aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDhravya <[email protected]>2024-06-30 18:42:53 -0500
committerDhravya <[email protected]>2024-06-30 18:42:53 -0500
commit79e26730800ed5e7d6fe59f3a3c002e0dfe46353 (patch)
tree4b7c56b8a648c4024c5b7c4565cb544e0e792718 /apps
parentensure useriD while saving (diff)
downloadsupermemory-79e26730800ed5e7d6fe59f3a3c002e0dfe46353.tar.xz
supermemory-79e26730800ed5e7d6fe59f3a3c002e0dfe46353.zip
makeshift notes page
Diffstat (limited to 'apps')
-rw-r--r--apps/web/app/(dash)/memories/page.tsx2
-rw-r--r--apps/web/app/(dash)/note/[noteid]/page.tsx24
-rw-r--r--apps/web/app/actions/doers.ts2
-rw-r--r--apps/web/app/actions/fetchers.ts23
-rw-r--r--apps/web/app/api/store/route.ts3
-rw-r--r--apps/web/migrations/cmd.sql1
-rw-r--r--apps/web/package.json5
-rw-r--r--apps/web/wrangler.toml4
8 files changed, 57 insertions, 7 deletions
diff --git a/apps/web/app/(dash)/memories/page.tsx b/apps/web/app/(dash)/memories/page.tsx
index 2e338c6a..fa074a0b 100644
--- a/apps/web/app/(dash)/memories/page.tsx
+++ b/apps/web/app/(dash)/memories/page.tsx
@@ -174,7 +174,7 @@ function LinkComponent({
// TODO: DISPLAY THE ITEM BASED ON `type` being note or page
return (
<Link
- href={url}
+ href={url.replace("https://beta.supermemory.ai", "")}
className={`bg-secondary border-2 border-border rounded-xl ${type === "tweet" ? "" : "p-4"} hover:scale-105 transition duration-200`}
>
{type === "page" ? (
diff --git a/apps/web/app/(dash)/note/[noteid]/page.tsx b/apps/web/app/(dash)/note/[noteid]/page.tsx
new file mode 100644
index 00000000..76fed275
--- /dev/null
+++ b/apps/web/app/(dash)/note/[noteid]/page.tsx
@@ -0,0 +1,24 @@
+import { getNoteFromId } from "@/app/actions/fetchers";
+import { NotebookIcon } from "lucide-react";
+
+async function Page({ params }: { params: { noteid: string } }) {
+ const note = await getNoteFromId(params.noteid as string);
+
+ if (!note.success) {
+ return <div>Failed to load note</div>;
+ }
+
+ return (
+ <div className="max-w-3xl mt-16 md:mt-32 flex mx-auto w-full flex-col">
+ <div className="flex items-center gap-2 text-xs">
+ <NotebookIcon className="w-3 h-3" /> Note
+ </div>
+ <h1 className="text-white w-full font-medium text-2xl text-left mt-2">
+ {note.data?.title}
+ </h1>
+ <div className="w-full pb-20 mt-12">{note.data?.content}</div>
+ </div>
+ );
+}
+
+export default Page;
diff --git a/apps/web/app/actions/doers.ts b/apps/web/app/actions/doers.ts
index 2f29b457..84d43924 100644
--- a/apps/web/app/actions/doers.ts
+++ b/apps/web/app/actions/doers.ts
@@ -171,7 +171,7 @@ export const createMemory = async (input: {
pageContent = input.content;
noteId = new Date().getTime();
metadata = {
- baseUrl: `https://beta.supermemory.ai/?note=${noteId}`,
+ baseUrl: `https://beta.supermemory.ai/note/${noteId}`,
description: `Note created at ${new Date().toLocaleString()}`,
image: "https://supermemory.ai/logo.png",
title: `${pageContent.slice(0, 20)} ${pageContent.length > 20 ? "..." : ""}`,
diff --git a/apps/web/app/actions/fetchers.ts b/apps/web/app/actions/fetchers.ts
index 0035c217..b9f6dc2a 100644
--- a/apps/web/app/actions/fetchers.ts
+++ b/apps/web/app/actions/fetchers.ts
@@ -200,3 +200,26 @@ export const getSessionAuthToken = async (): ServerActionReturnType<string> => {
data: token,
};
};
+
+export const getNoteFromId = async (
+ noteId: string,
+): ServerActionReturnType<Content> => {
+ const data = await auth();
+
+ if (!data || !data.user || !data.user.id) {
+ redirect("/signin");
+ return { error: "Not authenticated", success: false };
+ }
+
+ const note = await db.query.storedContent.findFirst({
+ where: and(
+ eq(storedContent.noteId, parseInt(noteId)),
+ eq(users, data.user.id),
+ ),
+ });
+
+ return {
+ success: true,
+ data: note,
+ };
+};
diff --git a/apps/web/app/api/store/route.ts b/apps/web/app/api/store/route.ts
index 29d7eec3..a67787c4 100644
--- a/apps/web/app/api/store/route.ts
+++ b/apps/web/app/api/store/route.ts
@@ -59,6 +59,8 @@ const createMemoryFromAPI = async (input: {
"#supermemory-user-" +
input.userId;
+ const noteId = new Date().getTime();
+
// Insert into database
try {
const insertResponse = await db
@@ -73,6 +75,7 @@ const createMemoryFromAPI = async (input: {
savedAt: new Date(),
userId: input.userId,
type: input.data.type,
+ noteId,
})
.returning({ id: storedContent.id });
diff --git a/apps/web/migrations/cmd.sql b/apps/web/migrations/cmd.sql
deleted file mode 100644
index 72297069..00000000
--- a/apps/web/migrations/cmd.sql
+++ /dev/null
@@ -1 +0,0 @@
-CREATE UNIQUE INDEX `storedContent_baseUrl_unique` ON `storedContent` (`baseUrl`); \ No newline at end of file
diff --git a/apps/web/package.json b/apps/web/package.json
index ae174ca3..44522dcc 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -11,9 +11,10 @@
"cf-typegen": "wrangler types --env-interface CloudflareEnv env.d.ts",
"pages:build": "npx @cloudflare/next-on-pages",
"preview": "npm run pages:build && wrangler pages dev",
- "deploy": "npm run pages:build && wrangler pages deploy",
+ "deploy": "npm run pages:build && wrangler pages deploy --branch main",
"schema-update": "bunx drizzle-kit generate sqlite",
- "update-local-db": "bunx wrangler d1 execute dev-d1-anycontext --local"
+ "update-local-db": "bunx wrangler d1 execute dev-d1-anycontext --local",
+ "update-prod-db": "bunx wrangler d1 execute prod-d1-supermemory --remote"
},
"dependencies": {
"@million/lint": "^1.0.0-rc.11",
diff --git a/apps/web/wrangler.toml b/apps/web/wrangler.toml
index 2b05d1b0..594614c7 100644
--- a/apps/web/wrangler.toml
+++ b/apps/web/wrangler.toml
@@ -13,8 +13,8 @@ bucket_name = "dev-r2-anycontext"
[[d1_databases]]
binding = "DATABASE"
-database_name = "prod-d1-supermemory"
-database_id = "f527a727-c472-41d4-8eaf-3d7ba0f2f395"
+database_name = "dev-d1-anycontext"
+database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c"
[[env.production.d1_databases]]
binding = "DATABASE"