diff --git a/back-end/db.js b/back-end/db.js index 86c5a82..4a174fe 100644 --- a/back-end/db.js +++ b/back-end/db.js @@ -59,11 +59,7 @@ const User = mongoose.model("User", username_password); const clothing_item = new mongoose.Schema({ - // id: { - // type: Number, - // required: true, - // unique: true - // }, + articleType: { type: String, required: true @@ -110,17 +106,7 @@ const outfitSchema = new mongoose.Schema({ type: String, required: false }, - items: [{ - itemName: { - type: String, - required: true - }, - itemType: { - type: String, - required: true - }, - _id: false // Prevents Mongoose from creating an _id for each subdocument - }], + Clothes:[clothing_item], user: { type: String, required: true diff --git a/back-end/public/accessories/accessory_1.jpg b/back-end/public/accessories/accessory_1.jpg deleted file mode 100644 index 507a7d4..0000000 Binary files a/back-end/public/accessories/accessory_1.jpg and /dev/null differ diff --git a/back-end/public/accessories/accessory_2.jpg b/back-end/public/accessories/accessory_2.jpg deleted file mode 100644 index d3a857e..0000000 Binary files a/back-end/public/accessories/accessory_2.jpg and /dev/null differ diff --git a/back-end/public/accessories/accessory_3.webp b/back-end/public/accessories/accessory_3.webp deleted file mode 100644 index 9dd6607..0000000 Binary files a/back-end/public/accessories/accessory_3.webp and /dev/null differ diff --git a/back-end/public/accessories/picture-1713464929562-246352166.avif b/back-end/public/accessories/picture-1713464929562-246352166.avif new file mode 100644 index 0000000..d706594 Binary files /dev/null and b/back-end/public/accessories/picture-1713464929562-246352166.avif differ diff --git a/back-end/public/accessories/picture-1713465745884-155437155.avif b/back-end/public/accessories/picture-1713465745884-155437155.avif new file mode 100644 index 0000000..20c4cc3 Binary files /dev/null and b/back-end/public/accessories/picture-1713465745884-155437155.avif differ diff --git a/back-end/public/accessories/picture-1713465806325-455340114.jpeg b/back-end/public/accessories/picture-1713465806325-455340114.jpeg new file mode 100644 index 0000000..3d5627d Binary files /dev/null and b/back-end/public/accessories/picture-1713465806325-455340114.jpeg differ diff --git a/back-end/public/jackets/jacket_1.jpg b/back-end/public/jackets/jacket_1.jpg deleted file mode 100644 index 9837836..0000000 Binary files a/back-end/public/jackets/jacket_1.jpg and /dev/null differ diff --git a/back-end/public/jackets/jacket_2.jpg b/back-end/public/jackets/jacket_2.jpg deleted file mode 100644 index 9b76139..0000000 Binary files a/back-end/public/jackets/jacket_2.jpg and /dev/null differ diff --git a/back-end/public/jackets/jacket_3.webp b/back-end/public/jackets/jacket_3.webp deleted file mode 100644 index 472b6f8..0000000 Binary files a/back-end/public/jackets/jacket_3.webp and /dev/null differ diff --git a/back-end/public/jackets/picture-1713467565526-125523491.webp b/back-end/public/jackets/picture-1713467565526-125523491.webp new file mode 100644 index 0000000..a85d518 Binary files /dev/null and b/back-end/public/jackets/picture-1713467565526-125523491.webp differ diff --git a/back-end/public/jackets/picture-1713467914017-103860588.webp b/back-end/public/jackets/picture-1713467914017-103860588.webp new file mode 100644 index 0000000..0751fd6 Binary files /dev/null and b/back-end/public/jackets/picture-1713467914017-103860588.webp differ diff --git a/back-end/public/pants/brown_pants.webp b/back-end/public/pants/brown_pants.webp deleted file mode 100644 index 52d0000..0000000 Binary files a/back-end/public/pants/brown_pants.webp and /dev/null differ diff --git a/back-end/public/pants/comfy.webp b/back-end/public/pants/comfy.webp deleted file mode 100644 index 3a2c0f9..0000000 Binary files a/back-end/public/pants/comfy.webp and /dev/null differ diff --git a/back-end/public/pants/extra_pants.jpg b/back-end/public/pants/extra_pants.jpg deleted file mode 100644 index 727748e..0000000 Binary files a/back-end/public/pants/extra_pants.jpg and /dev/null differ diff --git a/back-end/public/pants/picture-1713464820924-233174839.webp b/back-end/public/pants/picture-1713464820924-233174839.webp new file mode 100644 index 0000000..9bc8d43 Binary files /dev/null and b/back-end/public/pants/picture-1713464820924-233174839.webp differ diff --git a/back-end/public/shirts/casual_shirt.webp b/back-end/public/shirts/casual_shirt.webp deleted file mode 100644 index 5c295e2..0000000 Binary files a/back-end/public/shirts/casual_shirt.webp and /dev/null differ diff --git a/back-end/public/shirts/favorite_shirt.webp b/back-end/public/shirts/favorite_shirt.webp deleted file mode 100644 index c57ef22..0000000 Binary files a/back-end/public/shirts/favorite_shirt.webp and /dev/null differ diff --git a/back-end/public/shirts/formal_shirt.webp b/back-end/public/shirts/formal_shirt.webp deleted file mode 100644 index a6f7e76..0000000 Binary files a/back-end/public/shirts/formal_shirt.webp and /dev/null differ diff --git a/back-end/public/shoes/picture-1713468003891-979968757.png b/back-end/public/shoes/picture-1713468003891-979968757.png new file mode 100644 index 0000000..2bf2f61 Binary files /dev/null and b/back-end/public/shoes/picture-1713468003891-979968757.png differ diff --git a/back-end/public/shoes/picture-1713468080594-655330810.webp b/back-end/public/shoes/picture-1713468080594-655330810.webp new file mode 100644 index 0000000..411cf66 Binary files /dev/null and b/back-end/public/shoes/picture-1713468080594-655330810.webp differ diff --git a/back-end/public/shoes/picture-1713468164664-72153367.avif b/back-end/public/shoes/picture-1713468164664-72153367.avif new file mode 100644 index 0000000..58cc32c Binary files /dev/null and b/back-end/public/shoes/picture-1713468164664-72153367.avif differ diff --git a/back-end/public/shoes/shoes_1.avif b/back-end/public/shoes/shoes_1.avif deleted file mode 100644 index 5870753..0000000 Binary files a/back-end/public/shoes/shoes_1.avif and /dev/null differ diff --git a/back-end/public/shoes/shoes_2.webp b/back-end/public/shoes/shoes_2.webp deleted file mode 100644 index 4034148..0000000 Binary files a/back-end/public/shoes/shoes_2.webp and /dev/null differ diff --git a/back-end/public/shoes/shoes_3.webp b/back-end/public/shoes/shoes_3.webp deleted file mode 100644 index 0d5490d..0000000 Binary files a/back-end/public/shoes/shoes_3.webp and /dev/null differ diff --git a/back-end/public/skirts/picture-1713464181007-815048501.jpeg b/back-end/public/skirts/picture-1713464181007-815048501.jpeg new file mode 100644 index 0000000..b3ccff8 Binary files /dev/null and b/back-end/public/skirts/picture-1713464181007-815048501.jpeg differ diff --git a/back-end/public/skirts/picture-1713464501973-298833668.webp b/back-end/public/skirts/picture-1713464501973-298833668.webp new file mode 100644 index 0000000..486c16a Binary files /dev/null and b/back-end/public/skirts/picture-1713464501973-298833668.webp differ diff --git a/back-end/public/skirts/picture-1713464662716-687115932.webp b/back-end/public/skirts/picture-1713464662716-687115932.webp new file mode 100644 index 0000000..fd99f5b Binary files /dev/null and b/back-end/public/skirts/picture-1713464662716-687115932.webp differ diff --git a/back-end/public/skirts/skirt_1.webp b/back-end/public/skirts/skirt_1.webp deleted file mode 100644 index 3d674ac..0000000 Binary files a/back-end/public/skirts/skirt_1.webp and /dev/null differ diff --git a/back-end/public/skirts/skirt_2.webp b/back-end/public/skirts/skirt_2.webp deleted file mode 100644 index 430cca5..0000000 Binary files a/back-end/public/skirts/skirt_2.webp and /dev/null differ diff --git a/back-end/public/skirts/skirt_3.webp b/back-end/public/skirts/skirt_3.webp deleted file mode 100644 index 144febe..0000000 Binary files a/back-end/public/skirts/skirt_3.webp and /dev/null differ diff --git a/back-end/server.js b/back-end/server.js index f93e5e8..33338f7 100644 --- a/back-end/server.js +++ b/back-end/server.js @@ -8,293 +8,11 @@ import path from 'path'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); import models from './db.js'; -const {User, Clothes } = models; +const {User, Clothes,Outfit } = models; import auth from './routes/protected-content-routes.js'; // Import your protected routes -let clothcount=18; - -// call express's listen function to start listening to the port -const accounts = [ - { - "username": "tester", - "password": "tester" - }, - { - "username": "example", - "password": "login" - } -]; - -const shirts = [ - { id: 1, - name: 'Casual Shirt', - brand: 'Awesome Brand', - type: 'Casual', - color: 'Blue', - notes: 'Note 1', - img: '/public/shirts/casual_shirt.webp' - }, - { id: 2, - name: 'Formal Shirt', - brand: 'Formal Brand', - type: 'Formal', - color: 'White', - notes: 'Note 2', - img: '/public/shirts/formal_shirt.webp' - }, - { id: 18, - name: 'Favorite Shirt', - brand: 'Awesome Brand', - type: 'Casual', - color: 'Grey', - notes: 'Note 3', - img: '/public/shirts/favorite_shirt.webp' - } -] - -const pants = [ - { id: 3, - name: 'Casual Pants', - brand: 'Awesome Brand', - type: 'Casual', - color:'Orange', - notes: 'Note 1', - img: '/public/pants/brown_pants.webp' - }, - { id: 4, - name: 'Least Favorite Pants', - brand: 'Fake Brand 3', - type: 'Casual', - color: 'Brown', - notes: 'Note 2', - img: '/public/pants/extra_pants.jpg' - }, - { id: 5, - name: 'Favorite Pants', - brand: 'Cool Brand', - type: 'Casual', - color: 'Grey', - notes: 'Note 3', - img: '/public/pants/comfy.webp' - } -] - -const skirts = [ - { id: 6, - name: 'Best Dress', - brand: 'Awesome Brand', - type: 'Formal', - color: 'Emerald Green', - notes: 'Note 1', - img: '/public/skirts/skirt_1.webp' - }, - { id: 7, - name: 'Least Favorite Dress', - brand: 'Fake Brand 170', - type: 'Formal', - color: 'Blue', - notes: 'Note 2', - img: '/public/skirts/skirt_2.webp' - }, - { id: 8, - name: '2nd Favorite Dress', - brand: 'Cool Brand', - type: 'Formal', - color: 'Pink', - notes: 'Note 3', - img: '/public/skirts/skirt_3.webp' - } -] - -const jackets = [ - { id: 9, - name: 'Ugly Jacket', - brand: 'Awful Brand', - type: 'Casual', - color: 'Green', - notes: 'Note 1', - img: '/public/jackets/jacket_1.jpg' - }, - { - id: 10, - name: 'Coolest Jacket', - brand: 'Fake Brand 170', - type: 'Formal', - color: 'White', - notes: 'Note 2', - img: '/public/jackets/jacket_2.jpg' - }, - { id: 11, - name: 'Okay Jacket', - brand: 'Cool Brand', - type: 'Casual', - color: 'Blue', - notes: 'Note 3', - img: '/public/jackets/jacket_3.webp' - } -] - -const shoes = [ - { id: 12, - name: 'Nice Shoes', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Black', - notes: 'Note 1', - img: '/public/shoes/shoes_1.avif' - }, - { id: 13, - name: 'Decent Shoes', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Black', - notes: 'Note 2', - img: '/public/shoes/shoes_2.webp' - }, - { id: 14, - name: 'Okay Shoes', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Grey', - notes: 'Note 3', - img: '/public/shoes/shoes_3.webp' - } -] - -const accessories = [ - { id: 15, - name: 'Most Expensive', - brand: 'Cheap-O', - type: 'Formal', - color: 'Gold', - notes: 'Note 1', - img: '/public/accessories/accessory_1.jpg' - }, - { id: 16, - name: 'Best Accessory', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Black', - notes: 'Note 2', - img: '/public/accessories/accessory_2.jpg' - }, - { id: 17, - name: 'Pretty Cool', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Silver', - notes: 'Note 3', - img: '/public/accessories/accessory_3.webp' - } -] - -const outfits = [ - { - outfitName: 'Business Casual Look', - notes: 'A comfortable yet professional look for everyday business.', - items: [ - { id:2, - name: 'Formal Shirt', - brand: 'Formal Brand', - type: 'Formal', - color: 'White', - img: '/public/shirts/formal_shirt.webp', - }, - { id:5, - name: 'Favorite Pants', - brand: 'Cool Brand', - type: 'Casual', - color: 'Grey', - img: '/public/pants/comfy.webp', - }, - { id: 13, - name: 'Decent Shoes', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Black', - img: '/public/shoes/shoes_2.webp', - }, - { id: 16, - name: 'Best Accessory', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Black', - img: '/public/accessories/accessory_2.jpg', - } - ], - }, - { - outfitName: 'Summer Vibes', - notes: 'Perfect for the beach or a sunny day in the park.', - items: [ - { id: 1, - name: 'Casual Shirt', - brand: 'Awesome Brand', - type: 'Casual', - color: 'Blue', - img: '/public/shirts/casual_shirt.webp', - }, - { id: 3, - name: 'Casual Pants', - brand: 'Awesome Brand', - type: 'Casual', - color: 'Orange', - img: '/public/pants/brown_pants.webp', - }, - { id:12, - name: 'Nice Shoes', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Black', - img: '/public/shoes/shoes_1.avif', - }, - { id: 17, - name: 'Pretty Cool', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Silver', - img: '/public/accessories/accessory_3.webp', - } - ], - }, - { - outfitName: 'Evening Elegance', - notes: 'Elegant attire for dinner parties or a night out.', - items: [ - { id: 8, - name: '2nd Favorite Dress', - brand: 'Cool Brand', - type: 'Formal', - color: 'Pink', - img: '/public/skirts/skirt_3.webp', - }, - { id:10, - name: 'Coolest Jacket', - brand: 'Fake Brand 170', - type: 'Formal', - color: 'White', - img: '/public/jackets/jacket_2.jpg', - }, - { id:14, - name: 'Okay Shoes', - brand: 'Definitely Awesome', - type: 'Casual', - color: 'Grey', - img: '/public/shoes/shoes_3.webp', - }, - { id:15, - name: 'Most Expensive', - brand: 'Cheap-O', - type: 'Formal', - color: 'Gold', - img: '/public/accessories/accessory_1.jpg', - } - ], - }, -]; - server.post('/login', async (req,res) => { const u = req.body.username; @@ -714,17 +432,27 @@ server.post('/additem', auth, upload.single('picture'), async(req, res) => { // POST route to save a new outfit -server.post('/generator', (req, res) => { - const { outfitName, items } = req.body; - if (!outfitName || !items || items.length === 0) { - return res.status(400).json({ message: 'Outfit name and items are required.' }); +server.post('/generator', auth, async(req, res) => { + try { + const { outfitName, outfitNotes, items } = req.body; + const newOutfit = new Outfit({ + outfitName:req.body.outfitName, + outfitNotes:req.body.outfitNotes, + Clothes:req.body.items, + user: req.user.id, + }); + + if (!outfitName || !items || items.length === 0) { + return res.status(400).json({ message: 'Outfit name and items are required.' }); + } + await newOutfit.save(); + res.status(201).json({ message: 'Outfit saved successfully' }); + + } catch ( error ) { + res.status(500).json({ message: 'Failed to add outfit', error: error }); } - outfits.push({ - outfitName, - notes:'', - items - }); - res.status(201).json({ message: 'Outfit saved successfully' }); + + }); server.post('/random', (req, res) => { diff --git a/front-end/src/screens/AddItem.js b/front-end/src/screens/AddItem.js index 7d9e81d..0e91ebb 100644 --- a/front-end/src/screens/AddItem.js +++ b/front-end/src/screens/AddItem.js @@ -139,7 +139,7 @@ const AddItem = () => { required /> - + { id="picture" name="picture" onChange={handleChange} + required /> diff --git a/front-end/src/screens/Generator.js b/front-end/src/screens/Generator.js index 9f3efa7..bd3d827 100644 --- a/front-end/src/screens/Generator.js +++ b/front-end/src/screens/Generator.js @@ -3,12 +3,13 @@ import axios from 'axios'; import { Link } from 'react-router-dom'; import '../styles/Generator.css'; // Ensure you have the corresponding CSS file import OverlayMenu from '../components/OverlayMenu'; -import Footer from '../components/Footer'; + const Generator = () => { const [allItems, setAllItems] = useState([]); const [selectedItems, setSelectedItems] = useState([]); const [outfitName, setOutfitName] = useState(''); + const [outfitNotes, setOutfitNotes] = useState(''); const [error, setError] = useState(null); const [showForm, setShowForm] = useState(false); @@ -16,14 +17,19 @@ const Generator = () => { useEffect(() => { const fetchItems = async () => { try { - // Fetch all items from each category + const token = localStorage.getItem('token'); + const config = { + headers: { + Authorization: `Bearer ${token}` + } + }; const responses = await Promise.all([ - axios.get('http://localhost:3001/shirts'), - axios.get('http://localhost:3001/pants'), - axios.get('http://localhost:3001/skirts'), - axios.get('http://localhost:3001/jackets'), - axios.get('http://localhost:3001/shoes'), - axios.get('http://localhost:3001/accessories'), + axios.get('http://localhost:3001/shirts', config), + axios.get('http://localhost:3001/pants', config), + axios.get('http://localhost:3001/skirts', config), + axios.get('http://localhost:3001/jackets', config), + axios.get('http://localhost:3001/shoes', config), + axios.get('http://localhost:3001/accessories', config), ]); const combinedItems = responses.flatMap(response => response.data); @@ -66,19 +72,29 @@ const Generator = () => { const handleOutfitNameChange = (e) => { setOutfitName(e.target.value); }; - + const handleOutfitNotesChange = (e) => { + setOutfitNotes(e.target.value); + }; // Handler for saving the outfit const handleSaveOutfit = async (e) => { e.preventDefault(); try { - const itemsToSave = allItems.filter(item => selectedItems.includes(item.id)); + const token = localStorage.getItem('token'); + const config = { + headers: { + Authorization: `Bearer ${token}` + } + }; + const itemsToSave = allItems.filter(item => selectedItems.includes(item._id)); await axios.post('http://localhost:3001/generator', { outfitName, + outfitNotes, items: itemsToSave, - }); + },config); // Reset the selection and outfit name after saving setSelectedItems([]); setOutfitName(''); + setOutfitNotes(''); } catch (e) { console.error('Error saving the outfit:', e); setError(e.message); @@ -98,15 +114,15 @@ const Generator = () => {
{item.name}
+{item.nameItem}
{item.brand}
{item.type}
Brand: {item.brand}
-Type: {item.type}
+Style: {item.type}
Color: {item.color}
Notes: {item.notes}