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

Added prev and next buttons, rearranged button layout. #9

Closed
wants to merge 1 commit into from
Closed
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
71 changes: 50 additions & 21 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import { getUserRating } from "./tasks/getUserRatings";
import { setRating } from "./tasks/setRating";


// used to add new items
// import { AddNewItemCard } from "./components/AddNewItemCard";
// import { addRatingItem } from "./tasks/addItem";
Expand Down Expand Up @@ -48,7 +49,7 @@ function App() {
const [demoRating, setDemoRating] = useState(0);

// keep track of the index of the item in the list
var [itemIndex, setItemIndex] = useState(0);
var [itemIndex, setItemIndex] = useState(0);

let entryKeys: string[] = [
"0D3eg9jXmfeYiRDcErGc",
Expand Down Expand Up @@ -106,7 +107,7 @@ function App() {
];

// Use code below to generate array of item IDs
//
//
// setEntryKeys(foo);
// getRatingItems(100).then(async (value) => {
// let keys = Object.keys(value);
Expand All @@ -133,18 +134,31 @@ function App() {
}
}

function next(){
setItemIndex(itemIndex+=1);
getDebugRatingItem();
}

function prev(){
setItemIndex(itemIndex-=1);
getDebugRatingItem();
}

return (
<>
<Tabs
defaultActiveKey="home"
id="uncontrolled-tab-example"
className="mb-3"

>
<Tab eventKey="home" title="Home">
<div>
<Button variant="primary" onClick={openModal}>
{auth.currentUser ? "Sign Out" : "Sign In"}
</Button>
<div className="d-flex flex-row-reverse">
<Button variant="primary" onClick={openModal}>
{auth.currentUser ? "Sign Out" : "Sign In"}
</Button>
</div>

<Modal show={showModal} onHide={closeModal}>
<Modal.Header closeButton>
Expand Down Expand Up @@ -187,28 +201,43 @@ function App() {
</Modal.Footer>
</Modal>
</div>
<Button onClick={getDebugRatingItem}>Get Debug Rating Item</Button>
{ratingItem && (
<RatingPickerCard
id={debugId}
name={ratingItem.name}
description={ratingItem.description}
img_src={ratingItem.image}
rating={demoRating}
OnRatingChanged={(id, rating) =>
setRating(id, rating)
<div className="d-flex justify-content-center">
<div className="d-flex flex-column">

<Button onClick={getDebugRatingItem}>Start Rating Items</Button>
{ratingItem && (
<RatingPickerCard
id={debugId}
name={ratingItem.name}
description={ratingItem.description}
img_src={ratingItem.image}
rating={demoRating}
OnRatingChanged={(id, rating) =>
setRating(id, rating)
.then(() => {
// alert("rating set!"); // Commented out to speed up user experience
setItemIndex(itemIndex += 1); // increase index first
setItemIndex((itemIndex += 1)); // increase index first
// console.log(itemIndex); // used to debug
getDebugRatingItem(); // call function to refresh item
getDebugRatingItem(); // call function to refresh item
})
.catch((err) => alert(err))
}
/>
)}
}
/>
)}
</div>

<Button onClick={getDebugRatingItem}>Next</Button>
</div>
<div
className="d-flex justify-content-center"
style={{ padding: 20 }}
>
<div style={{ padding: 30}}>
<Button onClick={prev} size="lg"> Prev </Button>
</div>
<div style={{ padding: 30 }}>
<Button onClick={next} size="lg"> Next </Button>
</div>
</div>
</Tab>
<Tab eventKey="leaderboard" title="Leaderboard"></Tab>

Expand Down
2 changes: 1 addition & 1 deletion src/components/RatingPickerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const RatingPickerCard = ({ ...props }: RatingPickerCardProps) => {
/>
</div>
<hr />
<div className="d-flex justify-content-end">
<div className="d-flex justify-content-center">
<Button
variant="primary"
onClick={() => {
Expand Down