-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Marine LM <[email protected]>
- Loading branch information
Showing
3 changed files
with
57 additions
and
27 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
openbas-front/src/admin/components/components/reports/ReportGlobalObservation.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,42 @@ | ||
import React, { CSSProperties, useState } from 'react'; | ||
import { Paper, Typography } from '@mui/material'; | ||
import MarkDownField from '../../../../components/fields/MarkDownField'; | ||
import ExpandableMarkdown from '../../../../components/ExpandableMarkdown'; | ||
|
||
interface Props { | ||
label: string | ||
initialValue: string, | ||
style?: CSSProperties, | ||
onBlur: (observation: string) => void, | ||
canWrite?: boolean | ||
} | ||
|
||
const ReportGlobalObservation: React.FC<Props> = ({ | ||
label, | ||
initialValue = '', | ||
style = {}, | ||
onBlur, | ||
canWrite, | ||
}) => { | ||
const [globalObservation, setGlobalObservationRef] = useState<string>(initialValue); | ||
|
||
return ( | ||
<div style={style}> | ||
<Typography variant="h4" gutterBottom> | ||
{label} | ||
</Typography> | ||
|
||
<Paper variant="outlined" sx={{ ...!canWrite && { padding: '10px 15px 10px 15px' } }}> | ||
{canWrite | ||
? <MarkDownField | ||
onChange={(value: string) => setGlobalObservationRef(value)} | ||
initialValue={globalObservation} | ||
onBlur={() => onBlur(globalObservation)} | ||
/> : <ExpandableMarkdown limit={300} source={globalObservation}/> | ||
} | ||
</Paper> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ReportGlobalObservation; |
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