-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add commentDialog and link to SU page
- Loading branch information
1 parent
70bb09d
commit d1b4671
Showing
11 changed files
with
190 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Stack } from "@mui/material"; | ||
import { useParams } from "react-router-dom"; | ||
|
||
export const SurveyUnitPage = () => { | ||
const { id } = useParams(); | ||
return <Stack>UE {id}</Stack>; | ||
}; |
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,121 @@ | ||
import Button from "@mui/material/Button"; | ||
import Dialog from "@mui/material/Dialog"; | ||
import DialogActions from "@mui/material/DialogActions"; | ||
import DialogContent from "@mui/material/DialogContent"; | ||
import DialogTitle from "@mui/material/DialogTitle"; | ||
import TextField from "@mui/material/TextField"; | ||
import { theme } from "../theme"; | ||
import { ChangeEvent, useState } from "react"; | ||
import { Box, Divider, InputAdornment, Stack, Typography } from "@mui/material"; | ||
import { Row } from "./Row"; | ||
import { useIntl } from "react-intl"; | ||
|
||
type Props = { | ||
open: boolean; | ||
onClose: () => void; | ||
comment?: string; | ||
surveyUnitId: string; | ||
}; | ||
|
||
export const CommentDialog = ({ open, onClose, comment = "", surveyUnitId }: Props) => { | ||
const intl = useIntl(); | ||
|
||
const [newComment, setNewComment] = useState(comment); | ||
|
||
const onChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
const value = event.target.value; | ||
value !== newComment && setNewComment(value); | ||
}; | ||
|
||
const handleCancel = () => { | ||
onClose(); | ||
setNewComment(comment); | ||
}; | ||
|
||
const handleDelete = () => { | ||
// TODO call api to delete comment | ||
onClose(); | ||
setNewComment(""); | ||
}; | ||
|
||
const handleSubmit: React.FormEventHandler<HTMLFormElement> = e => { | ||
e.preventDefault(); | ||
// TODO call api to add comment | ||
onClose(); | ||
}; | ||
|
||
const isModified = newComment !== comment; | ||
|
||
return ( | ||
<Dialog | ||
open={open} | ||
onClose={handleCancel} | ||
sx={{ ".MuiPaper-root": { width: "560px", px: 3, borderRadius: "8px", pb: 2 } }} | ||
> | ||
<form onSubmit={handleSubmit}> | ||
<DialogTitle> | ||
<Row justifyContent={"space-between"}> | ||
<Box>{intl.formatMessage({ id: "comment" })}</Box> | ||
<Row gap={1}> | ||
<Divider orientation="vertical" variant="middle" sx={{ height: "20px" }} /> | ||
<Box> | ||
{intl.formatMessage({ id: "surveyUnitNumber" })} {surveyUnitId} | ||
</Box> | ||
</Row> | ||
</Row> | ||
</DialogTitle> | ||
<DialogContent> | ||
<Stack gap={1}> | ||
<TextField | ||
sx={{ | ||
mt: 1, | ||
".MuiInputLabel-root": { | ||
typography: "labelMedium", | ||
}, | ||
".MuiInputBase-root": { | ||
typography: "bodyMedium", | ||
}, | ||
".MuiOutlinedInput-notchedOutline": { | ||
borderColor: theme.palette.text.secondary, | ||
}, | ||
}} | ||
InputProps={{ | ||
startAdornment: <InputAdornment position="start" />, | ||
}} | ||
autoFocus | ||
id="comment" | ||
name="comment" | ||
label={intl.formatMessage({ id: "comment" })} | ||
placeholder={intl.formatMessage({ id: "commentPlaceholder" })} | ||
type="text" | ||
fullWidth | ||
variant="outlined" | ||
multiline | ||
rows={3} | ||
value={newComment} | ||
onChange={onChange} | ||
/> | ||
<Typography variant="bodySmall" color={"text.tertiary"}> | ||
{intl.formatMessage({ id: "commentDialogHelpText" })} | ||
</Typography> | ||
</Stack> | ||
</DialogContent> | ||
{comment === "" || isModified ? ( | ||
<DialogActions> | ||
<Button onClick={handleCancel}>{intl.formatMessage({ id: "cancel" })}</Button> | ||
<Button type="submit" variant="contained" disabled={!isModified}> | ||
{intl.formatMessage({ id: "validate" })} | ||
</Button> | ||
</DialogActions> | ||
) : ( | ||
<DialogActions> | ||
<Button onClick={handleDelete}>{intl.formatMessage({ id: "delete" })}</Button> | ||
<Button onClick={handleCancel} variant="contained"> | ||
{intl.formatMessage({ id: "closeButtonLabel" })} | ||
</Button> | ||
</DialogActions> | ||
)} | ||
</form> | ||
</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
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