web tech project
web tech project
FRONT END
MY-WTTWEBSDITE-APP
APP.JS
import React, { useState } from 'react';
import './App.css';
import './apifront';
function App() {
setIsSigningIn(true);
setIsSigningUp(false);
};
setIsSigningUp(true);
setIsSigningIn(false);
};
setEnteredUsername(username);
setIsAuthenticated(true);
};
setEnteredUsername(username);
setIsAuthenticated(true);
};
setIsSigningIn(false);
setIsSigningUp(false);
setUsername('');
setPassword('');
};
const handleGetStartedClick = () => {
setShowFeaturesPage(true);
};
setShowFeaturesPage(false);
setIsAuthenticated(false);
setUsername('');
setPassword('');
setEnteredUsername('');
};
setShowFeaturesPage(false);
setShowUploadPage(true);
};
setShowFeaturesPage(false);
setShowOutfitPage(true);
};
setShowUploadPage(false);
setShowOutfitPage(false);
setShowFeaturesPage(true);
};
setImage(URL.createObjectURL(file));
};
setCategory(selectedCategory);
};
setColor(e.target.value);
};
setOccasion(selectedOccasion);
};
const item = {
image: image,
category: category,
color: color,
occasion: occasion,
};
setUploadedItems([...uploadedItems, item]);
setImage(null);
setCategory('');
setColor('');
setOccasion('');
};
setSelectedOccasion(occasion);
};
setSelectedColor(e.target.value);
};
);
setIsSidebarVisible(!isSidebarVisible);
};
setIsSidebarVisible(false);
setIsSigningIn(false);
setIsSigningUp(false);
setShowFeaturesPage(false);
setShowUploadPage(false);
setShowOutfitPage(false);
setUsername('');
setPassword('');
setEnteredUsername('');
setIsAuthenticated(false);
};
setIsSidebarVisible(false);
};
if (showOutfitPage) {
return (
<div className="App">
<header className="App-header">
<h1>Select an Outfit</h1>
<h3>Choose an occasion:</h3>
{selectedOccasion && (
<div>
<h3>Pick a color:</h3>
</div>
)}
<div>
<h3>Outfit Options:</h3>
<div className="outfit-options">
<h4>Tops:</h4>
{filteredItems
))}
<h4>Bottoms:</h4>
{filteredItems
))}
<h4>Accessories:</h4>
{filteredItems
))}
</div>
</div>
)}
</header>
</div>
);
if (showUploadPage) {
return (
<div className="App">
<header className="App-header">
{image && (
<div>
<h3>Choose category:</h3>
</div>
)}
{category && (
<div>
</div>
)}
{color && (
<div>
<h3>Select an occasion:</h3>
</div>
)}
</header>
</div>
);
if (showFeaturesPage) {
return (
<div className="App">
<header className="App-header">
<h1>Features</h1>
<div className="feature-list">
<div className="feature">
<h3>Upload</h3>
</div>
<div className="feature">
<h3>Organize</h3>
</div>
<div className="feature">
<h3>Select</h3>
<p>Now, when you need an outfit for any occasion, all you need to do is pick a color and get
options for your top, bottom, and accessories. All you have to do is choose.</p>
</div>
<div className="feature">
<h3>Outfit</h3>
</div>
</div>
<button onClick={handleUploadPageClick}>Upload</button>
<button onClick={handleOutfitPageClick}>Outfit</button>
<button onClick={handleBackToSignInPage}>Back</button>
</header>
</div>
);
return (
<div className="App">
<header className="App-header">
{!isAuthenticated ? (
<div className="auth-buttons">
</div>
):(
<>
<h2>Welcome, {enteredUsername}!</h2>
</>
)}
{(isSigningIn || isSigningUp) && !isAuthenticated && (
<div className="auth-form">
{isSigningIn && (
<>
<input
type="email"
placeholder="Email"
/>
<br />
<input
type="tel"
placeholder="Phone Number"
/>
<br />
</>
)}
<input
type="text"
placeholder="Username"
/>
<br />
<input
type="password"
placeholder="Password"
/>
<br />
</button>
</div>
)}
<button onClick={handleHomeClick}>Home</button>
</div>
</button>
</header>
</div>
);
APP.CSS
body{
background-color : black;
color: white;
margin: 0;
font-family: arial, sans-serif;
}
.App {
text-align: center;
font-family: Arial, sans-serif;
background-color: black;
color: white;
}
.App-header {
padding: 20px;
color: white;
}
.logo {
width: 400px;
height: auto;
}
.auth-buttons {
margin: 20px;
}
button {
margin: 5px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
color: white;
background-color: black; /* Optional: keep button text white on a black background */
border: 1px solid white;
}
.auth-form {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
color: white;
}
.auth-form input {
margin: 5px 0;
padding: 10px;
width: 200px;
font-size: 16px;
color: white;
background-color: black;
border: 1px solid white;
}
.back-button {
margin-top: 10px;
padding: 5px 10px;
font-size: 14px;
cursor: pointer;
color: white;
background-color: black;
border: 1px solid white;
}
.feature-list {
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
margin-top: 20px;
color: white;
}
.feature {
text-align: left;
width: 80%;
max-width: 300px;
color: white;
}
.upload-page {
text-align: center;
padding: 20px;
color: white;
}
.upload-page h1 {
margin-bottom: 20px;
font-size: 24px;
color: white;
}
.upload-page input[type="file"] {
padding: 10px;
font-size: 16px;
margin: 20px;
color: white;
background-color: black;
border: 1px solid white;
}
.uploaded-image {
max-width: 80%;
height: auto;
margin-top: 20px;
}
.upload-page button {
margin-top: 20px;
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
color: white;
background-color: black;
border: 1px solid white;
}
.upload-page .category-buttons {
margin-top: 20px;
display: flex;
justify-content: center;
gap: 10px;
}
.upload-page .category-buttons p {
font-size: 16px;
margin-top: 10px;
color: white;
}
APIFRONT.JS
// src/apifront.js
import axios from 'axios';
Package.JSON
{
"name": "my-wttwebsdite-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"proxy": "http://localhost:5000"
}
Backend
Models
// models/Item.js
const mongoose = require('mongoose');
});
Routes
const express = require('express');
try {
await newItem.save();
res.status(201).json(newItem);
} catch (error) {
});
Backindex.js
// GET route to retrieve items based on filters
router.get('/', async (req, res) => {
try {
res.status(200).json(items);
} catch (error) {
});
module.exports = router;
app.use(cors());
app.use(express.json());
// Example route
});
server.js
const express = require('express');
app.use(bodyParser.json());
// Connect to MongoDB
mongoose.connect('mongodb://localhost:27017/fashion-fix-up', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
mongoose.connection.on('connected', () => {
console.log('Connected to MongoDB');
});
category,
color,
occasion,
imageURL,
});
await newItem.save();
} catch (error) {
});
app.listen(PORT, () => {
});
WEBAPP.JS
const express = require('express');
// Connect to MongoDB
mongoose.connect('mongodb://localhost:27017/fashion-fix-up', {
useNewUrlParser: true,
useUnifiedTopology: true,
});
mongoose.connection.on('connected', () => {
console.log('Connected to MongoDB');
});
try {
category,
color,
occasion,
imageURL,
});
await newItem.save();
} catch (error) {
});
// Start the server
app.listen(PORT, () => {
});
Mongo shell
use fashion-fixup;
db.items.insertOne({
category: "Top",
color: "Black",
occasion: "Casual"
imageURL: "/path/to/image.jpg"
});