diff --git a/reminder-dashboard/src/components/Import/index.tsx b/reminder-dashboard/src/components/Import/index.tsx index c113688..fe4c53a 100644 --- a/reminder-dashboard/src/components/Import/index.tsx +++ b/reminder-dashboard/src/components/Import/index.tsx @@ -3,6 +3,8 @@ import { useRef, useState } from "preact/hooks"; import { useParams } from "wouter"; import axios from "axios"; import { useFlash } from "../App/FlashContext"; +import { useGuild } from "../App/useGuild"; +import { useQueryClient } from "react-query"; export const Import = () => { const [modalOpen, setModalOpen] = useState(false); @@ -27,7 +29,7 @@ export const Import = () => { }; const ImportModal = ({ setModalOpen }) => { - const { guild } = useParams(); + const guild = useGuild(); const aRef = useRef(); const inputRef = useRef(); @@ -35,6 +37,8 @@ const ImportModal = ({ setModalOpen }) => { const [isImporting, setIsImporting] = useState(false); + const queryClient = useQueryClient(); + return ( { axios .put(`/dashboard/api/guild/${guild}/export/reminders`, { - body: JSON.stringify({ body: dataUrl.split(",")[1] }), + body: dataUrl.split(",")[1], }) .then(({ data }) => { setIsImporting(false); @@ -130,6 +134,9 @@ const ImportModal = ({ setModalOpen }) => { flash({ message: data.error, type: "error" }); } else { flash({ message: data.message, type: "success" }); + queryClient.invalidateQueries({ + queryKey: ["GUILD_REMINDERS", guild], + }); } }) .then(() => {