schon/storefront/src/pages/index.tsx
Egor fureunoir Gorbunov 9ceeb32f5d Fixes: 1) Remove unused useRouter import in index.tsx to clean up dependencies;
Extra: Ensure better maintainability by eliminating redundant imports;
2025-07-01 00:47:57 +03:00

27 lines
698 B
TypeScript

import {apolloClient} from 'graphql/apolloClient';
import {GET_PRODUCTS} from 'graphql/queries/getProducts';
import {GetStaticProps} from 'next';
export const getStaticProps: GetStaticProps = async () => {
const {data} = await apolloClient.query({
query: GET_PRODUCTS,
variables: {first: 10},
});
return {
props: {
products: data.products.edges.map((e: any) => e.node),
},
revalidate: 300,
};
}
export default function Home({products}: { products: any[] }) {
return (
<div>
{products.map(p => (
<div key={p.uuid}>{p.name} £{p.minPrice}</div>
))}
</div>
);
}