From aa21c215d18d0a80e7f2979f9a18f5af7db02f8c Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 29 Mar 2023 11:10:53 +0700 Subject: video page --- .../components/elements/Navbar/NavbarDesktop.jsx | 6 +++ src/lib/checkout/components/FinishCheckout.jsx | 2 +- .../product/components/Product/ProductDesktop.jsx | 16 +++++-- .../product/components/Product/ProductMobile.jsx | 10 +++- src/lib/video/api/videoApi.js | 8 ++++ src/lib/video/hooks/useVideo.js | 13 +++++ src/pages/index.jsx | 26 +++++----- src/pages/video.jsx | 55 ++++++++++++++++++++++ 8 files changed, 119 insertions(+), 17 deletions(-) create mode 100644 src/lib/video/api/videoApi.js create mode 100644 src/lib/video/hooks/useVideo.js create mode 100644 src/pages/video.jsx (limited to 'src') diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index 7e66a234..7f564cf1 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -109,6 +109,12 @@ const NavbarDesktop = () => { > Blog Indoteknik + + Indoteknik TV +
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 ( -
+

Terima Kasih atas Pembelian Anda

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 }) => {
Manufacture
{product.manufacture?.name ? ( - {product.manufacture?.name} + + {product.manufacture?.name} + ) : (
-
)} @@ -181,7 +191,7 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => { {product.variants.map((variant) => ( {variant.code} - {variant.attributes.join(', ')} + {variant.attributes.join(', ') || '-'} 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 }) => {
{product.manufacture?.name ? ( - {product.manufacture?.name} + + {product.manufacture?.name} + ) : (
-
)} 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 diff --git a/src/pages/index.jsx b/src/pages/index.jsx index c6737037..99f94ee1 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -1,10 +1,10 @@ import dynamic from 'next/dynamic' -import Seo from '@/core/components/Seo' import ImageSkeleton from '@/core/components/elements/Skeleton/ImageSkeleton' import PopularProductSkeleton from '@/lib/home/components/Skeleton/PopularProductSkeleton' import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' import { useRef } from 'react' +import { NextSeo } from 'next-seo' const BasicLayout = dynamic(() => import('@/core/components/layouts/BasicLayout')) @@ -35,19 +35,23 @@ export default function Home() { return ( - +
-
+
-
+
diff --git a/src/pages/video.jsx b/src/pages/video.jsx new file mode 100644 index 00000000..c7248da1 --- /dev/null +++ b/src/pages/video.jsx @@ -0,0 +1,55 @@ +import Pagination from '@/core/components/elements/Pagination/Pagination' +import BasicLayout from '@/core/components/layouts/BasicLayout' +import useVideo from '@/lib/video/hooks/useVideo' +import { useRouter } from 'next/router' + +export default function Video() { + const router = useRouter() + const limit = 16 + + const { page = 1 } = router.query + const { video } = useVideo({ limit, offset: limit * (page - 1) }) + + const pageCount = Math.ceil(video?.data?.videoTotal / limit) + + return ( + +
+

Kanal Video Indoteknik

+
+ {video.data?.videos?.map((video) => ( +
+