Fix time inputs

This commit is contained in:
jude
2024-03-01 16:54:56 +00:00
parent 8c2296b9c8
commit 0e0ab053f3
3 changed files with 113 additions and 56 deletions

View File

@ -128,38 +128,20 @@ export const fetchGuildRoles = (guild: string) => ({
export const fetchGuildReminders = (guild: string) => ({
queryKey: ["GUILD_REMINDERS", guild],
queryFn: () =>
axios
.get(`/dashboard/api/guild/${guild}/reminders`)
.then((resp) => resp.data)
.then((value) =>
value.map((reminder) => ({
...reminder,
utc_time: DateTime.fromISO(reminder.utc_time, { zone: "UTC" }),
expires:
reminder.expires === null
? null
: DateTime.fromISO(reminder.expires, { zone: "UTC" }),
})),
) as Promise<Reminder[]>,
axios.get(`/dashboard/api/guild/${guild}/reminders`).then((resp) => resp.data) as Promise<
Reminder[]
>,
staleTime: OTHER_STALE_TIME,
});
export const patchGuildReminder = (guild: string) => ({
mutationFn: (reminder: Reminder) =>
axios.patch(`/dashboard/api/guild/${guild}/reminders`, {
...reminder,
utc_time: reminder.utc_time.toFormat("yyyy-LL-dd'T'HH:mm:ss"),
}),
axios.patch(`/dashboard/api/guild/${guild}/reminders`, reminder),
});
export const postGuildReminder = (guild: string) => ({
mutationFn: (reminder: Reminder) =>
axios
.post(`/dashboard/api/guild/${guild}/reminders`, {
...reminder,
utc_time: reminder.utc_time.toFormat("yyyy-LL-dd'T'HH:mm:ss"),
})
.then((resp) => resp.data),
axios.post(`/dashboard/api/guild/${guild}/reminders`, reminder).then((resp) => resp.data),
});
export const deleteGuildReminder = (guild: string) => ({
@ -182,12 +164,7 @@ export const fetchGuildTemplates = (guild: string) => ({
export const postGuildTemplate = (guild: string) => ({
mutationFn: (reminder: Reminder) =>
axios
.post(`/dashboard/api/guild/${guild}/templates`, {
...reminder,
utc_time: reminder.utc_time.toFormat("yyyy-LL-dd'T'HH:mm:ss"),
})
.then((resp) => resp.data),
axios.post(`/dashboard/api/guild/${guild}/templates`, reminder).then((resp) => resp.data),
});
export const deleteGuildTemplate = (guild: string) => ({