Working on user preferences for dashboards
This commit is contained in:
@ -1,21 +1,28 @@
|
||||
import { LoadTemplate } from "../LoadTemplate";
|
||||
import { useReminder } from "../ReminderContext";
|
||||
import { useMutation, useQueryClient } from "react-query";
|
||||
import { postGuildReminder, postGuildTemplate, postUserReminder } from "../../../api";
|
||||
import { useMutation, useQuery, useQueryClient } from "react-query";
|
||||
import {
|
||||
fetchUserInfo,
|
||||
postGuildReminder,
|
||||
postGuildTemplate,
|
||||
postUserReminder,
|
||||
} from "../../../api";
|
||||
import { useState } from "preact/hooks";
|
||||
import { ICON_FLASH_TIME } from "../../../consts";
|
||||
import { useFlash } from "../../App/FlashContext";
|
||||
import { useGuild } from "../../App/useGuild";
|
||||
import { defaultReminder } from "../CreateReminder";
|
||||
|
||||
export const CreateButtonRow = () => {
|
||||
const guild = useGuild();
|
||||
const [reminder] = useReminder();
|
||||
const [reminder, setReminder] = useReminder();
|
||||
|
||||
const [recentlyCreated, setRecentlyCreated] = useState(false);
|
||||
const [templateRecentlyCreated, setTemplateRecentlyCreated] = useState(false);
|
||||
|
||||
const flash = useFlash();
|
||||
const queryClient = useQueryClient();
|
||||
const { data: userInfo } = useQuery({ ...fetchUserInfo() });
|
||||
const mutation = useMutation({
|
||||
...(guild ? postGuildReminder(guild) : postUserReminder()),
|
||||
onError: (error) => {
|
||||
@ -44,6 +51,9 @@ export const CreateButtonRow = () => {
|
||||
queryKey: ["USER_REMINDERS"],
|
||||
});
|
||||
}
|
||||
if (userInfo.reset_inputs_on_create) {
|
||||
setReminder(() => defaultReminder());
|
||||
}
|
||||
setRecentlyCreated(true);
|
||||
setTimeout(() => {
|
||||
setRecentlyCreated(false);
|
||||
|
@ -11,7 +11,7 @@ import "./styles.scss";
|
||||
import { useGuild } from "../App/useGuild";
|
||||
import { DEFAULT_COLOR } from "./Embed";
|
||||
|
||||
function defaultReminder(): Reminder {
|
||||
export function defaultReminder(): Reminder {
|
||||
return {
|
||||
attachment: null,
|
||||
attachment_name: null,
|
||||
|
Reference in New Issue
Block a user