Skip to content

Commit

Permalink
added reader link to admin page
Browse files Browse the repository at this point in the history
  • Loading branch information
jzakotnik committed Aug 23, 2021
1 parent e075d9b commit dd497d4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
6 changes: 5 additions & 1 deletion nextjs/mwe/pages/api/getData.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export default async function handler(req, res) {
if (result2 != null) {
return res
.status(200)
.json({ admin: true, lunchprofile: result2.lunchprofile });
.json({
admin: true,
public_id: result2.public_id,
lunchprofile: result2.lunchprofile,
});
}
//found nothing
return res.status(400).end();
Expand Down
41 changes: 40 additions & 1 deletion nextjs/mwe/pages/lunchprofileadmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ import Slider from "@material-ui/core/Slider";
import Switch from "@material-ui/core/Switch";
import Divider from "@material-ui/core/Divider";
import Impressum from "./impressum";
import IconButton from "@material-ui/core/IconButton";
import QRCode from "qrcode.react";
import FileCopyIcon from "@material-ui/icons/FileCopy";
import Accordion from "@material-ui/core/Accordion";
import AccordionSummary from "@material-ui/core/AccordionSummary";
import AccordionDetails from "@material-ui/core/AccordionDetails";

import ExpandMoreIcon from "@material-ui/icons/ExpandMore";

const marks = [
{
Expand Down Expand Up @@ -68,7 +76,13 @@ export default function LunchProfileAdmin(props) {
const [saving, setSaving] = useState(false);

const authid = props.authid;
const readerid = props.reader;
const readerid = props.readerid;
const readerLink = process.env.NEXT_PUBLIC_PROFILE_ENDPOINT + "/" + readerid;
console.log("Reader Link: ", props);

const handleCopyReader = (event) => {
navigator.clipboard.writeText(readerLink);
};

useEffect(() => {
setLunchProfile(props.lunchdata);
Expand Down Expand Up @@ -260,6 +274,31 @@ export default function LunchProfileAdmin(props) {
/>
</Box>
<SaveButton />
<Accordion>
<AccordionSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1a-content"
id="panel1a-header"
>
<Typography>Öffentliche Links (ready-only)</Typography>
</AccordionSummary>
<AccordionDetails>
<Typography variant="subtitle2">
<b>Nur-Lesen Link</b>
<IconButton aria-label="copy" onClick={handleCopyReader}>
<FileCopyIcon />
</IconButton>{" "}
<br></br>
<a href={readerLink} target="_blank" rel="noopener noreferrer">
{readerLink}
</a>
<br></br>
<center>
<QRCode value={readerLink} />
</center>
</Typography>
</AccordionDetails>
</Accordion>
<Impressum sx={{ mt: 5 }} />
</Box>
</Grid>
Expand Down
3 changes: 2 additions & 1 deletion nextjs/mwe/pages/profile/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Profile = (data) => {
<LunchProfileAdmin
lunchdata={data.lunchprofile}
authid={id}
readerid={data.public_id}
readOnly={readOnly}
userName="Jure"
/>
Expand All @@ -41,7 +42,7 @@ export async function getServerSideProps(context) {
);
const data = await res.json();
console.log("Received response from API");
//console.log(data);
console.log(data);

// Pass data to the page via props
return { props: data };
Expand Down

0 comments on commit dd497d4

Please sign in to comment.