-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OM-330: add qr codes to vouchers (#81)
- Loading branch information
1 parent
7acf16f
commit b987c7f
Showing
7 changed files
with
123 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
"dist" | ||
], | ||
"dependencies": { | ||
"react-qr-code": "^2.0.15", | ||
"react-to-print": "^2.15.1" | ||
} | ||
} |
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,44 @@ | ||
import React from 'react'; | ||
import QRCode from 'react-qr-code'; | ||
import { makeStyles } from '@material-ui/styles'; | ||
|
||
import { Grid } from '@material-ui/core'; | ||
|
||
const useStyles = makeStyles(() => ({ | ||
qrContainer: { | ||
height: 'auto', | ||
margin: '12px auto', | ||
maxWidth: 128, | ||
width: '100%', | ||
}, | ||
qrCode: { | ||
height: 'auto', | ||
maxWidth: '100%', | ||
width: '100%', | ||
}, | ||
})); | ||
|
||
export default function VoucherQRCode({ voucher, bgColor = '#e4f2ff' }) { | ||
if (!voucher) { | ||
return null; | ||
} | ||
|
||
const classes = useStyles(); | ||
const voucherUrl = new URL(`${window.location.origin}${process.env.PUBLIC_URL}/voucher/check/${voucher.code}`); | ||
|
||
return ( | ||
<Grid item xs={12}> | ||
<div className={classes.qrContainer}> | ||
<QRCode | ||
size={128} | ||
className={classes.qrCode} | ||
value={voucherUrl.toString()} | ||
viewBox="0 0 256 256" | ||
level="H" | ||
bgColor={bgColor} | ||
fgColor="#000000" | ||
/> | ||
</div> | ||
</Grid> | ||
); | ||
} |
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