Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit 436595b

Browse files
author
Steph Dietz
committed
update home page to only show in stock items
1 parent 0c158da commit 436595b

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

frontend/app/actions.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ const fetchQuery = async ({ query, variables }: FetchQueryProps) => {
3535
export async function searchProducts(
3636
query: string,
3737
maxItems: number,
38-
thresholdStars: number
38+
thresholdStars: number,
39+
inStockOnly: boolean = false
3940
) {
40-
console.log("Basic search", query, maxItems, thresholdStars);
4141
const graphqlQuery = `
42-
query searchProducts($query: String!, $maxItems: Int!, $thresholdStars: Float!) {
43-
searchProducts(query: $query, maxItems: $maxItems, thresholdStars: $thresholdStars) {
42+
query searchProducts($query: String!, $maxItems: Int!, $thresholdStars: Float!, $inStockOnly: Boolean!) {
43+
searchProducts(query: $query, maxItems: $maxItems, thresholdStars: $thresholdStars, inStockOnly: $inStockOnly) {
4444
searchObjs {
4545
product {
4646
name
@@ -63,6 +63,7 @@ query searchProducts($query: String!, $maxItems: Int!, $thresholdStars: Float!)
6363
query,
6464
maxItems,
6565
thresholdStars,
66+
inStockOnly,
6667
},
6768
});
6869

frontend/app/components/carousel.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import { Suspense } from "react";
44
import { TileSkeleton } from "./skeletons";
55

66
export async function Carousel() {
7-
const response = await searchProducts(
8-
"Items in the Stuffed Animals & Plush Toys category",
9-
7,
10-
1,
11-
);
7+
const response = await searchProducts("Top rated toys", 15, 1, true);
128

139
const products = response?.data?.searchProducts?.searchObjs || [];
1410
// Purposefully duplicating products to make the carousel loop and not run out of products on wide screens.

frontend/app/components/grid.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export async function ThreeItemGrid() {
4242
"Items that people of all ages would enjoy",
4343
3,
4444
1,
45+
true
4546
);
4647

4748
const topThreeProducts = response?.data?.searchProducts?.searchObjs || [];

0 commit comments

Comments
 (0)