diff --git a/src/components/DatabaseModal.tsx b/src/components/DatabaseModal.tsx
index a2dba60..513e641 100644
--- a/src/components/DatabaseModal.tsx
+++ b/src/components/DatabaseModal.tsx
@@ -1,4 +1,4 @@
-import { Button, Card, Flex, Group, Modal, Text } from "@mantine/core";
+import { Button, Card, Flex, Group, Modal, Stack, Text } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { notifications } from "@mantine/notifications";
import { IconDatabaseExport, IconDatabaseImport } from "@tabler/icons-react";
@@ -6,7 +6,8 @@ import { useLiveQuery } from "dexie-react-hooks";
import download from "downloadjs";
import { cloneElement, ReactElement } from "react";
import { db } from "../db";
-import { DeleteDataModal } from "./DeleteDataModal";
+import { DeleteAllDataModal } from "./DeleteAllDataModal";
+import { DeleteChatsModal } from "./DeleteChatsModal";
export function DatabaseModal({ children }: { children: ReactElement }) {
const [opened, { open, close }] = useDisclosure(false);
@@ -31,108 +32,113 @@ export function DatabaseModal({ children }: { children: ReactElement }) {
withinPortal
keepMounted
>
-
-
-
- {chatsCount}
-
-
- Chats
-
-
-
-
- {messagesCount}
-
-
- Messages
-
-
-
-
- {promptsCount}
-
-
- Prompts
-
-
-
-
- }
- onClick={async () => {
- const blob = await db.export();
- download(
- blob,
- `chatpad-export-${new Date().toLocaleString()}.json`,
- "application/json"
- );
- notifications.show({
- title: "Exporting Data",
- message: "Your data is being exported.",
- });
- }}
- >
- Export Data
-
- {
- const file = e.currentTarget.files?.[0];
- if (!file) return;
- db.import(file, {
- acceptNameDiff: true,
- overwriteValues: true,
- acceptMissingTables: true,
- clearTablesBeforeImport: true,
- })
- .then(() => {
- notifications.show({
- title: "Importing data",
- message: "Your data is being imported.",
- });
- })
- .catch((error) => {
- notifications.show({
- title: "Error",
- color: "red",
- message: "The file you selected is invalid",
- });
+
+
+
+
+ {chatsCount}
+
+
+ Chats
+
+
+
+
+ {messagesCount}
+
+
+ Messages
+
+
+
+
+ {promptsCount}
+
+
+ Prompts
+
+
+
+
+ }
+ onClick={async () => {
+ const blob = await db.export();
+ download(
+ blob,
+ `chatpad-export-${new Date().toLocaleString()}.json`,
+ "application/json"
+ );
+ notifications.show({
+ title: "Exporting Data",
+ message: "Your data is being exported.",
});
- }}
- accept="application/json"
- hidden
- />
- }
- >
- Import Data
-
-
-
+ }}
+ >
+ Export Data
+
+ {
+ const file = e.currentTarget.files?.[0];
+ if (!file) return;
+ db.import(file, {
+ acceptNameDiff: true,
+ overwriteValues: true,
+ acceptMissingTables: true,
+ clearTablesBeforeImport: true,
+ })
+ .then(() => {
+ notifications.show({
+ title: "Importing data",
+ message: "Your data is being imported.",
+ });
+ })
+ .catch((error) => {
+ notifications.show({
+ title: "Error",
+ color: "red",
+ message: "The file you selected is invalid",
+ });
+ });
+ }}
+ accept="application/json"
+ hidden
+ />
+ }
+ >
+ Import Data
+
+
+
+
+
+
+
>
);
diff --git a/src/components/DeleteDataModal.tsx b/src/components/DeleteAllDataModal.tsx
similarity index 87%
rename from src/components/DeleteDataModal.tsx
rename to src/components/DeleteAllDataModal.tsx
index bb44cb5..9b4cde6 100644
--- a/src/components/DeleteDataModal.tsx
+++ b/src/components/DeleteAllDataModal.tsx
@@ -3,15 +3,23 @@ import { useDisclosure } from "@mantine/hooks";
import { IconTrash } from "@tabler/icons-react";
import { db } from "../db";
-export function DeleteDataModal({ onOpen }: { onOpen: () => void }) {
+export function DeleteAllDataModal({ onOpen }: { onOpen: () => void }) {
const [opened, { open, close }] = useDisclosure(false, { onOpen });
return (
<>
+ }
+ >
+ Delete All Data
+
@@ -29,14 +37,6 @@ export function DeleteDataModal({ onOpen }: { onOpen: () => void }) {
- }
- >
- Delete Data
-
>
);
}
diff --git a/src/components/DeleteChatsModal.tsx b/src/components/DeleteChatsModal.tsx
new file mode 100644
index 0000000..e6d453a
--- /dev/null
+++ b/src/components/DeleteChatsModal.tsx
@@ -0,0 +1,43 @@
+import { Button, Modal, Stack, Text } from "@mantine/core";
+import { useDisclosure } from "@mantine/hooks";
+import { IconTrash } from "@tabler/icons-react";
+import { db } from "../db";
+
+export function DeleteChatsModal({ onOpen }: { onOpen: () => void }) {
+ const [opened, { open, close }] = useDisclosure(false, { onOpen });
+
+ return (
+ <>
+ }
+ >
+ Delete Chats
+
+
+
+ Are you sure you want to delete your chats?
+
+
+
+ >
+ );
+}