Skip to content

Commit

Permalink
fix(hotfix): fix products page 500 error
Browse files Browse the repository at this point in the history
  • Loading branch information
ismail-benlaredj committed Nov 27, 2023
1 parent 4ae1ab0 commit 4689f7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pages/item/[id].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function getStaticProps({ params }) {
otherItems,
},

revalidate: 10,
revalidate: 60 * 60,
};
}

Expand Down
16 changes: 10 additions & 6 deletions src/pages/products/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";

import { getAllItems } from "@/lib/firebase/firestoreFunctions";
Expand All @@ -11,7 +11,7 @@ import SearchBar from "@/components/searchbar";

import { categories } from "@/constants";

export default function ProductsPage({ items, queryParams }) {
export default function ProductsPage({ queryParams }) {
const {
register,
handleSubmit,
Expand All @@ -21,12 +21,19 @@ export default function ProductsPage({ items, queryParams }) {
const [categoryFilter, setCategoryFilter] = useState(null);
const [keywordFilter, setKeywordFilter] = useState("");
const [locationFilter, setLocationFilter] = useState("");
const [items, setItems] = useState([]);

const onSubmit = (data) => {
setKeywordFilter(data.keyword || "");
setLocationFilter(data.location || "");
};

useEffect(() => {
async function getItems() {
let items = await getAllItems("items");
setItems(items);
}
getItems();
}, []);
return (
<div className='my-32'>
<div className='my-28'>
Expand Down Expand Up @@ -133,12 +140,9 @@ export default function ProductsPage({ items, queryParams }) {

export async function getServerSideProps({ query }) {
const queryParams = query;
let items = await getAllItems("items");
items = JSON.parse(JSON.stringify(items));

return {
props: {
items,
queryParams,
},
};
Expand Down

1 comment on commit 4689f7f

@vercel
Copy link

@vercel vercel bot commented on 4689f7f Nov 27, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.