Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #2 #35

Open
wants to merge 43 commits into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
198036d
Merge pull request #24 from michacurri/release
michacurri Jan 2, 2021
1208434
prep for Heroku deploy - removed proxy from package.json and changed …
michacurri Jan 2, 2021
2eba403
changed PORT to process.env.PORT
michacurri Jan 2, 2021
ea0b9eb
heroku launch - commented out app.use(cors...) in server.js
michacurri Jan 2, 2021
f564d25
heroku deploy - changed DB_URI pointer in server.js
michacurri Jan 2, 2021
f2862fd
heroku deploy - uncommented CORS and changed to heroku http
michacurri Jan 2, 2021
8d12e61
heroku deploy - uncommented CORS and changed to heroku http
michacurri Jan 2, 2021
dd2b533
updated MongoDB user and password; amended Heroku secrets; amended .env
michacurri Jan 3, 2021
6ec82b9
heroku deploy: commented out cors... origin
michacurri Jan 3, 2021
b0a7580
removed log profileController.js:32 - populate workorders - causing e…
michacurri Jan 3, 2021
035d0d2
found status 500 error in profileController:32 - console.log - removed
michacurri Jan 3, 2021
00d4bd0
Merge pull request #25 from michacurri/develop
michacurri Jan 3, 2021
4f94a41
on master - oops
michacurri Jan 3, 2021
087fd98
large structural changes to put useContext in MainContentSection and …
michacurri Jan 5, 2021
41f4820
Merge pull request #26 from michacurri/updateProfileFeature
michacurri Jan 5, 2021
6e5d2a5
removed log from verifyToken
michacurri Jan 5, 2021
ae0980c
material-ui integration: login, signup, and workorderDisplay
michacurri Jan 9, 2021
8dd1fcb
Merge pull request #27 from michacurri/materialize
michacurri Jan 9, 2021
7030266
Merge pull request #28 from michacurri/develop
michacurri Jan 9, 2021
e532d04
some signup form validation frontend
michacurri Feb 9, 2021
cbefe8a
bug fix - app.listen moved to within mongoose connect call
michacurri Feb 13, 2021
49fcf5f
ref error - findDOMNode is deprecated in StrictMode
michacurri Feb 13, 2021
b31bdba
ProfileCreate.js email and password validation complete
michacurri Feb 14, 2021
0b57755
signup validation - some bugs with blur - otherwise complete
michacurri Feb 15, 2021
a84e715
merged validation
michacurri Feb 15, 2021
e5fdd2a
develop
michacurri Feb 15, 2021
7755a45
workorder view height adjust, Button integration and color
michacurri Feb 15, 2021
b41066f
Merge pull request #29 from michacurri/b-workorder-display-sizing
michacurri Feb 15, 2021
6a25d95
admin profile setup - bug > allow admin to remove currentProfile with…
michacurri Feb 15, 2021
bf459cc
Merge pull request #30 from michacurri/f-impersonator-integration
michacurri Feb 15, 2021
81606cb
profileRoute and controller for admin search to 'any'
michacurri Feb 16, 2021
02596df
search feature nearly complete
michacurri Feb 17, 2021
9ae2a7f
sidebar navigation materialized
michacurri Feb 17, 2021
16af50b
Merge pull request #31 from michacurri/f-admin-search-profiles
michacurri Feb 17, 2021
e37c413
Merge pull request #32 from michacurri/develop
michacurri Feb 17, 2021
117631f
moving SCSS to material-ui component level design
michacurri Feb 18, 2021
d97e9aa
master save
michacurri Feb 18, 2021
9aac274
reduced SCSS to just setup; working on cleaning up user-side
michacurri Feb 20, 2021
6fa7276
added Services.js on admin to input services
michacurri Feb 21, 2021
d6c20a1
Services, serviceRoutes, serviceController, and server made or update
michacurri Feb 21, 2021
22468b2
services State and display started
michacurri Feb 24, 2021
4c22b3d
Merge pull request #33 from michacurri/f-request-service
michacurri Feb 24, 2021
2ad1142
Merge pull request #34 from michacurri/develop
michacurri Feb 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions api/controllers/profileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const Profile = require("../models/profileModel");

module.exports = {
createProfile: async ({
admin,
firstName,
lastName,
email,
Expand All @@ -14,6 +15,7 @@ module.exports = {
workorders,
}) => {
const newProfile = new Profile({
admin,
firstName,
lastName,
phone,
Expand All @@ -29,20 +31,18 @@ module.exports = {
const profileRes = await Profile.findOne({ email })
.populate("workorders")
.exec();
console.log(`"profileRes.workorders": ${profileRes.workorders}`);
return profileRes;
} catch (err) {
throw err;
}
},
findProfileById: async (id) => {
try {
const profile = await Profile.findById(id)
.populate("workorders")
.exec();
const profile = await Profile.findById(id).populate("workorders").exec();
//* return everything but password
return {
id: profile._id,
admin: profile.admin,
firstName: profile.firstName,
lastName: profile.lastName,
email: profile.email,
Expand All @@ -52,4 +52,22 @@ module.exports = {
throw err;
}
},
findProfileByAny: async (inputValue) => {
try {
const profileRes = await Profile.find({
$or: [
{ firstName: inputValue },
{ lastName: inputValue },
{ email: inputValue },
// TODO - mongoose.js CastError: Cast to number failed for value
// { phone: inputValue },
],
})
.populate("workorders")
.exec();
return profileRes;
} catch (err) {
throw err;
}
},
};
25 changes: 25 additions & 0 deletions api/controllers/serviceController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const Services = require("../models/serviceSchema");

exports.findService = async (title) => {
try {
const serviceRes = await Services.find({ title });
return serviceRes;
} catch (err) {
throw err;
}
};

exports.createService = async ({ serviceType, title, desc, price }) => {
try {
const newService = new Service({
serviceType,
title,
desc,
price,
});
const service = await newService.save();
return service;
} catch (err) {
console.log(`error: ${err}`);
}
};
1 change: 0 additions & 1 deletion api/controllers/workorderController.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const Workorder = require("../models/workorderModel");
// const { findProfileById } = require("./profileController");
const Profile = require("../models/profileModel");

exports.createWorkorder = async ({ userId, brand, model, colour }) => {
Expand Down
23 changes: 18 additions & 5 deletions api/models/profileModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const { Schema } = mongoose;

const profileSchema = new Schema(
{
admin: {
type: Boolean,
required: true,
default: false,
},
firstName: {
type: String,
required: true,
Expand All @@ -20,20 +25,28 @@ const profileSchema = new Schema(
phone: {
type: Number,
required: true,
minlength: 10,
maxlength: 11,
match: /^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$/,
},
email: {
type: String,
required: true,
required: true,
unique: true,
match: /^.+@.+$/,
},
password: {
type: String,
required: true,
minlength: 8,
match: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{8,})/,
},
workorders: [{
type: Schema.Types.ObjectId,
ref: 'Workorder'
}]
workorders: [
{
type: Schema.Types.ObjectId,
ref: "Workorder",
},
],
},
{
timestamps: { createdAt: "created_at", updatedAt: "updated_at" },
Expand Down
24 changes: 21 additions & 3 deletions api/models/serviceSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@ const mongoose = require("mongoose");
const { Schema } = mongoose;

//___ servicesSchema
// service: String
// serviceType: String
// title: String
// description: [String]
// price: Number

const serviceSchema = new Schema({
services: String,
serviceType: {
type: String,
required: true,
},
title: {
type: String,
required: true,
},
desc: {
type: [String],
required: true,
},
price: {
type: Number,
required: true,
},
});

module.exports = serviceSchema;
module.exports = mongoose.model("Services", serviceSchema);
28 changes: 24 additions & 4 deletions api/routes/profileRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const {
createProfile,
findProfileByEmail,
findProfileById,
findProfileByAny,
} = require("../controllers/profileController");
const { verifyToken } = require("../middleware/verifyToken");
const { createToken } = require("../tokens/tokenService");

const router = express.Router();
// router.get("/search/email/:email", findProfileByEmail);

router.route("/create").post(async (req, res) => {
const { firstName, lastName, email, phone, password } = req.body;
Expand Down Expand Up @@ -54,7 +54,6 @@ router.route("/create").post(async (req, res) => {
});

router.route("/login").post(async (req, res) => {
console.log("route: login");
const { email, password } = req.body;
if (!email || email === " ") {
res.status(400).json({ message: "email must be provided" });
Expand Down Expand Up @@ -87,13 +86,34 @@ router.route("/login").post(async (req, res) => {
}
});

// where workorder route used to be
router
.route("/search/:searchValue")
.get(async (req, res) => {
const { searchValue } = req.params;
if (!searchValue || searchValue === "") {
res.status(400).json({ message: "nothing to search" });
return;
} else {
try {
const match = await findProfileByAny(searchValue);
if (!match) {
res
.status(400)
.json({ message: `Search for "${searchValue}" returned no results` });
return;
}
res.status(200).json(match);
} catch (err) {
console.log(err);
res.status(500).json({ message: "Internal server error" });
}
}
});

router
.use(verifyToken)
.route("/this-profile")
.get(async (req, res) => {
console.log(`/this-profile: ${req.profile.id}`);
try {
const profile = await findProfileById(req.profile.id);
res.json({ data: profile });
Expand Down
52 changes: 52 additions & 0 deletions api/routes/serviceRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const express = require("express");
const router = express.Router();
const Services = require("../models/serviceSchema");

router.route("/").get(async (req, res) => {
try {
const services = await Services.find();
res.json(services);
} catch (err) {
res.json({ error: err });
}
});

router.route("/create").post(async (req, res) => {
const { serviceType, title, desc, price } = req.body;
if (!serviceType || serviceType === " ") {
res.status(400).json({ message: "service type must be provided" });
return;
}
if (!title || title === " ") {
res.status(400).json({ message: "title must be provided" });
return;
}
if (!desc || desc === " ") {
res.status(400).json({ message: "description must be provided" });
return;
}
if (!price || price === " ") {
res.status(400).json({ message: "price must be provided" });
return;
}
try {
const service = await findService(title);
if (service) {
res
.status(400)
.json({ message: `a service with this title already exists` });
}
const newService = await createService({
serviceType,
title,
desc,
price,
});
res.status(200).json({ data: { id: newService._id } });
} catch (err) {
console.log(err);
res.status(500).json({ message: "Internal server error" });
}
});

module.exports = router;
6 changes: 3 additions & 3 deletions api/routes/workorderRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const express = require("express");
const router = express.Router();
const Workorder = require("../models/workorderModel");
const { verifyToken } = require("../middleware/verifyToken");
const { createToken } = require("../tokens/tokenService");
const { findProfileById } = require("../controllers/profileController");
const { createWorkorder } = require("../controllers/workorderController");
// const { createToken } = require("../tokens/tokenService");
// const { findProfileById } = require("../controllers/profileController");

// TODO
// @route GET/workorders
Expand All @@ -26,7 +26,7 @@ router.get("/", async (req, res) => {
// router.post("/create/:userId", async (req, res) => {

router
// .use(verifyToken)
.use(verifyToken)
.route("/create/:userId")
.post(async (req, res) => {
const { brand, model, colour } = req.body;
Expand Down
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
"object-path": "^0.11.5",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-input-mask": "^2.0.4",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.1",
"react-virtualized": "^9.22.3"
},
"proxy": "http://localhost:5000",
"scripts": {
"start:client": "react-scripts start",
"start:server": "nodemon server.js --ignore src",
Expand All @@ -35,7 +37,6 @@
"eslintConfig": {
"extends": "react-app"
},
"proxy": "http://localhost:5000",
"browserslist": {
"production": [
">0.2%",
Expand Down
Loading