Skip to content

Commit

Permalink
Merge pull request #784 from BIDMCDigitalPsychiatry/issue-777
Browse files Browse the repository at this point in the history
Survey percentage changes - QA fix
  • Loading branch information
sarithapillai8 authored Oct 11, 2023
2 parents 9f76869 + ccf577e commit 6dc86b6
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/components/Researcher/ActivityList/PercentageSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useEffect, useState } from "react"
import { makeStyles, createStyles, Theme, Grid, TextField, Button, Box } from "@material-ui/core"
import { makeStyles, createStyles, Theme, Grid, TextField, Button, Box, Tooltip, Fab, Icon } from "@material-ui/core"
import { useTranslation } from "react-i18next"
import LAMP from "lamp-core"
import { useSnackbar } from "notistack"

const useStyles = makeStyles((theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -60,6 +61,8 @@ const useStyles = makeStyles((theme: Theme) =>
export default function PercentageSettings({ activityId, ...props }) {
const { t } = useTranslation()
const classes = useStyles()
const { enqueueSnackbar } = useSnackbar()

const [settings, setSettings] = useState({
limit: null,
unit: null,
Expand All @@ -79,6 +82,9 @@ export default function PercentageSettings({ activityId, ...props }) {
const updateSettings = async () => {
settings["startDate"] = new Date().getTime()
await LAMP.Type.setAttachment(activityId, "me", "lamp.dashboard.percentage_settings", settings)
enqueueSnackbar(`${t("Successfully updated survey percentage settings.")}`, {
variant: "success",
})
}

return (
Expand All @@ -92,6 +98,7 @@ export default function PercentageSettings({ activityId, ...props }) {
type="number"
value={settings.limit}
variant="filled"
InputProps={{ inputProps: { min: 1 } }}
onChange={(e) => {
setSettings({ ...settings, limit: parseInt(e.target.value) })
}}
Expand Down Expand Up @@ -119,15 +126,20 @@ export default function PercentageSettings({ activityId, ...props }) {
type="number"
value={settings.timeframe}
variant="filled"
InputProps={{ inputProps: { min: 1 } }}
onChange={(e) => {
setSettings({ ...settings, timeframe: parseInt(e.target.value) })
}}
/>
</Grid>
<Box marginLeft={1} paddingBottom={4}>
<Button onClick={updateSettings} className={classes.btnBlue}>
Save
</Button>
<Tooltip title={`${t("Save this activity.")}`}>
<Fab className={classes.btnBlue} aria-label="Save" variant="extended" onClick={updateSettings}>
{`${t("Save")}`}
<span style={{ width: 8 }} />
<Icon>save</Icon>
</Fab>
</Tooltip>
</Box>
</Grid>
)
Expand Down

0 comments on commit 6dc86b6

Please sign in to comment.