summaryrefslogtreecommitdiff
path: root/src/pages/my/wishlist.js
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2023-03-01 09:18:52 +0000
committerIT Fixcomart <it@fixcomart.co.id>2023-03-01 09:18:52 +0000
commita7abbf4ddc70068620e9f44b74dc162ce2e16ee2 (patch)
tree74f66253717515d364ce74bd8275015c1f829cbc /src/pages/my/wishlist.js
parent90e1edab9b6a8ccc09a49fed3addbec2cbc4e4c3 (diff)
parenta1b9b647a6c4bda1f5db63879639d44543f9557e (diff)
Merged in refactor (pull request #1)
Refactor
Diffstat (limited to 'src/pages/my/wishlist.js')
-rw-r--r--src/pages/my/wishlist.js60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/pages/my/wishlist.js b/src/pages/my/wishlist.js
deleted file mode 100644
index 3d479802..00000000
--- a/src/pages/my/wishlist.js
+++ /dev/null
@@ -1,60 +0,0 @@
-import WithAuth from "@/components/auth/WithAuth";
-import Alert from "@/components/elements/Alert";
-import Pagination from "@/components/elements/Pagination";
-import Spinner from "@/components/elements/Spinner";
-import AppBar from "@/components/layouts/AppBar";
-import Layout from "@/components/layouts/Layout";
-import ProductCard from "@/components/products/ProductCard";
-import apiOdoo from "@/core/utils/apiOdoo";
-import { useAuth } from "@/core/utils/auth";
-import { useRouter } from "next/router";
-import { useEffect, useState } from "react";
-
-export default function Wishlist() {
- const [ auth ] = useAuth();
- const router = useRouter();
- const { page = 1 } = router.query;
- const [ wishlists, setWishlists ] = useState(null);
- const [ pageCount, setPageCount ] = useState(0);
-
- useEffect(() => {
- const loadWishlist = async () => {
- const limit = 10;
- const offset = (page - 1) * limit;
- if (auth) {
- const dataWishlist = await apiOdoo('GET', `/api/v1/user/${auth.id}/wishlist?limit=${limit}&offset=${offset}`);
- setWishlists(dataWishlist);
- setPageCount(Math.ceil(dataWishlist.product_total / limit));
- }
- }
- loadWishlist();
- }, [ auth, page ]);
-
- return (
- <WithAuth>
- <Layout>
- <AppBar title='Wishlist' />
-
- <div className="px-4 py-6">
- { !wishlists && (
- <Spinner className="w-6 h-6 text-gray-600 fill-gray-900 mx-auto" />
- ) }
- { wishlists?.products?.length == 0 && (
- <Alert type='info' className='text-center'>
- Wishlist anda masih kosong
- </Alert>
- ) }
- <div className="grid grid-cols-2 gap-3">
- {wishlists?.products.map((product) => (
- <ProductCard key={product.id} data={product} />
- ))}
- </div>
-
- <div className="mt-6">
- <Pagination currentPage={page} pageCount={pageCount} url={`/my/wishlist`} />
- </div>
- </div>
- </Layout>
- </WithAuth>
- )
-} \ No newline at end of file