Update interface for template import/export
This commit is contained in:
parent
0a9c390f32
commit
0f9d3eda9a
@ -33,6 +33,7 @@ const ImportModal = ({ setModalOpen }) => {
|
||||
|
||||
const aRef = useRef<HTMLAnchorElement>();
|
||||
const inputRef = useRef<HTMLInputElement>();
|
||||
const selectRef = useRef<HTMLSelectElement>();
|
||||
const flash = useFlash();
|
||||
|
||||
const [isImporting, setIsImporting] = useState(false);
|
||||
@ -55,17 +56,16 @@ const ImportModal = ({ setModalOpen }) => {
|
||||
>
|
||||
<>
|
||||
<div class="control">
|
||||
<div class="field">
|
||||
<label>
|
||||
<input
|
||||
type="radio"
|
||||
class="default-width"
|
||||
<div class="field select">
|
||||
<select
|
||||
name="exportSelect"
|
||||
style={{ width: "100%" }}
|
||||
value="reminders"
|
||||
checked
|
||||
/>
|
||||
Reminders
|
||||
</label>
|
||||
ref={selectRef}
|
||||
>
|
||||
<option value="reminders">Reminders</option>
|
||||
<option value="reminder_templates">Reminder templates</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
@ -90,7 +90,9 @@ const ImportModal = ({ setModalOpen }) => {
|
||||
id="export-data"
|
||||
onClick={() =>
|
||||
axios
|
||||
.get(`/dashboard/api/guild/${guild}/export/reminders`)
|
||||
.get(
|
||||
`/dashboard/api/guild/${guild}/export/${selectRef.current.value}`,
|
||||
)
|
||||
.then(({ data, status }) => {
|
||||
if (status === 200) {
|
||||
aRef.current.href = `data:text/plain;charset=utf-8,${encodeURIComponent(
|
||||
@ -124,11 +126,15 @@ const ImportModal = ({ setModalOpen }) => {
|
||||
setIsImporting(true);
|
||||
|
||||
axios
|
||||
.put(`/dashboard/api/guild/${guild}/export/reminders`, {
|
||||
.put(
|
||||
`/dashboard/api/guild/${guild}/export/${selectRef.current.value}`,
|
||||
{
|
||||
body: dataUrl.split(",")[1],
|
||||
})
|
||||
},
|
||||
)
|
||||
.then(({ data }) => {
|
||||
setIsImporting(false);
|
||||
setModalOpen(false);
|
||||
|
||||
if (data.error) {
|
||||
flash({ message: data.error, type: "error" });
|
||||
@ -137,6 +143,9 @@ const ImportModal = ({ setModalOpen }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["GUILD_REMINDERS", guild],
|
||||
});
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["GUILD_TEMPLATES", guild],
|
||||
});
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user