diff --git a/app/page.tsx b/app/page.tsx
index 7b0b81e28..3201b60f5 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -1,18 +1,77 @@
-import { Carousel } from 'components/carousel';
-import { ThreeItemGrid } from 'components/grid/three-items';
-
export const metadata = {
description: 'High-performance ecommerce store built with Next.js, Vercel, and Shopify.',
openGraph: {
type: 'website'
}
};
+import { Carousel } from 'components/carousel';
+import { ThreeItemGrid } from 'components/grid/three-items';
+import { Category } from 'lib/woocomerce/models/base';
+import { Product } from 'lib/woocomerce/models/product';
+import { woocommerce } from 'lib/woocomerce/woocommerce';
+import { wordpress } from 'lib/wordpress/wordpress';
+import React from 'react';
export default async function HomePage() {
+ const categories: Category[] = await woocommerce.get('products/categories');
+ const productsByCategory: Record
= {};
+ await Promise.all(
+ categories.map((category) =>
+ woocommerce.get('products', { category: category.id.toString() }).then((products) => {
+ productsByCategory[category.name] = products;
+ })
+ )
+ );
+ const posts = await wordpress.get('posts');
+
return (
- <>
-
-
- >
+
+ {categories.map((category, index) => (
+
+
+
+ {category.name}
+
+
+
+
+ {category.description}
+
+
+
+ {productsByCategory[category.name] && (
+
+ )}
+
+ {index === 1 && (
+
+ Top products
+
+
+ )}
+
+ ))}
+
+
Latest posts
+
+ {posts.map((post: any) => (
+
+

+
+
{post.title.rendered}
+
+
+
+ ))}
+
+
+
);
}
diff --git a/app/profile/area/page.tsx b/app/profile/area/page.tsx
new file mode 100644
index 000000000..61385631e
--- /dev/null
+++ b/app/profile/area/page.tsx
@@ -0,0 +1,7 @@
+export default async function PersonalArea() {
+ return (
+
+ );
+}
diff --git a/app/profile/layout.tsx b/app/profile/layout.tsx
new file mode 100644
index 000000000..869301b94
--- /dev/null
+++ b/app/profile/layout.tsx
@@ -0,0 +1,66 @@
+'use client';
+
+import { Avatar } from '@nextui-org/react';
+import LogoutButton from 'components/button/logout';
+import { Customer } from 'lib/woocomerce/models/customer';
+import { Shipping } from 'lib/woocomerce/models/shipping';
+import Link from 'next/link';
+import { useEffect, useState } from 'react';
+
+export default function ProfileLayout({ children }: { children: React.ReactNode }) {
+ const [customer, setCustomer] = useState(undefined);
+ const [shippingAddress, setShippingAddress] = useState(undefined);
+
+ useEffect(() => {
+ const fetchCustomer = async () => {
+ const data = (await (
+ await fetch('/api/customer', {
+ method: 'GET',
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ })
+ ).json()) as Customer;
+ setCustomer(data);
+ };
+
+ fetchCustomer();
+ }, []);
+
+ return (
+
+
+
Profile
+ {customer && (
+
+
+
+ {customer.first_name}
+ {customer.last_name}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )}
+
+
+ {children}
+
+
+ );
+}
diff --git a/app/profile/orders/page.tsx b/app/profile/orders/page.tsx
index 4c5f28c6d..ef11d4b2d 100644
--- a/app/profile/orders/page.tsx
+++ b/app/profile/orders/page.tsx
@@ -10,7 +10,7 @@ export default async function OrdersPage() {
const orders = await woocommerce.get('orders');
return (
-
+
Orders
{orders.map((order) => (
diff --git a/app/profile/page.tsx b/app/profile/page.tsx
index e17ca8e23..e025c0185 100644
--- a/app/profile/page.tsx
+++ b/app/profile/page.tsx
@@ -1,106 +1,7 @@
-'use client';
-
-import LogoutButton from 'components/button/logout';
-import ShippingForm from 'components/shipping/form';
-import { Customer } from 'lib/woocomerce/models/customer';
-import { Shipping } from 'lib/woocomerce/models/shipping';
-import Link from 'next/link';
-import { useEffect, useState } from 'react';
-
-export default function ProfilePage() {
- const [customer, setCustomer] = useState(undefined);
- const [shippingAddress, setShippingAddress] = useState(undefined);
-
- useEffect(() => {
- const fetchCustomer = async () => {
- const data = (await (
- await fetch('/api/customer', {
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json'
- }
- })
- ).json()) as Customer;
- setCustomer(data);
- };
-
- fetchCustomer();
- }, []);
-
+export default async function ProfilePage() {
return (
-
- Profile
-
-
Info
- {customer && (
-
-

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- )}
-
+
);
}
diff --git a/components/button/logout.tsx b/components/button/logout.tsx
index 99c6d0d6b..33beafb12 100644
--- a/components/button/logout.tsx
+++ b/components/button/logout.tsx
@@ -7,7 +7,7 @@ export default function LogoutButton() {
return (