From 90bebfb7a5dcca5af407ef4663ce2288eba18c34 Mon Sep 17 00:00:00 2001 From: michacurri Date: Thu, 31 Dec 2020 18:13:01 -0500 Subject: [PATCH 1/2] changed github structure to include develop and release branches - prepping to add workorderDisplay feature to develop branch --- api/routes/workorderRoutes.js | 44 ++--------------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/api/routes/workorderRoutes.js b/api/routes/workorderRoutes.js index 54685ef..09ed215 100644 --- a/api/routes/workorderRoutes.js +++ b/api/routes/workorderRoutes.js @@ -20,43 +20,11 @@ const { createWorkorder } = require("../controllers/workorderController"); // }); // TODO -// @route POST /workorders +// @route POST /api/workorders // @desc Add a new workorder // @access Public -// router.post("/create", async (req, res) => { -// // Create a new workorder from the information entered through req.body -// const { -// // dateIn, -// // dateOut, -// brand, -// model, -// colour, -// // service, -// // status, -// // parts, -// } = req.body; +// router.post("/create/:userId", async (req, res) => { -// const newWorkorder = new Workorder({ -// // dateIn, -// // dateOut, -// brand, -// model, -// colour, -// // service, -// // status, -// // parts, -// }); - -// try { -// const workorder = await newWorkorder.save(); -// res.json(workorder); -// } catch (err) { -// res.json({ error: err }); -// } -// }); - -// cut and pasted from profileRoutes.js -// will need to be modified to not push, but create NEW router // .use(verifyToken) .route("/create/:userId") @@ -80,7 +48,6 @@ router return; } try { - // const profile = await findProfileById(userId); const newWorkorder = await createWorkorder({ // profile, userId, @@ -93,18 +60,11 @@ router // status, // parts, }); - // console.log(`|||| workorderRoutes:96 "newWorkorder": ${newWorkorder}`); res.status(200).json({ newWorkorder }); } catch (err) { console.log(err); res.status(500).json({ message: "Internal server error" }); } - // try { - // const workorder = await newWorkorder.save(); - // res.json(workorder); - // } catch (err) { - // res.json({ error: err }); - // } }); // TODO From b4ab39420e75737040c3a74460a54ea46db790b4 Mon Sep 17 00:00:00 2001 From: michacurri Date: Thu, 31 Dec 2020 18:26:52 -0500 Subject: [PATCH 2/2] workorderRoutes uncommented /get --- .eslintcache | 1 - procfile => Procfile | 0 api/routes/workorderRoutes.js | 16 ++++++++-------- 3 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 .eslintcache rename procfile => Procfile (100%) diff --git a/.eslintcache b/.eslintcache deleted file mode 100644 index add76b8..0000000 --- a/.eslintcache +++ /dev/null @@ -1 +0,0 @@ -[{"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\index.js":"1","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\App.js":"2","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\serviceWorker.js":"3","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Footer.js":"4","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Header.js":"5","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\backend\\authorization\\ImpersonatorContext.js":"6","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\MainContentSection.js":"7","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\backend\\authorization\\UserContext.js":"8","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Home.js":"9","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\backend\\authorization\\AuthContainer.js":"10","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\SidebarNav.js":"11","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Workorder.js":"12","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Profile.js":"13","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\AdvertHero.js":"14","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\admin\\Settings.js":"15","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\WorkorderDisplay.js":"16","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\backend\\authorization\\AuthLoginSignup.js":"17","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\ProfileDisplay.js":"18","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\admin\\WorkorderCreate.js":"19","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\ProfileCreate.js":"20","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\ProfilesSearch.js":"21","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Field.js":"22","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\ContactEditor.js":"23","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\WorkorderEditor.js":"24"},{"size":504,"mtime":1604978282975,"results":"25","hashOfConfig":"26"},{"size":1026,"mtime":1607725577254,"results":"27","hashOfConfig":"26"},{"size":5086,"mtime":499162500000,"results":"28","hashOfConfig":"26"},{"size":317,"mtime":1607899147195,"results":"29","hashOfConfig":"26"},{"size":993,"mtime":1607899147195,"results":"30","hashOfConfig":"26"},{"size":384,"mtime":1607707441472,"results":"31","hashOfConfig":"26"},{"size":1703,"mtime":1607899147196,"results":"32","hashOfConfig":"26"},{"size":348,"mtime":1607707441474,"results":"33","hashOfConfig":"26"},{"size":162,"mtime":1607725577266,"results":"34","hashOfConfig":"26"},{"size":1206,"mtime":1609301357132,"results":"35","hashOfConfig":"26"},{"size":498,"mtime":1607725577272,"results":"36","hashOfConfig":"26"},{"size":1100,"mtime":1609300204622,"results":"37","hashOfConfig":"26"},{"size":2061,"mtime":1607903062458,"results":"38","hashOfConfig":"26"},{"size":456,"mtime":1607725577262,"results":"39","hashOfConfig":"26"},{"size":258,"mtime":1607725577259,"results":"40","hashOfConfig":"26"},{"size":586,"mtime":1609301357139,"results":"41","hashOfConfig":"26"},{"size":2358,"mtime":1609301357134,"results":"42","hashOfConfig":"26"},{"size":559,"mtime":1607903062459,"results":"43","hashOfConfig":"26"},{"size":1408,"mtime":1609301357135,"results":"44","hashOfConfig":"26"},{"size":1245,"mtime":1609301357137,"results":"45","hashOfConfig":"26"},{"size":1573,"mtime":1607903062460,"results":"46","hashOfConfig":"26"},{"size":356,"mtime":1607725577263,"results":"47","hashOfConfig":"26"},{"size":1102,"mtime":1607725577262,"results":"48","hashOfConfig":"26"},{"size":1056,"mtime":1607899147203,"results":"49","hashOfConfig":"26"},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},"a6s0il",{"filePath":"53","messages":"54","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"55","messages":"56","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"57","messages":"58","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"59","messages":"60","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"61","messages":"62","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"63","messages":"64","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"65","messages":"66","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"67","messages":"68","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"69","messages":"70","errorCount":0,"warningCount":3,"fixableErrorCount":0,"fixableWarningCount":0,"source":"71","usedDeprecatedRules":"52"},{"filePath":"72","messages":"73","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"74","messages":"75","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"76","messages":"77","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"78","messages":"79","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"80","messages":"81","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"82","messages":"83","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"84","messages":"85","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"86","usedDeprecatedRules":"52"},{"filePath":"87","messages":"88","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"89","messages":"90","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"91","messages":"92","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"93","messages":"94","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"95","messages":"96","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"97","messages":"98","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},{"filePath":"99","messages":"100","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"52"},"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\index.js",[],["101","102"],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\App.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\serviceWorker.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Footer.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Header.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\backend\\authorization\\ImpersonatorContext.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\MainContentSection.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\backend\\authorization\\UserContext.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Home.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\backend\\authorization\\AuthContainer.js",["103","104","105"],"import React, { useContext, useCallback } from \"react\";\r\nimport { UserContext } from \"./UserContext\";\r\nimport { ImpersonatorContext } from \"./ImpersonatorContext\";\r\nimport AuthLoginSignup from \"./AuthLoginSignup\";\r\n\r\nconst AuthContainer = () => {\r\n const [currentUser, setCurrentUser] = useContext(UserContext);\r\n const [impersonator, setImpersonator] = useContext(ImpersonatorContext);\r\n\r\n //* const loadImpersonator = useCallback(() => {\r\n // setTimeout(() => {\r\n // setImpersonator(undefined);\r\n // }, [3000]);\r\n // }, [setImpersonator]);\r\n\r\n const loadUserProfile = useCallback(\r\n async function () {\r\n try {\r\n const response = await fetch(\"/api/profile/this-profile\", {\r\n headers: {\r\n credentials: \"include\",\r\n },\r\n });\r\n const json = await response.json();\r\n if (!response.ok) {\r\n throw new Error(json.message);\r\n }\r\n setCurrentUser(json.data);\r\n } catch (err) {\r\n console.log(err);\r\n setCurrentUser(undefined);\r\n }\r\n },\r\n [setCurrentUser]\r\n );\r\n return (\r\n \r\n );\r\n};\r\n\r\nexport default AuthContainer;\r\n","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\SidebarNav.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Workorder.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Profile.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\AdvertHero.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\admin\\Settings.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\WorkorderDisplay.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\backend\\authorization\\AuthLoginSignup.js",["106"],"import React, { Fragment, useState } from \"react\";\r\nimport { Link, Switch, Route, Redirect } from \"react-router-dom\";\r\nimport ProfileCreate from \"../../components/root/ProfileCreate\";\r\nimport Field from \"../../components/root/Field\";\r\n\r\nconst headers = {\r\n Accept: \"application/json\",\r\n \"Content-Type\": \"application/json\",\r\n};\r\n\r\nfunction AuthLoginSignup({ loadUserProfile }) {\r\n const [email, setEmail] = useState(\"\");\r\n const [password, setPassword] = useState(\"\");\r\n const [error, setError] = useState(\"\");\r\n const [link, setLink] = useState(\"signup\");\r\n\r\n const changeLink = () => {\r\n if (link === \"signup\") {\r\n setLink(\"login\");\r\n } else {\r\n setLink(\"signup\");\r\n }\r\n };\r\n\r\n const handleSubmit = async (e) => {\r\n e.preventDefault();\r\n try {\r\n const response = await fetch(\"/profile/login\", {\r\n method: \"POST\",\r\n headers: headers,\r\n body: JSON.stringify({ email, password }),\r\n });\r\n const data = await response.json();\r\n if (!response.ok) {\r\n throw new Error(data.message);\r\n }\r\n loadUserProfile();\r\n } catch (err) {\r\n setError(err.message);\r\n console.log(error);\r\n }\r\n };\r\n\r\n return (\r\n \r\n \r\n \r\n \r\n
\r\n
\r\n {\r\n setEmail(e.target.value);\r\n }}\r\n />\r\n {\r\n setPassword(e.target.value);\r\n }}\r\n />\r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n
\r\n {/* prettier-ignore */}\r\n \r\n
\r\n );\r\n}\r\n\r\nexport default AuthLoginSignup;\r\n","C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\ProfileDisplay.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\admin\\WorkorderCreate.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\ProfileCreate.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\ProfilesSearch.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\Field.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\ContactEditor.js",[],"C:\\Users\\n49ph\\Documents\\WebDev\\bike-shop\\aero\\src\\components\\root\\WorkorderEditor.js",[],{"ruleId":"107","replacedBy":"108"},{"ruleId":"109","replacedBy":"110"},{"ruleId":"111","severity":1,"message":"112","line":7,"column":10,"nodeType":"113","messageId":"114","endLine":7,"endColumn":21},{"ruleId":"111","severity":1,"message":"115","line":8,"column":10,"nodeType":"113","messageId":"114","endLine":8,"endColumn":22},{"ruleId":"111","severity":1,"message":"116","line":8,"column":24,"nodeType":"113","messageId":"114","endLine":8,"endColumn":39},{"ruleId":"111","severity":1,"message":"117","line":14,"column":10,"nodeType":"113","messageId":"114","endLine":14,"endColumn":15},"no-native-reassign",["118"],"no-negated-in-lhs",["119"],"no-unused-vars","'currentUser' is assigned a value but never used.","Identifier","unusedVar","'impersonator' is assigned a value but never used.","'setImpersonator' is assigned a value but never used.","'error' is assigned a value but never used.","no-global-assign","no-unsafe-negation"] \ No newline at end of file diff --git a/procfile b/Procfile similarity index 100% rename from procfile rename to Procfile diff --git a/api/routes/workorderRoutes.js b/api/routes/workorderRoutes.js index 09ed215..5fe65a3 100644 --- a/api/routes/workorderRoutes.js +++ b/api/routes/workorderRoutes.js @@ -10,14 +10,14 @@ const { createWorkorder } = require("../controllers/workorderController"); // @route GET/workorders // @desc Returns all workorders // @access Public -// router.get("/", async (req, res) => { -// try { -// const workorders = await Workorder.find(); -// res.json(workorders); -// } catch (err) { -// res.json({ error: err }); -// } -// }); +router.get("/", async (req, res) => { + try { + const workorders = await Workorder.find(); + res.json(workorders); + } catch (err) { + res.json({ error: err }); + } +}); // TODO // @route POST /api/workorders