Allow removing attachments

Show HTTP errors
This commit is contained in:
jude 2024-03-27 17:19:19 +00:00
parent 334b1bc084
commit 18cac0345b
4 changed files with 43 additions and 2 deletions

View File

@ -26,7 +26,6 @@
<link rel="stylesheet" href="/static/css/fa.css">
<link rel="stylesheet" href="/static/css/font.css">
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/dtsel.css">
</head>
<body>
<div id="app"></div>

View File

@ -39,12 +39,42 @@ export const Attachment = () => {
}}
></input>
<span class="file-cta">
<span class="file-label">{attachment_name || "Add Attachment"}</span>
<span
class="file-label"
style={{
maxWidth: "200px",
}}
>
{attachment_name || "Add Attachment"}
</span>
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
</span>
</label>
{attachment_name && (
<>
<button
onClick={() => {
setReminder((reminder) => ({
...reminder,
attachment: null,
attachment_name: null,
}));
}}
style={{
border: "none",
background: "none",
cursor: "pointer",
}}
>
<span class="sr-only">Remove attachment</span>
<span class="icon">
<i class="fas fa-trash"></i>
</span>
</button>
</>
)}
</div>
);
};

View File

@ -18,6 +18,12 @@ export const CreateButtonRow = () => {
const queryClient = useQueryClient();
const mutation = useMutation({
...(guild ? postGuildReminder(guild) : postUserReminder()),
onError: (error) => {
flash({
message: `An error occurred: ${error}`,
type: "error",
});
},
onSuccess: (data) => {
if (data.error) {
flash({

View File

@ -19,6 +19,12 @@ export const EditButtonRow = () => {
const flash = useFlash();
const mutation = useMutation({
...(guild ? patchGuildReminder(guild) : patchUserReminder()),
onError: (error) => {
flash({
message: `An error occurred: ${error}`,
type: "error",
});
},
onSuccess: (response) => {
if (guild) {
queryClient.invalidateQueries({