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

Jeff feature branch #23

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a8f33d4
added some comments all around
JReyCodes Nov 15, 2023
6caa8c3
tried to access the AWS s3 buckets and the PostgreSQL db
JReyCodes Nov 15, 2023
ef5d621
Merge pull request #1 from Chic-Cat-Snake/JReyCodes/AwsSetup
JReyCodes Nov 15, 2023
67865b7
fixed login and home paths
JadeChan03 Nov 15, 2023
7ebee44
updating main branch
JadeChan03 Nov 15, 2023
0de0373
Merge pull request #2 from Chic-Cat-Snake/jade-frontend
JadeChan03 Nov 15, 2023
fdd2129
add category checkboxes to upload outfit
lwu15 Nov 15, 2023
25344fd
Merge pull request #3 from Chic-Cat-Snake/lwu/new-feature
lwu15 Nov 15, 2023
8f02cf6
fixed the issues with the aws access denied issues and also the prost…
JReyCodes Nov 15, 2023
5c08a15
Merge pull request #4 from Chic-Cat-Snake/JReyCodes/AwsSetup
JReyCodes Nov 15, 2023
8055306
"added testing files"
jgotts89 Nov 15, 2023
53a4baf
Merge branch 'main' of https://github.com/Chic-Cat-Snake/Chic into Je…
jgotts89 Nov 15, 2023
23c4a95
Merge pull request #5 from Chic-Cat-Snake/Jeff-feature-branch
JReyCodes Nov 15, 2023
01c85ac
Add filtering and displaying of category tags
lwu15 Nov 15, 2023
475c932
fixed the issues with login not wokring correctly
JReyCodes Nov 15, 2023
ab87767
finished fixing all the merge conflicts
JReyCodes Nov 15, 2023
90d5b51
Merge pull request #6 from Chic-Cat-Snake/JReyCodes/AwsSetup
JReyCodes Nov 15, 2023
fb2097a
redesigned login/signup page, migrated in-line css, reorganised css f…
JadeChan03 Nov 15, 2023
8f43a2f
Merge branch 'main' of https://github.com/Chic-Cat-Snake/Chic into ja…
JadeChan03 Nov 15, 2023
88a1dc3
deleted signup styles sheet
JadeChan03 Nov 15, 2023
4bf9e97
Merge pull request #7 from Chic-Cat-Snake/jade-frontend
JadeChan03 Nov 15, 2023
e5aa6dc
fixed login/signup access
JadeChan03 Nov 16, 2023
f784705
Merge branch 'main' of https://github.com/Chic-Cat-Snake/Chic into ja…
JadeChan03 Nov 16, 2023
87bd3da
Merge pull request #8 from Chic-Cat-Snake/jade-frontend
JadeChan03 Nov 16, 2023
6f44ddd
pushed the updated working version of the app
JReyCodes Nov 16, 2023
51c3ad1
Merge pull request #9 from Chic-Cat-Snake/JReyCodes/AwsSetup
JReyCodes Nov 16, 2023
dc385ed
update outfits routes
lwu15 Nov 16, 2023
f4541bb
save edits
lwu15 Nov 16, 2023
28f8a46
redesigned dashboard
JadeChan03 Nov 16, 2023
91f808e
Merge pull request #10 from Chic-Cat-Snake/jade-frontend
JadeChan03 Nov 16, 2023
071ee63
"set up some testing files"
jgotts89 Nov 16, 2023
a410ce7
Merge branch 'main' of https://github.com/Chic-Cat-Snake/Chic into Je…
jgotts89 Nov 16, 2023
694ab9a
fix filtering and add display category tags
lwu15 Nov 16, 2023
5a0adf0
Merge pull request #11 from Chic-Cat-Snake/Jeff-feature-branch
JReyCodes Nov 16, 2023
a7f3a97
add pseudocode for AllOutfits
lwu15 Nov 16, 2023
6e527bb
Merge pull request #12 from Chic-Cat-Snake/lwu/new-feature
lwu15 Nov 16, 2023
ed8395d
added a feature to give you a random outfit based upon the filters yo…
JReyCodes Nov 16, 2023
cfdc3c9
Merge pull request #13 from Chic-Cat-Snake/JReyCodes/AwsSetup
JReyCodes Nov 16, 2023
bfdf259
redesigned alloutfits, added global font and logo animation
JadeChan03 Nov 16, 2023
4310340
redesigned alloutfits, added logo animation and global font
JadeChan03 Nov 16, 2023
142a6e6
Merge pull request #14 from Chic-Cat-Snake/jade-frontend
JadeChan03 Nov 16, 2023
6e09727
"test of index.js"
jgotts89 Nov 16, 2023
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
33 changes: 18 additions & 15 deletions client/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,28 @@ const App = () => {

console.log('this is SSID', SSID);
return (

<Router>
<Link to="/" style={{ margin: 10 }}>
Home
</Link>
<Link to="/signup" style={{ margin: 10 }}>
Signup
</Link>
<Link to="/login" style={{ margin: 10 }}>
Login
</Link>
<Link to="/dashboard" style={{ margin: 10 }}>
Dashboard
</Link>
<Link to="/alloutfits" style={{ margin: 10 }}>
All Outfits
</Link>
<div id="tabs">
<Link to="/signup" id='link'>
SIGN UP
</Link>
<Link to="/login" id='link'>
LOG IN
</Link>
<Link to="/dashboard" id='link'>
DASHBOARD
</Link>
<Link to="/alloutfits" id='link'>
ALL OUTFITS
</Link>
</div>
<Routes>
{/** Look into why they have the setSSID to SetSSID
Potentially is prop drilling this function down*/}
<Route path="/" element={<Login setSSID={setSSID} />} />
<Route path="/signup" element={<Signup setSSID={setSSID} />} />
<Route path="/login" element={<Login setSSID={setSSID} />} />
<Route path="/dashboard" element={<Dashboard SSID={SSID} />} />
<Route path="/alloutfits" element={<AllOutfits SSID={SSID} />} />
</Routes>
Expand Down
167 changes: 141 additions & 26 deletions client/components/AllOutfits.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,164 @@ import Outfit from './Outfit.jsx';
import '../styles/style.css';

const AllOutfits = ({ SSID }) => {
const [outfitImage, setOutfitImage] = useState([]);
const [outfitDes, setOutfitDes] = useState([]);
const [data, setData] = useState([]);
const [outfitsArray, setOutfitsArray] = useState([]);
const [categories, setCategories] = useState({
casual: false,
smartCasual: false,
businessAttire: false,
formal: false,
athleisure: false,
});
const [randomOutift,setRandomOutfit] = useState()
const [allOutfits,setAllOutfits] = useState(true)

useEffect(() => {
fetch(`/outfits/alloutfits`, {
// initial fetching of all outfit data
const fetchData = () => {
fetch(`/outfits/alloutfits`, {
method: 'POST',
headers: {
'Content-type': 'Application/JSON',
},
body: JSON.stringify({
SSID: SSID,
}),
})
.then((initialRes) => initialRes.json())
.then((initialData) => setData(initialData.rows))
.catch((error) => {
console.error('Error fetching initial data:', error);
});
};

fetchData();
}, []);

// update array that stores outfit data when data changes
useEffect(() => {
setOutfitsArray(data.map((outfit, index) => <Outfit key={outfit.index} outfitData={outfit} />));
}, [data]);

const getRandomOutift = () => {
const copy = outfitsArray.slice()
setRandomOutfit(copy[Math.floor(Math.random() * copy.length)])
allOutfits ? setAllOutfits(false):setAllOutfits(true)
}

// function to handle updating of checkboxes
const handleCheckChange = (event) => {
const { name, value, checked } = event.target;
if (name === 'categories') {
setCategories((prevCategories) => ({
...prevCategories,
[value]: checked,
}));
}
};

// filter the keys of the categories so we only send the selected categories
const selectedCategories = Object.keys(categories).filter((key) => categories[key]);

// function to handle the filtered outfit form submission
const handleSubmit = (event) => {
event.preventDefault();
fetch(`/outfits/filteredoutfits`, {
method: 'POST',
headers: {
'Content-type': 'Application/JSON',
},
body: JSON.stringify({
SSID: SSID,
categories: selectedCategories,
}),
})
.then((res) => res.json())
.then((res) => {
console.log('these are all outfits from frontend', res.rows);
const outfitImageArr = [];
const outfitDesArr = [];
for (let i = 0; i < res.rows.length; i++) {
outfitImageArr.push(res.rows[i]['aws_image']);
outfitDesArr.push(res.rows[i]['description']);
if (!res.ok) {
throw new Error('Network response was not ok');
}
setOutfitImage(outfitImageArr);
setOutfitDes(outfitDesArr);
return res.json();
})
.then((res) => {
console.log('Filtered outfits from frontend:', res.rows);
setData(res.rows);
})
.catch((error) => {
console.log('An error occurred while getting the outfits data', error);
});
}, []);
// add image and description to outfitdata

console.log('outfitImage:', outfitImage);
console.log('outfitDes:', outfitDes);

const array = [];
for (let i = 0; i < outfitImage.length; i++) {
array.push(
<Outfit outfitImage={outfitImage[i]} outfitDes={outfitDes[i]} />
);
}
};

return (
<div className="outfitsContainer">
<div id="outfitBox">{array}</div>
<h2 className='header'>CATEGORIES</h2>
<form className='allOutfitsForm'onSubmit={handleSubmit}>
<div className='checkboxDiv'>
<div>
<input
type="checkbox"
id="casual"
value="casual"
name="categories"
checked={categories.casual}
onChange={handleCheckChange}
/>
<label htmlFor="casual">Casual</label>
</div>

<div>
<input
type="checkbox"
id="smartCasual"
value="smartCasual"
name="categories"
checked={categories.smartCasual}
onChange={handleCheckChange}
/>
<label htmlFor="smartCasual">Smart Casual</label>
</div>

<div>
<input
type="checkbox"
id="businessAttire"
value="businessAttire"
name="categories"
checked={categories.businessAttire}
onChange={handleCheckChange}
/>
<label htmlFor="businessAttire">Business Attire</label>
</div>

<div>
<input
type="checkbox"
id="formal"
value="formal"
name="categories"
checked={categories.formal}
onChange={handleCheckChange}
/>
<label htmlFor="formal">Formal</label>
</div>

<div>
<input
type="checkbox"
id="athleisure"
value="athleisure"
name="categories"
checked={categories.athleisure}
onChange={handleCheckChange}
/>
<label htmlFor="athleisure">Athleisure</label>
</div>
</div>
<button className='outfitsButton' type="submit">GET RESULTS</button>
</form>
<div id="outfitBox">{allOutfits ? outfitsArray:randomOutift}</div>
<button onClick={getRandomOutift}>DONT KNOW WHAT TO WEAR CLICK HERE</button>
</div>
);
};

export default AllOutfits;
export default AllOutfits;
4 changes: 2 additions & 2 deletions client/components/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import UploadOutfit from './UploadOutfit.jsx';
const Dashboard = ({ SSID }) => {
return (
<div>
<h2>Welcome to the Dashboard</h2>
<UploadOutfit SSID={SSID} />
</div>
);
};
export default Dashboard;

export default Dashboard;
11 changes: 0 additions & 11 deletions client/components/Home.jsx

This file was deleted.

50 changes: 26 additions & 24 deletions client/components/Login.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react'
import '../styles/login.css'
import '../styles/login.css'
import { Link, useNavigate } from 'react-router-dom';



const Login = ( {setSSID} ) => {
const Login = ({ setSSID }) => {

const navigator = useNavigate()

let loginHandler = () => {

let username = document.querySelector('#loginUsername').value;
let username = document.querySelector('#loginUsername').value;
let password = document.querySelector('#loginPassword').value;

const userInfo = {
Expand All @@ -21,34 +21,36 @@ const Login = ( {setSSID} ) => {
fetch('/auth/login', {
method: 'POST',
headers: {
'Content-type' : 'Application/JSON'
'Content-type': 'Application/JSON'
},
body: JSON.stringify(userInfo)
})
.then((res) => res.json())
.then((res) => {
if(res.err){
alert(res.err)
}
else{
setSSID(res)
navigator('/dashboard')
}
})
.then((res) => res.json())
.then((res) => {
if (res.err) {
alert(res.err)
}
else {
setSSID(res)
navigator('/dashboard')
}
})
};

return (
<>
<div id='loginBox'>
<img id='logo' src='https://www.wrkmode.com/images/id/logo_chic.gif'></img>
<input id='loginUsername' placeholder='username'></input>
<input id='loginPassword' placeholder='password'></input>
<button id='loginButton'onClick= {loginHandler}>Login</button>
<Link id='signupLink' to='/signup'>
Click here to Signup
return (
<div id='inputBox'>
<div className='logo'>
<img className='logoPic' src="https://drive.google.com/uc?export=view&id=1v0179NE5pCP1n3ZWIv51ij3ww4cEeBpV" width="200">
</img>
<text id='chic'>HIC</text>
</div>
<input id='loginUsername' className='input' placeholder='USERNAME'></input>
<input id='loginPassword' className='input' placeholder='PASSWORD'></input>
<button id='signupLoginButton' onClick={loginHandler}>LOGIN</button>
<Link id='userLink' to='/signup'>
CLICK HERE TO SIGNUP
</Link>
</div>
</>
)
}

Expand Down
41 changes: 30 additions & 11 deletions client/components/Outfit.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
import React from 'react'

const Outfit = ({ outfitImage, outfitDes }) => {
return(
<div id='outfit'>
<div className='imgContainer'>
<img src={'outfits/uploads/' + outfitImage} style={{maxWidth:'300px'}}alt="outfitImage prop" />
</div>
<h3>{outfitDes}</h3>
import React from 'react';

const Outfit = (props) => {
const { aws_image, description, casual, smart_casual, business_attire, formal, athleisure } = props.outfitData;

const categoryNames = [];
if (casual) categoryNames.push('Casual');
if (smart_casual) categoryNames.push('Smart Casual');
if (business_attire) categoryNames.push('Business Attire');
if (formal) categoryNames.push('Formal');
if (athleisure) categoryNames.push('Athleisure');

return (
<div id='outfit'>
<div className='imgContainer'>
<img src={'outfits/uploads/' + aws_image} style={{ maxWidth: '300px' }} alt="outfitImage prop" />
</div>
<h3>{description}</h3>
{categoryNames.length > 0 && (
<div>
<h4>Categories:</h4>
{categoryNames.map((category, idx) => (
<div key={idx}>
{category}
</div>
))}
</div>
)
}
)}
</div>
);
};

export default Outfit;
Loading