create-myexam-app 1.0.20 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +1 -1
  2. package/projects/SCMS/backend/.env +2 -2
  3. package/projects/SCMS/backend/config/db.js +12 -0
  4. package/projects/SCMS/backend/controllers/authController.js +90 -0
  5. package/projects/SCMS/backend/controllers/deliveryController.js +79 -0
  6. package/projects/SCMS/backend/controllers/productController.js +74 -0
  7. package/projects/SCMS/backend/controllers/reportsController.js +77 -0
  8. package/projects/SCMS/backend/controllers/shipmentController.js +80 -0
  9. package/projects/SCMS/backend/controllers/supplierController.js +58 -0
  10. package/projects/SCMS/backend/middleware/auth.js +32 -0
  11. package/projects/SCMS/backend/models/User.js +28 -0
  12. package/projects/SCMS/backend/models/delivery.js +33 -0
  13. package/projects/SCMS/backend/models/product.js +43 -0
  14. package/projects/SCMS/backend/models/shipment.js +34 -0
  15. package/projects/SCMS/backend/models/supplier.js +36 -0
  16. package/projects/SCMS/backend/package-lock.json +2190 -778
  17. package/projects/SCMS/backend/package.json +23 -23
  18. package/projects/SCMS/backend/routes/SupplierRoutes.js +15 -0
  19. package/projects/SCMS/backend/routes/authRoutes.js +11 -0
  20. package/projects/SCMS/backend/routes/deliveryRoutes.js +18 -0
  21. package/projects/SCMS/backend/routes/productRoutes.js +15 -0
  22. package/projects/SCMS/backend/routes/protectedRoutes.js +10 -0
  23. package/projects/SCMS/backend/routes/reportsRoutes.js +8 -0
  24. package/projects/SCMS/backend/routes/shipmentRoutes.js +18 -0
  25. package/projects/SCMS/backend/server.js +28 -8
  26. package/projects/SCMS/frontend/index.html +1 -1
  27. package/projects/SCMS/frontend/package-lock.json +781 -152
  28. package/projects/SCMS/frontend/package.json +5 -1
  29. package/projects/SCMS/frontend/src/App.jsx +28 -115
  30. package/projects/SCMS/frontend/src/components/DashboardLayout.jsx +103 -0
  31. package/projects/SCMS/frontend/src/components/ProtectedRoute.jsx +30 -0
  32. package/projects/SCMS/frontend/src/index.css +110 -107
  33. package/projects/SCMS/frontend/src/pages/DashboardHome.jsx +34 -0
  34. package/projects/SCMS/frontend/src/pages/Delivery.jsx +183 -0
  35. package/projects/SCMS/frontend/src/pages/Login.jsx +81 -0
  36. package/projects/SCMS/frontend/src/pages/Profile.jsx +62 -0
  37. package/projects/SCMS/frontend/src/pages/Register.jsx +110 -0
  38. package/projects/SCMS/frontend/src/pages/Reports.jsx +94 -0
  39. package/projects/SCMS/frontend/src/pages/Shipment.jsx +182 -0
  40. package/projects/SCMS/frontend/src/pages/Supplier.jsx +165 -0
  41. package/projects/SCMS/frontend/vite.config.js +2 -2
  42. package/projects/SCMS/backend/db/connectDB.js +0 -11
  43. package/projects/SCMS/frontend/public/icons.svg +0 -24
  44. package/projects/SCMS/frontend/src/App.css +0 -184
  45. package/projects/SCMS/frontend/src/assets/hero.png +0 -0
  46. package/projects/SCMS/frontend/src/assets/react.svg +0 -1
  47. package/projects/SCMS/frontend/src/assets/vite.svg +0 -1
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  "name": "create-myexam-app",
4
4
 
5
- "version": "1.0.20",
5
+ "version": "1.0.21",
6
6
 
7
7
  "description": "My exam projects",
8
8
 
@@ -1,5 +1,5 @@
1
- PORT= 5000
1
+ PORT=5000
2
2
 
3
- MONGO_URI=mongodb://localhost:27017/scms_dbb
3
+ MONGO_URI=mongodb://localhost:27017/SCMS
4
4
 
5
5
  JWT_SECRET=your_secret_key_here
@@ -0,0 +1,12 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const connectDB = async () => {
4
+ try {
5
+ await mongoose.connect('mongodb://localhost:27017/SCMS');
6
+ console.log('MongoDB connected');
7
+ } catch (error) {
8
+ console.error('MongoDB connection error:', error);
9
+ }
10
+ };
11
+
12
+ module.exports = connectDB;
@@ -0,0 +1,90 @@
1
+ const bcrypt = require('bcrypt');
2
+ const jwt = require('jsonwebtoken');
3
+ const User = require('../models/User');
4
+ const JWT_SECRET = 'change_this_to_a_long_random_secret';
5
+
6
+
7
+
8
+ function createToken(userId) {
9
+ return jwt.sign({ userId },JWT_SECRET, { expiresIn: '7d' });
10
+ }
11
+
12
+ function formatUser(user) {
13
+ return {
14
+ id: user._id,
15
+ name: user.name,
16
+ email: user.email,
17
+ };
18
+ }
19
+
20
+ exports.register = async (req, res) => {
21
+ try {
22
+ const { name, email, password } = req.body;
23
+
24
+ if (!name || !email || !password) {
25
+ return res.status(400).json({ message: 'Name, email, and password are required' });
26
+ }
27
+
28
+ if (password.length < 6) {
29
+ return res.status(400).json({ message: 'Password must be at least 6 characters' });
30
+ }
31
+
32
+ const existing = await User.findOne({ email: email.toLowerCase() });
33
+ if (existing) {
34
+ return res.status(409).json({ message: 'Email already registered' });
35
+ }
36
+
37
+ const hashedPassword = await bcrypt.hash(password, 10);
38
+ const user = await User.create({
39
+ name,
40
+ email: email.toLowerCase(),//to ensure the email is always lowercase
41
+ password: hashedPassword,
42
+ });
43
+
44
+ const token = createToken(user._id);
45
+
46
+ res.status(201).json({
47
+ token,
48
+ user: formatUser(user),
49
+ });
50
+ } catch (err) {
51
+ res.status(500).json({ message: err.message });
52
+ }
53
+ }
54
+
55
+ exports.login = async (req, res) => {
56
+ try {
57
+ const { email, password } = req.body;
58
+
59
+ if (!email || !password) {
60
+ return res.status(400).json({ message: 'Email and password are required' });
61
+ }
62
+
63
+ const user = await User.findOne({ email: email.toLowerCase() });
64
+ if (!user) {
65
+ return res.status(401).json({ message: 'Invalid email or password' });
66
+ }
67
+
68
+ const match = await bcrypt.compare(password, user.password);
69
+ if (!match) {
70
+ return res.status(401).json({ message: 'Invalid email or password' });
71
+ }
72
+
73
+ const token = createToken(user._id);
74
+
75
+ res.json({
76
+ token,
77
+ user: formatUser(user),
78
+ });
79
+ } catch (err) {
80
+ res.status(500).json({ message: err.message });
81
+ }
82
+ }
83
+
84
+ exports.getMe = async (req, res) => {
85
+ try {
86
+ res.json({ user: formatUser(req.user) });
87
+ } catch (err) {
88
+ res.status(500).json({ message: err.message });
89
+ }
90
+ };
@@ -0,0 +1,79 @@
1
+ const Delivery = require('../models/delivery');
2
+ const Shipment = require('../models/shipment');
3
+
4
+ exports.addDelivery = async (req, res) => {
5
+ try {
6
+ const { deliveryCode, deliveryDate, quantityDelivered, deliveryStatus, shipmentId } = req.body;
7
+
8
+ if (shipmentId) {
9
+ const shipment = await Shipment.findById(shipmentId);
10
+ if (!shipment) return res.status(404).json({ msg: 'Shipment not found' });
11
+ }
12
+
13
+ const newDelivery = await Delivery.create({
14
+ deliveryCode,
15
+ deliveryDate,
16
+ quantityDelivered,
17
+ deliveryStatus,
18
+ shipment: shipmentId || null,
19
+ });
20
+
21
+ res.status(201).json(newDelivery);
22
+ } catch (error) {
23
+ res.status(500).json({ msg: 'Failed to add delivery', error: error.message });
24
+ }
25
+ };
26
+
27
+ exports.getDeliveries = async (req, res) => {
28
+ try {
29
+ const deliveries = await Delivery.find().populate({ path: 'shipment', populate: 'supplier' });
30
+ res.status(200).json(deliveries);
31
+ } catch (error) {
32
+ res.status(500).json({ msg: 'Failed to fetch deliveries', error: error.message });
33
+ }
34
+ };
35
+
36
+ exports.getDeliveryById = async (req, res) => {
37
+ try {
38
+ const delivery = await Delivery.findById(req.params.id).populate({ path: 'shipment', populate: 'supplier' });
39
+ if (!delivery) return res.status(404).json({ msg: 'Delivery not found' });
40
+ res.status(200).json(delivery);
41
+ } catch (error) {
42
+ res.status(500).json({ msg: 'Failed to fetch delivery', error: error.message });
43
+ }
44
+ };
45
+
46
+ exports.updateDelivery = async (req, res) => {
47
+ try {
48
+ const { shipmentId } = req.body;
49
+
50
+ if (shipmentId) {
51
+ const shipment = await Shipment.findById(shipmentId);
52
+ if (!shipment) return res.status(404).json({ msg: 'Shipment not found' });
53
+ }
54
+
55
+ const updatedDelivery = await Delivery.findByIdAndUpdate(
56
+ req.params.id,
57
+ {
58
+ ...req.body,
59
+ shipment: shipmentId || null,
60
+ },
61
+ { new: true }
62
+ );
63
+
64
+ if (!updatedDelivery) return res.status(404).json({ msg: 'Delivery not found' });
65
+ res.status(200).json(updatedDelivery);
66
+ } catch (error) {
67
+ res.status(500).json({ msg: 'Failed to update delivery', error: error.message });
68
+ }
69
+ };
70
+
71
+ exports.deleteDelivery = async (req, res) => {
72
+ try {
73
+ const deletedDelivery = await Delivery.findByIdAndDelete(req.params.id);
74
+ if (!deletedDelivery) return res.status(404).json({ msg: 'Delivery not found' });
75
+ res.status(200).json({ msg: 'Delivery deleted successfully' });
76
+ } catch (error) {
77
+ res.status(500).json({ msg: 'Failed to delete delivery', error: error.message });
78
+ }
79
+ };
@@ -0,0 +1,74 @@
1
+ const Product = require('../models/Product');
2
+
3
+
4
+ exports.getproduct = async (req, res) => {
5
+ try {
6
+ const products = await Product.find().populate('Supplier');
7
+ if (!products) {
8
+ return res.status(404).json({ message: 'Products not found' });
9
+ }
10
+ res.json(products);
11
+ } catch (err) {
12
+ res.status(500).json({ message: err.message });
13
+ }
14
+ }
15
+
16
+ exports.getproductbyid = async (req, res) => {
17
+ try {
18
+ const productById = await Product.findById(req.params.id).populate('Supplier');
19
+ if (!productById) {
20
+ return res.status(404).json({ message: 'Product not found' });
21
+ }
22
+ res.json(productById);
23
+ } catch (err) {
24
+ res.status(500).json({ message: err.message });
25
+ }
26
+ };
27
+
28
+ exports.addproduct = async (req, res) => {
29
+ try {
30
+ const { productCode, productName, category, unitPrice, quantity, expiryDate } = req.body
31
+ const newproduct = await Product.create({
32
+ productCode,
33
+ productName,
34
+ category,
35
+ unitPrice,
36
+ quantity,
37
+ expiryDate,
38
+ Supplier: req.user._id
39
+ });
40
+
41
+ res.status(201).json(newproduct);
42
+ } catch (err) {
43
+ res.status(500).json({ message: err.message });
44
+ }
45
+ }
46
+
47
+ exports.updateproduct = async (req, res) => {
48
+ try {
49
+ const updateproducts = await Product.findByIdAndUpdate(
50
+ req.params.id,
51
+ req.body,
52
+ { new: true }
53
+ );
54
+ if (!updateproducts) return res.status(404).json({ msg: " product not found" })
55
+
56
+ res.json({ msg: "Products updated Syccessfully", data: updateproducts });
57
+ } catch (err) {
58
+ res.status(500).json({ message: err.message });
59
+ }
60
+ }
61
+
62
+ exports.deleteproduct = async (req, res) => {
63
+ try {
64
+ const deleteproduct = await Product.findByIdAndDelete(
65
+ req.params.id
66
+ );
67
+ if (!deleteproduct) {
68
+ return res.status(404).json({ message: 'product not found' });
69
+ }
70
+ res.json({ message: 'Product deleted successfully' });
71
+ } catch (err) {
72
+ res.status(500).json({ message: err.message });
73
+ }
74
+ }
@@ -0,0 +1,77 @@
1
+ const Supplier = require('../models/Supplier');
2
+ const Shipment = require('../models/shipment');
3
+ const Delivery = require('../models/delivery');
4
+
5
+ function getStartDate(days) {
6
+ const date = new Date();
7
+ date.setHours(0, 0, 0, 0);
8
+ date.setDate(date.getDate() - days);
9
+ return date;
10
+ }
11
+
12
+ exports.getReportSummary = async (req, res) => {
13
+ try {
14
+ const now = new Date();
15
+ const dailyStart = getStartDate(1);
16
+ const weeklyStart = getStartDate(7);
17
+ const monthlyStart = getStartDate(30);
18
+
19
+ const [
20
+ totalSuppliers,
21
+ dailySuppliers,
22
+ weeklySuppliers,
23
+ monthlySuppliers,
24
+ totalShipments,
25
+ dailyShipments,
26
+ weeklyShipments,
27
+ monthlyShipments,
28
+ totalDeliveries,
29
+ dailyDeliveries,
30
+ weeklyDeliveries,
31
+ monthlyDeliveries,
32
+ recentShipments,
33
+ recentDeliveries,
34
+ ] = await Promise.all([
35
+ Supplier.countDocuments(),
36
+ Supplier.countDocuments({ createdAt: { $gte: dailyStart } }),
37
+ Supplier.countDocuments({ createdAt: { $gte: weeklyStart } }),
38
+ Supplier.countDocuments({ createdAt: { $gte: monthlyStart } }),
39
+ Shipment.countDocuments(),
40
+ Shipment.countDocuments({ createdAt: { $gte: dailyStart } }),
41
+ Shipment.countDocuments({ createdAt: { $gte: weeklyStart } }),
42
+ Shipment.countDocuments({ createdAt: { $gte: monthlyStart } }),
43
+ Delivery.countDocuments(),
44
+ Delivery.countDocuments({ createdAt: { $gte: dailyStart } }),
45
+ Delivery.countDocuments({ createdAt: { $gte: weeklyStart } }),
46
+ Delivery.countDocuments({ createdAt: { $gte: monthlyStart } }),
47
+ Shipment.find().sort({ createdAt: -1 }).limit(5).populate('supplier'),
48
+ Delivery.find().sort({ createdAt: -1 }).limit(5).populate({ path: 'shipment', populate: 'supplier' }),
49
+ ]);
50
+
51
+ res.status(200).json({
52
+ suppliers: {
53
+ total: totalSuppliers,
54
+ daily: dailySuppliers,
55
+ weekly: weeklySuppliers,
56
+ monthly: monthlySuppliers,
57
+ },
58
+ shipments: {
59
+ total: totalShipments,
60
+ daily: dailyShipments,
61
+ weekly: weeklyShipments,
62
+ monthly: monthlyShipments,
63
+ },
64
+ deliveries: {
65
+ total: totalDeliveries,
66
+ daily: dailyDeliveries,
67
+ weekly: weeklyDeliveries,
68
+ monthly: monthlyDeliveries,
69
+ },
70
+ recentShipments,
71
+ recentDeliveries,
72
+ generatedAt: now,
73
+ });
74
+ } catch (error) {
75
+ res.status(500).json({ msg: 'Failed to generate report', error: error.message });
76
+ }
77
+ };
@@ -0,0 +1,80 @@
1
+ const Shipment = require('../models/shipment');
2
+ const Supplier = require('../models/Supplier');
3
+
4
+ exports.addShipment = async (req, res) => {
5
+ try {
6
+ const { shipmentNumber, shipmentDate, shipmentStatus, destination, supplierId } = req.body;
7
+
8
+ if (supplierId) {
9
+ const supplier = await Supplier.findById(supplierId);
10
+ if (!supplier) return res.status(404).json({ msg: 'Supplier not found' });
11
+ }
12
+
13
+ const newShipment = await Shipment.create({
14
+ shipmentNumber,
15
+ shipmentDate,
16
+ shipmentStatus,
17
+ destination,
18
+ supplier: supplierId || null,
19
+ });
20
+
21
+ res.status(201).json(newShipment);
22
+ } catch (error) {
23
+ res.status(500).json({ msg: 'Failed to add shipment', error: error.message });
24
+ }
25
+ };
26
+
27
+ exports.getShipments = async (req, res) => {
28
+ try {
29
+ const shipments = await Shipment.find().populate('supplier');
30
+ res.status(200).json(shipments);
31
+ } catch (error) {
32
+ res.status(500).json({ msg: 'Failed to fetch shipments', error: error.message });
33
+ }
34
+ };
35
+
36
+ exports.getShipmentById = async (req, res) => {
37
+ try {
38
+ const shipment = await Shipment.findById(req.params.id).populate('supplier');
39
+ if (!shipment) return res.status(404).json({ msg: 'Shipment not found' });
40
+ res.status(200).json(shipment);
41
+ } catch (error) {
42
+ res.status(500).json({ msg: 'Failed to fetch shipment', error: error.message });
43
+ }
44
+ };
45
+
46
+ exports.updateShipment = async (req, res) => {
47
+ try {
48
+ const { supplierId } = req.body;
49
+
50
+ if (supplierId) {
51
+ const supplier = await Supplier.findById(supplierId);
52
+ if (!supplier) return res.status(404).json({ msg: 'Supplier not found' });
53
+ }
54
+
55
+ const updatedShipment = await Shipment.findByIdAndUpdate(
56
+ req.params.id,
57
+ {
58
+ ...req.body,
59
+ supplier: supplierId || null,
60
+ },
61
+ { new: true }
62
+ );
63
+
64
+ if (!updatedShipment) return res.status(404).json({ msg: 'Shipment not found' });
65
+
66
+ res.status(200).json(updatedShipment);
67
+ } catch (error) {
68
+ res.status(500).json({ msg: 'Failed to update shipment', error: error.message });
69
+ }
70
+ };
71
+
72
+ exports.deleteShipment = async (req, res) => {
73
+ try {
74
+ const deletedShipment = await Shipment.findByIdAndDelete(req.params.id);
75
+ if (!deletedShipment) return res.status(404).json({ msg: 'Shipment not found' });
76
+ res.status(200).json({ msg: 'Shipment deleted successfully' });
77
+ } catch (error) {
78
+ res.status(500).json({ msg: 'Failed to delete shipment', error: error.message });
79
+ }
80
+ };
@@ -0,0 +1,58 @@
1
+ const supplier = require('../models/Supplier');
2
+
3
+ exports.addsupplier = async (req, res) => {
4
+ try {
5
+ const newsupplier = new supplier(req.body);
6
+ await newsupplier.save();
7
+ res.status(200).json({ msg: 'Supplier added successful' });
8
+ } catch (error) {
9
+ res.status(500).json({ msg: 'Failed to add supplier', error: error.message });
10
+ }
11
+ };
12
+
13
+ exports.getsupplierbyid = async (req, res) => {
14
+ try {
15
+ const singlesupplier = await supplier.findById(req.params.id);
16
+
17
+ if (!singlesupplier) return res.status(404).json({ msg: 'Supplier not found' });
18
+
19
+ res.status(200).json(singlesupplier);
20
+ } catch (error) {
21
+ res.status(500).json({ msg: 'failed to fetch', error: error.message });
22
+ }
23
+ };
24
+
25
+ exports.getsupplier = async (req, res) => {
26
+ try {
27
+ const getsupplier = await supplier.find();
28
+ res.status(200).json(getsupplier);
29
+ } catch (error) {
30
+ res.status(500).json({ error: error.message });
31
+ }
32
+ };
33
+
34
+ exports.updatesupplier = async (req, res) => {
35
+ try {
36
+ const updatesupplier = await supplier.findByIdAndUpdate(req.params.id, req.body, {
37
+ new: true,
38
+ });
39
+
40
+ if (!updatesupplier) return res.status(404).json({ msg: 'Supplier not found' });
41
+
42
+ res.status(200).json({ msg: 'updated successfully' });
43
+ } catch (error) {
44
+ res.status(500).json({ msg: 'Failed to update', error: error.message });
45
+ }
46
+ };
47
+
48
+ exports.deletesupplier = async (req, res) => {
49
+ try {
50
+ const deletesupplier = await supplier.findByIdAndDelete(req.params.id);
51
+
52
+ if (!deletesupplier) return res.status(404).json({ msg: 'Supplier not found' });
53
+
54
+ res.status(200).json({ msg: 'Deleted successfully' });
55
+ } catch (error) {
56
+ res.status(500).json({ msg: 'Failed to delete', error: error.message });
57
+ }
58
+ };
@@ -0,0 +1,32 @@
1
+ // this middleware is helping us to protect our routes so that only authenticated users can access the routes
2
+ //it is checking if the user is authenticated by checking the token in the header(the header is the part of the request that contains the token)
3
+ //if the user is not authenticated, it will return a 401 status code and a message that the user is not authorized
4
+ //if the user is authenticated, it will return the user object
5
+ //and the user object is the user that is authenticated
6
+
7
+ const jwt = require('jsonwebtoken');
8
+ const User = require('../models/User');
9
+ const JWT_SECRET = 'change_this_to_a_long_random_secret';
10
+
11
+ exports.protect = async (req, res, next) => {
12
+ try {
13
+ const header = req.headers.authorization;
14
+
15
+ if (!header || !header.startsWith('Bearer ')) {
16
+ return res.status(401).json({ message: 'Not authorized' });
17
+ }
18
+
19
+ const token = header.split(' ')[1];
20
+ const decoded = jwt.verify(token, JWT_SECRET);
21
+ const user = await User.findById(decoded.userId).select('-password');
22
+
23
+ if (!user) {
24
+ return res.status(401).json({ message: 'Not authorized' });
25
+ }
26
+
27
+ req.user = user;
28
+ next();
29
+ } catch (err) {
30
+ return res.status(401).json({ message: 'Not authorized' });
31
+ }
32
+ };
@@ -0,0 +1,28 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const userSchema = new mongoose.Schema(
4
+ {
5
+ name: {
6
+ type: String,
7
+ required: true,
8
+ trim: true,
9
+ },
10
+ email: {
11
+ type: String,
12
+ required: true,
13
+ unique: true,
14
+ lowercase: true,
15
+ trim: true,
16
+ },
17
+ password: {
18
+ type: String,
19
+ required: true,
20
+ minlength: 6,
21
+ },
22
+ },
23
+ { timestamps: true }
24
+ );
25
+
26
+ const User = mongoose.model('User', userSchema);
27
+
28
+ module.exports = User;
@@ -0,0 +1,33 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const deliverySchema = new mongoose.Schema(
4
+ {
5
+ deliveryCode: {
6
+ type: String,
7
+ required: true,
8
+ trim: true,
9
+ unique: true,
10
+ },
11
+ deliveryDate: {
12
+ type: Date,
13
+ required: true,
14
+ },
15
+ quantityDelivered: {
16
+ type: Number,
17
+ required: true,
18
+ },
19
+ deliveryStatus: {
20
+ type: String,
21
+ required: true,
22
+ trim: true,
23
+ },
24
+ shipment: {
25
+ type: mongoose.Schema.Types.ObjectId,
26
+ ref: 'Shipment',
27
+ required: false,
28
+ },
29
+ },
30
+ { timestamps: true }
31
+ );
32
+
33
+ module.exports = mongoose.model('Delivery', deliverySchema);
@@ -0,0 +1,43 @@
1
+ const mongoose = require('mongoose');
2
+ const Supplier = require('./Supplier');
3
+
4
+ const productSchema = new mongoose.Schema(
5
+ {
6
+ productCode: {
7
+ type: String,
8
+ required: true,
9
+ trim: true,
10
+ },
11
+ productName: {
12
+ type: String,
13
+ default: '',
14
+ trim: true,
15
+ },
16
+ category: {
17
+ type: String,
18
+ required: true,
19
+ trim: true
20
+ },
21
+
22
+ unitPrice: {
23
+ type: String,
24
+ required: true,
25
+ trim: true
26
+ },
27
+ quantity: {
28
+ type: String,
29
+ required: true,
30
+ trim: true
31
+ },
32
+ expiryDate: {
33
+ type: String
34
+ },
35
+ Supplier: {
36
+ type: mongoose.Schema.Types.ObjectId,
37
+ ref: 'Supplier'
38
+ }
39
+
40
+ }
41
+ );
42
+
43
+ module.exports = mongoose.model('Product', productSchema);
@@ -0,0 +1,34 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const shipmentSchema = new mongoose.Schema(
4
+ {
5
+ shipmentNumber: {
6
+ type: String,
7
+ required: true,
8
+ trim: true,
9
+ unique: true,
10
+ },
11
+ shipmentDate: {
12
+ type: Date,
13
+ required: true,
14
+ },
15
+ shipmentStatus: {
16
+ type: String,
17
+ required: true,
18
+ trim: true,
19
+ },
20
+ destination: {
21
+ type: String,
22
+ required: true,
23
+ trim: true,
24
+ },
25
+ supplier: {
26
+ type: mongoose.Schema.Types.ObjectId,
27
+ ref: 'Supplier',
28
+ required: false,
29
+ },
30
+ },
31
+ { timestamps: true }
32
+ );
33
+
34
+ module.exports = mongoose.model('Shipment', shipmentSchema);