aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorDhravya Shah <[email protected]>2024-08-03 12:08:31 -0700
committerDhravya Shah <[email protected]>2024-08-03 12:08:31 -0700
commitd8123449fd901abb9515d505eb83fc0ce53f86aa (patch)
tree47786aa6a16b0d057bd28dfcba1c87dd9182c436 /apps
parentfix: Small UI issue (diff)
downloadsupermemory-d8123449fd901abb9515d505eb83fc0ce53f86aa.tar.xz
supermemory-d8123449fd901abb9515d505eb83fc0ce53f86aa.zip
export memories option
Diffstat (limited to 'apps')
-rw-r--r--apps/web/app/(dash)/(memories)/content.tsx42
1 files changed, 35 insertions, 7 deletions
diff --git a/apps/web/app/(dash)/(memories)/content.tsx b/apps/web/app/(dash)/(memories)/content.tsx
index 4514d851..47ba5e13 100644
--- a/apps/web/app/(dash)/(memories)/content.tsx
+++ b/apps/web/app/(dash)/(memories)/content.tsx
@@ -60,6 +60,26 @@ export function MemoriesPage({
const [filter, setFilter] = useState(initialFilter);
+ const handleExport = () => {
+ const dataToExport = sortedItems.map((item) => ({
+ type: item.item,
+ date: new Date(item.date).toISOString(),
+ data: item.data,
+ }));
+
+ const json = JSON.stringify(dataToExport, null, 2);
+ const blob = new Blob([json], { type: "application/json" });
+ const url = URL.createObjectURL(blob);
+
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = "memories_and_spaces.json";
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+ };
+
// Sort Both memories and spaces by their savedAt and createdAt dates respectfully.
// The output should be just one single list of items
// And it will look something like { item: "memory" | "space", date: Date, data: Content | StoredSpace }
@@ -172,13 +192,21 @@ export function MemoriesPage({
</div>
)}
- <Filters
- setFilter={setFilter}
- filter={filter}
- filterMethods={
- currentSpace ? SpaceFilterMethods : MemoriesFilterMethods
- }
- />
+ <div className="flex justify-between w-full">
+ <Filters
+ setFilter={setFilter}
+ filter={filter}
+ filterMethods={
+ currentSpace ? SpaceFilterMethods : MemoriesFilterMethods
+ }
+ />
+ <button
+ onClick={handleExport}
+ className={`transition px-6 py-2 rounded-xl hover:text-[#369DFD]" text-[#B3BCC5] bg-secondary hover:bg-secondary hover:text-[#76a3cc]`}
+ >
+ JSON Export
+ </button>
+ </div>
<Masonry
className="mt-6 relative"