bc01d60728
* style: add eslint configuration as per bee-js * chore: add `plugin:react/reocommended` in `.eslintrc` Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com> * chore: add `consistent` to `array-bracket-newline` as per review * style: after automatic fixes with `npm run lint` * style: fixed all linter errors * refactor: fixed all linter warnings * chore: added missing new line at end of `.prettierrc` file Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { ReactElement, useState } from 'react'
|
|
import QRCode from 'qrcode.react'
|
|
import { IconButton, Dialog, DialogTitle } from '@material-ui/core'
|
|
import { FilterCenterFocusSharp } from '@material-ui/icons'
|
|
|
|
interface Props {
|
|
value: string
|
|
label: string
|
|
}
|
|
|
|
export default function QRCodeModal(props: Props): ReactElement {
|
|
const [open, setOpen] = useState(false)
|
|
|
|
const handleOpen = () => {
|
|
setOpen(true)
|
|
}
|
|
|
|
const handleClose = () => {
|
|
setOpen(false)
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<IconButton color="primary" size="small" onClick={handleOpen}>
|
|
<FilterCenterFocusSharp />
|
|
</IconButton>
|
|
<Dialog onClose={handleClose} aria-labelledby="simple-dialog-title" open={open}>
|
|
<div style={{ padding: '30px', textAlign: 'center' }}>
|
|
<DialogTitle id="simple-dialog-title">{props.label}</DialogTitle>
|
|
<QRCode
|
|
value={props.value}
|
|
size={150}
|
|
bgColor={'#ffffff'}
|
|
fgColor={'#000000'}
|
|
level={'L'}
|
|
includeMargin={false}
|
|
renderAs={'svg'}
|
|
/>
|
|
</div>
|
|
</Dialog>
|
|
</div>
|
|
)
|
|
}
|