diff --git a/src/components/Guild/GuildReminders.tsx b/src/components/Guild/GuildReminders.tsx
index 7d3aaa4..ba0e9b6 100644
--- a/src/components/Guild/GuildReminders.tsx
+++ b/src/components/Guild/GuildReminders.tsx
@@ -26,7 +26,7 @@ export const GuildReminders = () => {
Create Reminder
-
+
diff --git a/src/components/Guild/index.tsx b/src/components/Guild/index.tsx
index e7aa5ea..d775884 100644
--- a/src/components/Guild/index.tsx
+++ b/src/components/Guild/index.tsx
@@ -3,6 +3,8 @@ import { fetchGuildInfo } from "../../api";
import { useParams } from "wouter";
import { GuildReminders } from "./GuildReminders";
import { GuildError } from "./GuildError";
+import { createPortal } from "preact/compat";
+import { Import } from "../Import";
export const Guild = () => {
const { guild } = useParams();
@@ -13,6 +15,13 @@ export const Guild = () => {
} else if (guildInfo.error) {
return
;
} else {
- return
;
+ const importModal = createPortal(
, document.getElementById("bottom-sidebar"));
+
+ return (
+ <>
+ {importModal}
+
+ >
+ );
}
};
diff --git a/src/components/Import/index.tsx b/src/components/Import/index.tsx
index ac5ed23..c113688 100644
--- a/src/components/Import/index.tsx
+++ b/src/components/Import/index.tsx
@@ -1,5 +1,8 @@
import { Modal } from "../Modal";
-import { useState } from "preact/hooks";
+import { useRef, useState } from "preact/hooks";
+import { useParams } from "wouter";
+import axios from "axios";
+import { useFlash } from "../App/FlashContext";
export const Import = () => {
const [modalOpen, setModalOpen] = useState(false);
@@ -24,6 +27,14 @@ export const Import = () => {
};
const ImportModal = ({ setModalOpen }) => {
+ const { guild } = useParams();
+
+ const aRef = useRef
();
+ const inputRef = useRef();
+ const flash = useFlash();
+
+ const [isImporting, setIsImporting] = useState(false);
+
return (
{
-
-
-
+
+
{
+ new Promise((resolve) => {
+ let fileReader = new FileReader();
+ fileReader.onload = (e) => resolve(fileReader.result);
+ fileReader.readAsDataURL(inputRef.current.files[0]);
+ }).then((dataUrl: string) => {
+ setIsImporting(true);
+
+ axios
+ .put(`/dashboard/api/guild/${guild}/export/reminders`, {
+ body: JSON.stringify({ body: dataUrl.split(",")[1] }),
+ })
+ .then(({ data }) => {
+ setIsImporting(false);
+
+ if (data.error) {
+ flash({ message: data.error, type: "error" });
+ } else {
+ flash({ message: data.message, type: "success" });
+ }
+ })
+ .then(() => {
+ delete inputRef.current.files[0];
+ });
+ });
+ }}
+ />
>
);
diff --git a/src/components/Sidebar/index.tsx b/src/components/Sidebar/index.tsx
index a77350c..906a292 100644
--- a/src/components/Sidebar/index.tsx
+++ b/src/components/Sidebar/index.tsx
@@ -6,7 +6,6 @@ import { Wave } from "./Wave";
import { GuildEntry } from "./GuildEntry";
import { fetchUserGuilds, GuildInfo } from "../../api";
import { TimezonePicker } from "../TimezonePicker";
-import { Import } from "../Import";
type ContentProps = {
guilds: GuildInfo[];
@@ -18,9 +17,9 @@ const SidebarContent = ({ guilds }: ContentProps) => {
return (
<>
-
+
-
+