+
{products.FutureProducts.length > 0 ? (
<>
- {products.FutureProducts
- /*.sort((a, b) =>
- a.Name.localeCompare(b.Name)
- )*/
- .sort((a, b) => b.Votes - a.Votes)
- .map(
- (product, index) =>
- (showMore.futureProducts || index < 5) && (
-
-
-
- vote.n === product.Name &&
- vote.t === 0
- ) > -1
- ? "red"
- : "#000",
- }}
- onClick={() => {
- if (
- votes.findIndex(
- (vote) =>
- vote.n === product.Name &&
- vote.t === 0
- ) === -1
- ) {
- VoteRequest(product.Name, false);
- vote(product.Name, false);
+ {products.FutureProducts.sort((a, b) => b.Votes - a.Votes).map(
+ (product, index) =>
+ (showMore.futureProducts || index < 5) && (
+
+
+
+ vote.n === product.Name && vote.t === 0
+ ) > -1
+ ? "red"
+ : "#000",
+ }}
+ onClick={() => {
+ if (
+ votes.findIndex(
+ (vote) =>
+ vote.n === product.Name && vote.t === 0
+ ) === -1
+ ) {
+ VoteRequest(product.Name, false);
+ vote(product.Name, false);
- // simulate vote before request is made
- setProducts((products) => {
- const newArr =
- products.FutureProducts.map((p) =>
- p.Name === product.Name
- ? { ...p, Votes: p.Votes - 1 }
- : p
- );
+ // simulate vote before request is made
+ setProducts((products) => {
+ const newArr =
+ products.FutureProducts.map((p) =>
+ p.Name === product.Name
+ ? { ...p, Votes: p.Votes - 1 }
+ : p
+ );
- return {
- ...products,
- FutureProducts: newArr,
- };
- });
- }
- }}
- />
- {product.Votes}
-
- vote.n === product.Name &&
- vote.t === 1
- ) > -1
- ? "green"
- : "#000",
- }}
- onClick={() => {
- if (
- votes.findIndex(
- (vote) =>
- vote.n === product.Name &&
- vote.t === 1
- ) === -1
- ) {
- VoteRequest(product.Name, true);
- vote(product.Name, true);
+ return {
+ ...products,
+ FutureProducts: newArr,
+ };
+ });
+ }
+ }}
+ />
+ {product.Votes}
+
+ vote.n === product.Name && vote.t === 1
+ ) > -1
+ ? "green"
+ : "#000",
+ }}
+ onClick={() => {
+ if (
+ votes.findIndex(
+ (vote) =>
+ vote.n === product.Name && vote.t === 1
+ ) === -1
+ ) {
+ VoteRequest(product.Name, true);
+ vote(product.Name, true);
- // simulate vote before request is made
- setProducts((products) => {
- const newArr =
- products.FutureProducts.map((p) =>
- p.Name === product.Name
- ? { ...p, Votes: p.Votes + 1 }
- : p
- );
+ // simulate vote before request is made
+ setProducts((products) => {
+ const newArr =
+ products.FutureProducts.map((p) =>
+ p.Name === product.Name
+ ? { ...p, Votes: p.Votes + 1 }
+ : p
+ );
- return {
- ...products,
- FutureProducts: newArr,
- };
- });
- }
- }}
- />
-
- }
- />
-
- )
- )}
+ return {
+ ...products,
+ FutureProducts: newArr,
+ };
+ });
+ }
+ }}
+ />
+
+ }
+ />
+
+ )
+ )}
{products.FutureProducts.length > 5 &&
!showMore.futureProducts && (