-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DataCleanup] Implement changes, completed for ReviewEntries (#2743)
- Loading branch information
1 parent
d69ed66
commit 26e9677
Showing
76 changed files
with
1,234 additions
and
456 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Button, Grid } from "@mui/material"; | ||
import { ReactElement, useEffect, useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
import { CancelConfirmDialog } from "components/Dialogs"; | ||
|
||
interface UndoButtonProps { | ||
buttonIdEnabled?: string; | ||
buttonIdCancel?: string; | ||
buttonIdConfirm?: string; | ||
textIdDialog: string; | ||
textIdDisabled: string; | ||
textIdEnabled: string; | ||
isUndoAllowed: () => Promise<boolean>; | ||
undo: () => Promise<void>; | ||
} | ||
|
||
export default function UndoButton(props: UndoButtonProps): ReactElement { | ||
const isUndoAllowed = props.isUndoAllowed; | ||
|
||
const [isUndoEnabled, setUndoEnabled] = useState(false); | ||
const [undoDialogOpen, setUndoDialogOpen] = useState(false); | ||
|
||
const { t } = useTranslation(); | ||
|
||
useEffect(() => { | ||
if (!undoDialogOpen) { | ||
isUndoAllowed().then(setUndoEnabled); | ||
} | ||
}, [isUndoAllowed, undoDialogOpen]); | ||
|
||
return ( | ||
<Grid container direction="column" justifyContent="center"> | ||
{isUndoEnabled ? ( | ||
<div> | ||
<Button | ||
variant="outlined" | ||
id={props.buttonIdEnabled} | ||
onClick={() => setUndoDialogOpen(true)} | ||
> | ||
{t(props.textIdEnabled)} | ||
</Button> | ||
<CancelConfirmDialog | ||
open={undoDialogOpen} | ||
textId={props.textIdDialog} | ||
handleCancel={() => setUndoDialogOpen(false)} | ||
handleConfirm={() => | ||
props.undo().then(() => setUndoDialogOpen(false)) | ||
} | ||
buttonIdCancel={props.buttonIdCancel} | ||
buttonIdConfirm={props.buttonIdConfirm} | ||
/> | ||
</div> | ||
) : ( | ||
<div> | ||
<Button disabled>{t(props.textIdDisabled)}</Button> | ||
</div> | ||
)} | ||
</Grid> | ||
); | ||
} |
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
Oops, something went wrong.