diff --git a/nextjs/mwe/pages/admin.js b/nextjs/mwe/pages/admin.js index c0aca55..ad7125a 100644 --- a/nextjs/mwe/pages/admin.js +++ b/nextjs/mwe/pages/admin.js @@ -43,7 +43,7 @@ export default function Admin(props) { const defaultLunchProfile = { mon: true, tue: true, - wed: false, + wed: true, thu: true, fri: true, }; diff --git a/nextjs/mwe/pages/api/getData.js b/nextjs/mwe/pages/api/getData.js index db0b9d9..df0df6e 100644 --- a/nextjs/mwe/pages/api/getData.js +++ b/nextjs/mwe/pages/api/getData.js @@ -7,7 +7,11 @@ export default function handler(req, res) { console.log("Got request for the database"); console.log(req.query.id); db.get(req.query.id, function (err, value) { - if (err) return console.log("DB request failed", err); // likely the key was not found + if (err) { + db.close(); + res.end(value); + return console.log("DB request failed", err); + } // likely the key was not found console.log(value); db.close(); res.end(value); diff --git a/nextjs/mwe/pages/lunchprofile.js b/nextjs/mwe/pages/lunchprofile.js index 9f5a0c1..c69053f 100644 --- a/nextjs/mwe/pages/lunchprofile.js +++ b/nextjs/mwe/pages/lunchprofile.js @@ -45,6 +45,10 @@ export default function LunchProfile(props) { fri: true, }); + const readOnly = !props.admin; + const authid = props.authid; + const readerid = props.reader; + useEffect(() => { console.log("Use Effect with props:"); console.log(props); @@ -54,7 +58,8 @@ export default function LunchProfile(props) { const handleSubmit = (event) => { event.preventDefault(); //console.log(event); - const data = dayselection; + + const data = { dayselection, authid: { admin: authid, reader: readerid } }; console.log("Saving.."); console.log(JSON.stringify(data)); diff --git a/nextjs/mwe/pages/profile/[id].js b/nextjs/mwe/pages/profile/[id].js index 707da59..95283d7 100644 --- a/nextjs/mwe/pages/profile/[id].js +++ b/nextjs/mwe/pages/profile/[id].js @@ -6,11 +6,13 @@ const Profile = (data) => { const router = useRouter(); const { id } = router.query; console.log("Rendering data"); - console.log(data); + console.log(data, id); return (