generated from nyu-software-engineering/generic-mern-stack-project
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yujin Hong
committed
Apr 28, 2024
1 parent
380d934
commit a469ddc
Showing
6 changed files
with
169 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
.Survey { | ||
display: flex; | ||
flex-direction: column; | ||
background-color: #e8e8e8; | ||
height: 150vh; | ||
} | ||
|
||
.survey-question { | ||
background-color: white; | ||
margin-bottom: 1rem; | ||
border-radius: 4px; | ||
} | ||
|
||
.section { | ||
padding: 0rem 0rem 0rem 1rem; | ||
background-color: #BEBEBE; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
label { | ||
display: block; | ||
} | ||
|
||
select, | ||
input[type="number"] { | ||
width: 100%; | ||
padding: 0.75rem; | ||
border: 1px solid #D1D1D1; | ||
border-radius: 4px; | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
button { | ||
background-color: #57068C; | ||
color: white; | ||
padding: 0.75rem 1.5rem; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
button:hover { | ||
background-color: #6D28D9; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import "./UserAnswers.css"; | ||
import Header from "./Header"; | ||
import Button from './Button'; | ||
import axios from 'axios'; | ||
import { set } from 'mongoose'; | ||
|
||
function UserAnswers() { | ||
const navigate = useNavigate(); | ||
const [error, setError] = useState(''); | ||
const [errorMessage, setErrorMessage] = useState(""); | ||
|
||
const[name, setName] = useState(null); | ||
const [year, setYear] = useState(null); | ||
const [genderAns, setGenderAns] = useState(null); | ||
const [petsAns, setPetsAns] = useState(null); | ||
const [guestsAns, setGuestsAns] = useState(null); | ||
const [smokeAns, setSmokeAns] = useState(null); | ||
const [drinkAns, setDrinkAns] = useState(null); | ||
const [maxRent, setMaxRent] = useState(null); | ||
const [minRent, setMinRent] = useState(null); | ||
const [bedAns, setBedAns] = useState(null); | ||
const [quietAns, setQuietAns] = useState(null); | ||
const [cleanAns, setCleanAns] = useState(null); | ||
|
||
const fetchSurveyData = async () => { | ||
try { | ||
const response = await axios.get('http://localhost:3001/useranswers', { | ||
headers: { | ||
Authorization: `Bearer ${localStorage.getItem('token')}` | ||
} | ||
}); | ||
console.log('Fetching profile data', response.data); | ||
if (response.data) { | ||
setName(response.data.profile.name) | ||
setYear(response.data.answers.year) | ||
setGenderAns(response.data.answers.gender) | ||
setPetsAns(response.data.answers.pets) | ||
setGuestsAns(response.data.answers.guests) | ||
setSmokeAns(response.data.answers.smoke) | ||
setDrinkAns(response.data.answers.drink) | ||
setMaxRent(response.data.answers.rent_max) | ||
setMinRent(response.data.answers.rent_min) | ||
setBedAns(response.data.answers.bedtime) | ||
setQuietAns(response.data.answers.quietness) | ||
setCleanAns(response.data.answers.cleanliness) | ||
} else { | ||
throw new Error('Profile data is missing'); | ||
} | ||
} catch (error) { | ||
console.error('Error fetching profile data:', error); | ||
setError('Error fetching profile data: ' + error.message); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
fetchSurveyData(); | ||
}, []); | ||
|
||
|
||
return ( | ||
<div className="Survey"> | ||
<Header /> | ||
<div className='section'> | ||
<h3>Status</h3> | ||
</div> | ||
<div className="survey-question"> | ||
<p>Name: {name} </p> | ||
<p>Year: {year}</p> | ||
<p>Gender: {genderAns} </p> | ||
<p>Do you have pets? {petsAns} </p> | ||
</div> | ||
<br></br> | ||
<div className='section'> | ||
<h3>Rent Range</h3> | ||
</div> | ||
<div className="survey-question"> | ||
<p>Max Rent: {maxRent} </p> | ||
<p>Min Rent: {minRent} </p> | ||
</div> | ||
<br></br> | ||
<div className='section'> | ||
<h3>Living Habits</h3> | ||
</div> | ||
<div className="survey-question"> | ||
<p>How often do you bring over guests? {guestsAns} </p> | ||
<p>How often do you smoke? {smokeAns} </p> | ||
<p>How often do you drink? {drinkAns} </p> | ||
<p>When is your usual bedtime(1: Before 10, 2: Between 10 pm and 12 am, 3: Between 12 am and 2 am, | ||
4: Between 2 am and 4 am, 5:After 4 am, 6: Irregular)? {bedAns} </p> | ||
<p>How would you rate your loudness from 1 to 5(1 being quiet and 5 being loud)? {quietAns} </p> | ||
<p>How would you rate your cleanliness from 1 to 5(1 being messy and 5 being clean)? {cleanAns} </p> | ||
</div> | ||
<Button text="Back" location="/otheruser" /> | ||
</div> | ||
); | ||
} | ||
|
||
export default UserAnswers; |