Skip to content

Commit d7639bf

Browse files
committed
New product page
1 parent 4e6f43c commit d7639bf

File tree

2 files changed

+35
-80
lines changed

2 files changed

+35
-80
lines changed

src/pages/products2.tsx

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/pages/produkter.tsx

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,44 @@
1-
// Components
2-
import DisplayProducts from '@/components/Product/DisplayProducts.component';
1+
import Head from 'next/head';
32
import Layout from '@/components/Layout/Layout.component';
4-
5-
// GraphQL
6-
import { FETCH_ALL_PRODUCTS_QUERY } from '@/utils/gql/GQL_QUERIES';
7-
8-
// Utilities
3+
import ProductList from '@/components/Product/ProductList.component';
94
import client from '@/utils/apollo/ApolloClient';
10-
11-
// Types
5+
import { FETCH_ALL_PRODUCTS_QUERY } from '@/utils/gql/GQL_QUERIES';
126
import type { NextPage, GetStaticProps, InferGetStaticPropsType } from 'next';
137

14-
/**
15-
* Displays all of the products.
16-
* @function HomePage
17-
* @param {InferGetStaticPropsType<typeof getStaticProps>} products
18-
* @returns {JSX.Element} - Rendered component
19-
*/
20-
218
const Produkter: NextPage = ({
229
products,
23-
}: InferGetStaticPropsType<typeof getStaticProps>) => (
24-
<Layout title="Produkter">
25-
{products && <DisplayProducts products={products} />}
26-
</Layout>
27-
);
10+
loading,
11+
}: InferGetStaticPropsType<typeof getStaticProps>) => {
12+
if (loading)
13+
return (
14+
<Layout title="Produkter">
15+
<div className="flex justify-center items-center min-h-screen">
16+
<div className="animate-spin rounded-full h-32 w-32 border-t-2 border-b-2 border-gray-900"></div>
17+
</div>
18+
</Layout>
19+
);
20+
21+
if (!products)
22+
return (
23+
<Layout title="Produkter">
24+
<div className="flex justify-center items-center min-h-screen">
25+
<p className="text-red-500">Ingen produkter funnet</p>
26+
</div>
27+
</Layout>
28+
);
29+
30+
return (
31+
<Layout title="Produkter">
32+
<Head>
33+
<title>Produkter | WooCommerce Next.js</title>
34+
</Head>
35+
36+
<div className="container mx-auto px-4 py-8">
37+
<ProductList products={products} title="Herreklær" />
38+
</div>
39+
</Layout>
40+
);
41+
};
2842

2943
export default Produkter;
3044

0 commit comments

Comments
 (0)