diff --git a/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/controllers/order.js b/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/controllers/order.js
index 7a506d7..a6cb071 100644
--- a/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/controllers/order.js
+++ b/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/controllers/order.js
@@ -3,39 +3,51 @@ const User = require("../model/User")
exports.createOrder = async (req, res) => {
try {
- const { userId, products, totalAmount } = req.body
-
- const user = await User.findById(userId)
-
- if (!user) {
- return res.status(404).json({ message: "User not found" })
- }
-
- // Check if the user is an admin
- if (user.isAdmin) {
- return res
- .status(403)
- .json({ message: "Admins cannot create orders" })
- }
-
- const newOrder = {
- products: products,
- totalAmount: totalAmount,
- purchaseOn: Date.now(),
- }
-
- user.orderedProducts.push(newOrder)
- await user.save()
-
- res.status(201).json({
- message: "Order created successfully",
- order: newOrder,
- })
+ const {
+ userId,
+ products,
+ totalAmount,
+ shippingAddress,
+ personalInfo,
+ shippingMethod,
+ paymentMethod,
+ // Add other details as needed
+ } = req.body;
+
+ const user = await User.findById(userId);
+
+ if (!user) {
+ return res.status(404).json({ message: "User not found" });
+ }
+
+ // Check if the user is an admin
+ if (user.isAdmin) {
+ return res.status(403).json({ message: "Admins cannot create orders" });
+ }
+
+ const newOrder = {
+ products: products,
+ totalAmount: totalAmount,
+ shippingAddress: shippingAddress,
+ personalInfo: personalInfo,
+ shippingMethod: shippingMethod,
+ paymentMethod: paymentMethod,
+ // Add other details to newOrder as needed
+ purchaseOn: Date.now(),
+ };
+
+ user.orderedProducts.push(newOrder);
+ await user.save();
+
+ res.status(201).json({
+ message: "Order created successfully",
+ order: newOrder,
+ });
} catch (error) {
- console.error(error)
- res.status(500).json({ message: "Internal Server Error" })
+ console.error(error);
+ res.status(500).json({ message: "Internal Server Error" });
}
-}
+ };
// Retrieve authenticated user's orders
exports.getOrders = async (req, res) => {
diff --git a/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/controllers/user.js b/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/controllers/user.js
index 750a611..95e2518 100644
--- a/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/controllers/user.js
+++ b/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/controllers/user.js
@@ -532,4 +532,3 @@ exports.updateAddress = async (req, res) => {
res.status(500).json({ message: 'Internal server error' });
}
};
-
\ No newline at end of file
diff --git a/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/model/ShippingMethod.js b/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/model/ShippingMethod.js
new file mode 100644
index 0000000..078de34
--- /dev/null
+++ b/individual/fullstack/fullstack/capstone-3 added/backend/csp2-reciproco/model/ShippingMethod.js
@@ -0,0 +1,13 @@
+// models/ShippingMethod.js
+
+const mongoose = require('mongoose');
+
+const shippingMethodSchema = new mongoose.Schema({
+ name: { type: String, required: true },
+ description: { type: String, required: true },
+ // Add other fields as needed
+});
+
+const ShippingMethod = mongoose.model('ShippingMethod', shippingMethodSchema);
+
+module.exports = ShippingMethod;
diff --git a/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/App.js b/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/App.js
index 6caa485..d8cfd6a 100644
--- a/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/App.js
+++ b/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/App.js
@@ -18,6 +18,7 @@ import UpdateProfile from './components/UpdateProfile';
import AdminDashboard from './pages/AdminDashboard';
import ProductPage from './pages/ProductPage';
import CheckoutPage from './pages/CheckoutPage';
+import OrderConfirmationPage from './pages/OrderConfirmationPage';
import Error from './pages/Error'; // Import the NotFound component
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
@@ -108,6 +109,7 @@ function App() {
} />
} />
} />
+ } />
{/* Catch-all route that redirects to the home page */}
} />
diff --git a/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/components/AddressCollapse.js b/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/components/AddressCollapse.js
new file mode 100644
index 0000000..889bad9
--- /dev/null
+++ b/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/components/AddressCollapse.js
@@ -0,0 +1,134 @@
+import React from "react";
+import { Button, Collapse, Col, Row, Table, Form } from "react-bootstrap";
+import AddressForm from "./AddressForm"; // Assuming the path is correct
+
+const AddressCollapse = ({
+ addressOpen,
+ setAddressOpen,
+ isCustomerLoggedIn,
+ selectedAddress,
+ setSelectedAddress,
+ handleContinueAddress,
+ addAddressFormOpen,
+ setAddAddressFormOpen,
+ addressFormError,
+ addresses,
+ handleDeleteAddress,
+}) => {
+ const handleAddressSelect = (addressId) => {
+ // Update the selectedAddressId
+ setSelectedAddress(addressId);
+
+ // If you also want to update the selectedAddress object, find the corresponding address
+ const selected = addresses.find((address) => address._id === addressId);
+ setSelectedAddress(selected);
+ };
+
+ return (
+
+
+
+ 2. Address
+
+
+
+
+
+ {isCustomerLoggedIn ? (
+
+
+ The selected address will be used both as your personal address
+ (for invoice) and as your delivery address.
+
+
+ {/* Left column - Add New Address Form Dropdown */}
+
+ {addAddressFormOpen && (
+
+ )}
+
+
+
+
+
+
+ {/* Right column - My Addresses from addressForm */}
+ {addresses && addresses.length > 0 ? (
+
+
+
+ My Addresses |
+ Actions |
+
+
+
+ {addresses.map((address, index) => (
+
+
+
+
+ handleAddressSelect(address._id)
+ }
+ />
+
+
+ {address.street}, {address.city},{" "}
+ {address.state}, {address.zipCode},{" "}
+ {address.country}
+
+
+ |
+
+
+ |
+
+ ))}
+
+
+ ) : (
+ No existing addresses. Add a new address below.
+ )}
+
+
+ ) : (
+
User not logged in. Log in to view and manage addresses.
+ )}
+
+
+
+ );
+};
+
+export default AddressCollapse;
diff --git a/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/components/AddressForm.js b/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/components/AddressForm.js
index 90e3a00..669414c 100644
--- a/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/components/AddressForm.js
+++ b/individual/fullstack/fullstack/capstone-3 added/frontend/csp3-reciproco/src/components/AddressForm.js
@@ -1,6 +1,5 @@
-import React from 'react';
-import { Form, Button } from 'react-bootstrap';
-
+import React from "react";
+import { Form, Button } from "react-bootstrap";
const AddressForm = ({
selectedAddress,
@@ -8,91 +7,92 @@ const AddressForm = ({
handleContinueAddress,
addressFormError,
}) => {
- const philippineStates = [
- "...",
- "Abra",
- "Agusan del Norte",
- "Agusan del Sur",
- "Aklan",
- "Albay",
- "Antique",
- "Apayao",
- "Aurora",
- "Basilan",
- "Bataan",
- "Batanes",
- "Batangas",
- "Benguet",
- "Biliran",
- "Bohol",
- "Bukidnon",
- "Bulacan",
- "Cagayan",
- "Camarines Norte",
- "Camarines Sur",
- "Camiguin",
- "Capiz",
- "Catanduanes",
- "Cavite",
- "Cebu",
- "Cotabato",
- "Davao de Oro (formerly Compostela Valley)",
- "Davao del Norte",
- "Davao del Sur",
- "Davao Occidental",
- "Davao Oriental",
- "Dinagat Islands",
- "Eastern Samar",
- "Guimaras",
- "Ifugao",
- "Ilocos Norte",
- "Ilocos Sur",
- "Iloilo",
- "Isabela",
- "Kalinga",
- "La Union",
- "Laguna",
- "Lanao del Norte",
- "Lanao del Sur",
- "Leyte",
- "Maguindanao",
- "Marinduque",
- "Masbate",
- "Misamis Occidental",
- "Misamis Oriental",
- "Mountain Province",
- "Negros Occidental",
- "Negros Oriental",
- "Northern Samar",
- "Nueva Ecija",
- "Nueva Vizcaya",
- "Occidental Mindoro",
- "Oriental Mindoro",
- "Palawan",
- "Pampanga",
- "Pangasinan",
- "Quezon",
- "Quirino",
- "Rizal",
- "Romblon",
- "Samar (Western Samar)",
- "Sarangani",
- "Siquijor",
- "Sorsogon",
- "South Cotabato",
- "Southern Leyte",
- "Sultan Kudarat",
- "Sulu",
- "Surigao del Norte",
- "Surigao del Sur",
- "Tarlac",
- "Tawi-Tawi",
- "Zambales",
- "Zamboanga del Norte",
- "Zamboanga del Sur",
- "Zamboanga Sibugay",
- ];
- // Define the array of Philippine states
+ const philippineStates = [
+ "...",
+ "Abra",
+ "Agusan del Norte",
+ "Agusan del Sur",
+ "Aklan",
+ "Albay",
+ "Antique",
+ "Apayao",
+ "Aurora",
+ "Basilan",
+ "Bataan",
+ "Batanes",
+ "Batangas",
+ "Benguet",
+ "Biliran",
+ "Bohol",
+ "Bukidnon",
+ "Bulacan",
+ "Cagayan",
+ "Camarines Norte",
+ "Camarines Sur",
+ "Camiguin",
+ "Capiz",
+ "Catanduanes",
+ "Cavite",
+ "Cebu",
+ "Cotabato",
+ "Davao de Oro (formerly Compostela Valley)",
+ "Davao del Norte",
+ "Davao del Sur",
+ "Davao Occidental",
+ "Davao Oriental",
+ "Dinagat Islands",
+ "Eastern Samar",
+ "Guimaras",
+ "Ifugao",
+ "Ilocos Norte",
+ "Ilocos Sur",
+ "Iloilo",
+ "Isabela",
+ "Kalinga",
+ "La Union",
+ "Laguna",
+ "Lanao del Norte",
+ "Lanao del Sur",
+ "Leyte",
+ "Maguindanao",
+ "Marinduque",
+ "Masbate",
+ "Misamis Occidental",
+ "Misamis Oriental",
+ "Mountain Province",
+ "Negros Occidental",
+ "Negros Oriental",
+ "Northern Samar",
+ "Nueva Ecija",
+ "Nueva Vizcaya",
+ "Occidental Mindoro",
+ "Oriental Mindoro",
+ "Palawan",
+ "Pampanga",
+ "Pangasinan",
+ "Quezon",
+ "Quirino",
+ "Rizal",
+ "Romblon",
+ "Samar (Western Samar)",
+ "Sarangani",
+ "Siquijor",
+ "Sorsogon",
+ "South Cotabato",
+ "Southern Leyte",
+ "Sultan Kudarat",
+ "Sulu",
+ "Surigao del Norte",
+ "Surigao del Sur",
+ "Tarlac",
+ "Tawi-Tawi",
+ "Zambales",
+ "Zamboanga del Norte",
+ "Zamboanga del Sur",
+ "Zamboanga Sibugay",
+ ];
+
+ const countryStates = ["...", "Philippines"];
return (
State
+
Country
-
+
+ setSelectedAddress({
+ ...selectedAddress,
+ country: e.target.value, // Fix: change state to country
+ })
+ }
+ required
+ >
+
+ {countryStates.map((country, index) => (
+
+ ))}
+