Skip to content

Commit

Permalink
Merge pull request #803 from BIDMCDigitalPsychiatry/issue-783
Browse files Browse the repository at this point in the history
Issue 783
  • Loading branch information
sarithapillai8 authored Jan 25, 2024
2 parents 72e4b49 + 6149ee6 commit 04f1336
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/components/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ export default function ConfirmationDialog({
confirmAction,
confirmationDialog,
confirmationMsg,
okText,
cancelText,
...props
}: {
confirmAction: Function
confirmationDialog: number
confirmationDialog?: number
confirmationMsg: string
okText?: string
cancelText?: string
} & DialogProps) {
const { t } = useTranslation()
const [isClicked, setIsClicked] = useState(false)
Expand All @@ -36,7 +40,7 @@ export default function ConfirmationDialog({
</DialogContent>
<DialogActions>
<Button onClick={() => confirmAction("No")} color="primary">
{`${t("No")}`}
{`${t(cancelText ?? "No")}`}
</Button>
<Button
onClick={() => {
Expand All @@ -48,7 +52,7 @@ export default function ConfirmationDialog({
autoFocus
disabled={!!isClicked}
>
{`${t("Yes")}`}
{`${t(okText ?? "Yes")}`}
</Button>
</DialogActions>
</Dialog>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default function Login({ setIdentity, lastDomain, onComplete, ...props })
onComplete()
})
.catch((err) => {
console.warn("error with auth request", err)
// console.warn("error with auth request", err)
enqueueSnackbar(`${t("Incorrect username, password, or server address.")}`, {
variant: "error",
})
Expand Down
19 changes: 18 additions & 1 deletion src/components/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import ResponsiveDialog from "./ResponsiveDialog"
import useInterval from "./useInterval"
import LAMP from "lamp-core"
import { useTranslation } from "react-i18next"

import ConfirmationDialog from "./ConfirmationDialog"
const useStyles = makeStyles((theme) => ({
conversationStyle: {
borderRadius: "10px",
Expand Down Expand Up @@ -157,6 +157,8 @@ export default function Messages({
const [currentMessage, setCurrentMessage] = useState<string>()
const [addMsg, setAddMsg] = useState(false)
const supportsSidebar = useMediaQuery(useTheme().breakpoints.up("md"))
const [confirmationDialog, setConfirmationDialog] = useState(true)

const { t } = useTranslation()

useInterval(
Expand Down Expand Up @@ -296,6 +298,13 @@ export default function Messages({
)
}

const confirmAction = (status: string) => {
if (status == "No") {
history.back()
}
setConfirmationDialog(false)
}

if (msgOpen) {
return (
<Container>
Expand All @@ -305,6 +314,14 @@ export default function Messages({
} else {
return (
<Box>
<ConfirmationDialog
open={confirmationDialog}
onClose={() => setConfirmationDialog(false)}
confirmAction={confirmAction}
okText={"Okay"}
cancelText={"Take me back"}
confirmationMsg={`${t("This chat is not monitored and should not be used for urgent matters.")}`}
/>
<AppBar position="static" className={classes.inlineHeader}>
<Toolbar className={classes.toolbardashboard}>
<IconButton onClick={() => history.back()} color="default" aria-label="Menu">
Expand Down

0 comments on commit 04f1336

Please sign in to comment.