diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-03-29 11:14:10 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-03-29 11:14:10 +0700 |
| commit | ac230a35f325cc47e89fd5d635847536f2dd9b44 (patch) | |
| tree | 140f183209ca2353de06fdeb3e7028b43ee28c40 /src/lib | |
| parent | 5f8362bc9272af730a084b7cc1dda6537f7f8d40 (diff) | |
| parent | aa21c215d18d0a80e7f2979f9a18f5af7db02f8c (diff) | |
Merge branch 'master' of https://bitbucket.org/altafixco/next-indoteknik
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/checkout/components/FinishCheckout.jsx | 2 | ||||
| -rw-r--r-- | src/lib/product/components/Product/ProductDesktop.jsx | 16 | ||||
| -rw-r--r-- | src/lib/product/components/Product/ProductMobile.jsx | 10 | ||||
| -rw-r--r-- | src/lib/video/api/videoApi.js | 8 | ||||
| -rw-r--r-- | src/lib/video/hooks/useVideo.js | 13 |
5 files changed, 43 insertions, 6 deletions
diff --git a/src/lib/checkout/components/FinishCheckout.jsx b/src/lib/checkout/components/FinishCheckout.jsx index 33c0d46a..4af39e91 100644 --- a/src/lib/checkout/components/FinishCheckout.jsx +++ b/src/lib/checkout/components/FinishCheckout.jsx @@ -2,7 +2,7 @@ import Link from '@/core/components/elements/Link/Link' const FinishCheckout = ({ query }) => { return ( - <div className='p-4'> + <div className='mx-auto container p-4 md:p-0 mt-0 md:mt-10'> <div className='rounded-xl bg-yellow_r-4 text-center border border-yellow_r-7'> <div className='px-4 py-6 text-yellow_r-12'> <p className='font-semibold mb-2'>Terima Kasih atas Pembelian Anda</p> diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 79e7bb45..2f0ac488 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -12,6 +12,7 @@ import useVariantPrice from '@/lib/variant/hooks/useVariantPrice' import useProductPrice from '../../hooks/useProductPrice' import PriceSkeleton from '@/core/components/elements/Skeleton/PriceSkeleton' import { useRouter } from 'next/router' +import { createSlug } from '@/core/utils/slug' const ProductDesktop = ({ product, wishlist, toggleWishlist }) => { const router = useRouter() @@ -38,7 +39,8 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => { if (!validQuantity(quantity)) return updateItemCart({ productId: variantId, - quantity + quantity, + selected: true }) toast.success('Berhasil menambahkan ke keranjang') } @@ -92,7 +94,15 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => { <div className='w-1/4 text-gray_r-12/70'>Manufacture</div> <div className='w-3/4'> {product.manufacture?.name ? ( - <Link href='/'>{product.manufacture?.name}</Link> + <Link + href={createSlug( + '/shop/brands/', + product.manufacture?.name, + product.manufacture?.id + )} + > + {product.manufacture?.name} + </Link> ) : ( <div>-</div> )} @@ -181,7 +191,7 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => { {product.variants.map((variant) => ( <tr key={variant.id}> <td>{variant.code}</td> - <td>{variant.attributes.join(', ')}</td> + <td>{variant.attributes.join(', ') || '-'}</td> <td> <VariantPrice id={variant.id} /> </td> diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index 0df22026..e560639c 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -14,6 +14,7 @@ import { toast } from 'react-hot-toast' import useVariantPrice from '@/lib/variant/hooks/useVariantPrice' import PriceSkeleton from '@/core/components/elements/Skeleton/PriceSkeleton' import useProductPrice from '../../hooks/useProductPrice' +import { createSlug } from '@/core/utils/slug' const ProductMobile = ({ product, wishlist, toggleWishlist }) => { const router = useRouter() @@ -79,7 +80,8 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { if (!validAction()) return updateItemCart({ productId: activeVariant.id, - quantity + quantity, + selected: true }) toast.success('Berhasil menambahkan ke keranjang') } @@ -106,7 +108,11 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { <div className='p-4'> <div className='flex items-end mb-2'> {product.manufacture?.name ? ( - <Link href='/'>{product.manufacture?.name}</Link> + <Link + href={createSlug('/shop/brands/', product.manufacture?.name, product.manufacture?.id)} + > + {product.manufacture?.name} + </Link> ) : ( <div>-</div> )} diff --git a/src/lib/video/api/videoApi.js b/src/lib/video/api/videoApi.js new file mode 100644 index 00000000..d1031dab --- /dev/null +++ b/src/lib/video/api/videoApi.js @@ -0,0 +1,8 @@ +import odooApi from '@/core/api/odooApi' + +const videoApi = async ({ limit, offset }) => { + const dataVideos = await odooApi('GET', `/api/v1/video_content?limit=${limit}&offset=${offset}`) + return dataVideos +} + +export default videoApi diff --git a/src/lib/video/hooks/useVideo.js b/src/lib/video/hooks/useVideo.js new file mode 100644 index 00000000..6086f9aa --- /dev/null +++ b/src/lib/video/hooks/useVideo.js @@ -0,0 +1,13 @@ +import { useQuery } from 'react-query' +import videoApi from '../api/videoApi' + +const useVideo = ({ limit, offset }) => { + const fetchVideo = async () => await videoApi({ limit, offset }) + const video = useQuery(`video-${limit}-${offset}`, fetchVideo, { + refetchOnWindowFocus: false + }) + + return { video } +} + +export default useVideo |
