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

Alexander : Week-6, Survey #445

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 0 additions & 49 deletions code/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion code/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Technigo React App</title>
<title>Super Nostalgia - Survey</title>
</head>

<body>
Expand Down
13 changes: 10 additions & 3 deletions code/src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import React from 'react';
import Survey from 'components/Survey';
import Hero from 'components/Hero';

export const App = () => {
return (
<div>
Find me in src/app.js!
</div>
<>
<div className="hero">
<Hero />
</div>
<div className="survey-body">
<Survey />
</div>
</>
);
}
14 changes: 14 additions & 0 deletions code/src/components/Hero.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable linebreak-style */
/* eslint-disable indent */
import React from 'react';

const Hero = () => {
return (
<>
<div className="hero-text"><h1>Ultra Nostalgia</h1></div>
<div className="hero-wrapper" />
</>
)
}

export default Hero;
10 changes: 10 additions & 0 deletions code/src/components/Landing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";

const Landing = (props) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused component? I might need to be corrected here.

return (

)

}

export default Landing;
47 changes: 47 additions & 0 deletions code/src/components/Name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* eslint-disable linebreak-style */
/* eslint-disable react/jsx-indent-props */
/* eslint-disable indent */

import React, { useRef, useEffect } from 'react';

const Name = (props) => {
const { name, setName, counter, setCounter, percentboop, setPercentbop } = props

const inputRef = useRef(null);

useEffect(() => {
inputRef.current.focus();
}, []);

const handleNameChange = (event) => {
setName(event.target.value)
}

const goToNextQuestion = () => {
setCounter(counter + 1);
setPercentbop(percentboop + 20)
};

const handleKeyDown = (event) => {
if (event.keyCode === 13) {
goToNextQuestion();
}
};

return (
<div>
<p>What is your name?</p>
<input
className="name-input"
type="text"
name="name"
value={name}
ref={inputRef}
onKeyDown={handleKeyDown}
onChange={handleNameChange}
required="required" />
</div>
)
}

export default Name;
17 changes: 17 additions & 0 deletions code/src/components/ProgressBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable linebreak-style */
/* eslint-disable indent */

import React from 'react';

const ProgressBar = ({ percent }) => {
// const { bop, setBop } = props;
return (
<div className="progress-bar">
<div className="progress-bar-fill" style={{ width: `${percent}%` }}>
{percent}%
</div>
</div>
)
}

export default ProgressBar;
58 changes: 58 additions & 0 deletions code/src/components/Purchases.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* eslint-disable linebreak-style */
/* eslint-disable react/jsx-indent-props */
/* eslint-disable indent */

import React from 'react';
import Question2Image from '../images/question2.jpg'

const Purchases = (props) => {
const { purchases, setPurchases } = props
// const { food, setFood, avocado, setAvocado, percentboop, setPercentbop } = props

// const inputRef = useRef(null);

const handlePurchasesChange = (event) => {
setPurchases(event.target.value)
}

// const goToNextQuestion = () => {
// setAvocado(avocado + 1)
// setPercentbop(percentboop + 10)
// }

// const handleKeyDown = (event) => {
// if (event.keyCode === 13) {
// goToNextQuestion();
// }
// };

return (
<div className="food-wrapper">
<img
className="question2-image"
src={Question2Image}
alt="q2" />
<p>How many retail therapy purchases have you done with us?</p>
<select
className="question2"
onChange={handlePurchasesChange}
value={purchases}>
<option value="">Select option:</option>
<option value="ounce">Only once (thus far!)</option>
<option value="twice">At least two times</option>
<option value="3-5 times">3-5 times</option>
<option value="5-20 times">5-20 times</option>
<option value="more than 20 times">More than 20 times! take my MONEY ◝(ᵔᵕᵔ)◜</option>
</select>
{/* <input
type="text"
value={food}
ref={inputRef}
onKeyDown={handleKeyDown}
onChange={handleFoodChange} />
{console.log(food)} */}
Comment on lines +47 to +53

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to reference past code if you have another working solution

</div>
)
}

export default Purchases;
51 changes: 51 additions & 0 deletions code/src/components/RadioProduct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* eslint-disable linebreak-style */
/* eslint-disable react/jsx-tag-spacing */
/* eslint-disable indent */
/* eslint-disable react/jsx-indent-props */

import React from 'react';
import Vinylimage from '../images/vinylicon.jpg'
import Posterimage from '../images/postericon.jpg'
import Fadsimage from '../images/fadicon.jpg'
import Consoleimage from '../images/consoleicon.jpg'

const products = [
'Exclusive vinyl records',
'Vintage video game consoles',
'90s-fads inspired merch',
'Y2k wall-art and posters'
];

const RadioProduct = (props) => {
const { favProduct, setFavProduct } = props;

const handleProductChange = (event) => {
setFavProduct(event.target.value);
}
return (
<form className="food-wrapper">
<p>What is your favorite product from UltraNostalgia?</p>
{products.map((product) => (
<label htmlFor="product" key={product} className="favorite-product">
<input
type="radio"
name="favoriteProduct"
className="product-button"
value={product}
onChange={handleProductChange}
onChecked={favProduct === product}
required />
{product}
</label>
))}
Comment on lines +28 to +40

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of map()

<div className="icon-container">
<img className="product-icon" src={Vinylimage} alt="vinyl"/>
<img className="product-icon" src={Posterimage} alt="poster"/>
<img className="product-icon" src={Fadsimage} alt="fads"/>
<img className="product-icon" src={Consoleimage} alt="console"/>
</div>
</form>
)
}

export default RadioProduct;
15 changes: 15 additions & 0 deletions code/src/components/Result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable linebreak-style */
/* eslint-disable max-len */
/* eslint-disable indent */
import React from 'react';

const Result = ({ name, purchases, favProduct }) => {
return (
<>
<p>Awesome! Thank you for completing our survey {name}.</p>
<p>You have used our online store {purchases} and we appreciate that, your favorite out of our range of ultra nostalgic products are {favProduct}.</p>
</>
)
}

export default Result;
26 changes: 26 additions & 0 deletions code/src/components/Satisfaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* eslint-disable linebreak-style */
import React from 'react';

const Satisfaction = (props) => {
const { satisfactionRange, satisfaction, handleSatisfactionChange } = props
return (
<div className="food-counter">
<form className="satisfaction-container">
<p>What do you think of our online store?</p>
<label htmlFor="satisfaction" className="satisfaction-slider">
<input
className="slider"
type="range"
min="0"
max="4"
value={satisfactionRange}
onChange={handleSatisfactionChange}
required />
<p>{satisfaction}</p>
</label>
</form>
</div>
);
};

export default Satisfaction;
30 changes: 30 additions & 0 deletions code/src/components/Suggestion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint-disable linebreak-style */
/* eslint-disable padded-blocks */
import React from 'react';

const Suggestion = ({ suggestion, setSuggestion }) => {

const handleSuggestionChange = (event) => {
setSuggestion(event.target.value);
}

return (
<div className="food-container">
<p> Got any suggestions?</p>
<label htmlFor="suggestion">
<textarea
className="textarea-opinion"
name="suggestion"
rows="10"
cols="50"
maxLength="300"
placeholder="How can we improve our services? Let us know here..."
value={suggestion}
onChange={handleSuggestionChange}
required />
</label>
</div>
)
}

export default Suggestion;
Loading