-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rss): suggest saving before changing tab
- Loading branch information
Showing
4 changed files
with
155 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ents/GuildDashboard/SpecialCategoryComponents/RssFeeds/UnsavedFeedsConfirmationDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from "@mui/material"; | ||
|
||
import { useGuildConfigEditionContext } from "../../../../repository/context/GuildConfigEditionContext"; | ||
import { usePutGuildRssFeedMutation } from "../../../../repository/redux/api/api"; | ||
|
||
interface UnsavedFeedsConfirmationDialogProps { | ||
open: boolean; | ||
onCancel: () => void; | ||
onConfirm: () => void; | ||
} | ||
export default function UnsavedFeedsConfirmationDialog({ open, onCancel, onConfirm }: UnsavedFeedsConfirmationDialogProps) { | ||
const { guildId, state, setRssFeedsValue } = useGuildConfigEditionContext(); | ||
const [editFeedMutation, { isLoading }] = usePutGuildRssFeedMutation(); | ||
|
||
async function saveFeeds() { | ||
await Promise.all(state.editedRssFeeds?.map( | ||
(feed) => editFeedMutation({ guildId, feed }) | ||
) ?? []); | ||
setRssFeedsValue(undefined); | ||
onConfirm(); | ||
} | ||
|
||
return ( | ||
<Dialog maxWidth="xs" open={open} onClose={onCancel}> | ||
<DialogTitle>You have unsaved changes!</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText> | ||
You have unsaved changes in the RSS feeds configuration. Do you want to save them before leaving? | ||
</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button autoFocus color="gray" onClick={onCancel} disabled={isLoading}> | ||
Cancel | ||
</Button> | ||
<Button color="primary" onClick={saveFeeds} disabled={isLoading}>Save</Button> | ||
<Button color="error" onClick={onConfirm} disabled={isLoading}>Close without saving</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters