From b02510e26e7e9bc292a1779bd23801014b94aad4 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 26 Apr 2023 17:23:52 +0700 Subject: flash sale and countdown --- src/lib/auth/components/CompanyProfile.jsx | 2 +- src/lib/auth/components/PersonalProfile.jsx | 4 ++-- src/lib/flashSale/api/flashSaleApi.js | 8 +++++++ src/lib/flashSale/components/FlashSale.jsx | 37 +++++++++++++++++++++++++++++ src/lib/home/components/PreferredBrand.jsx | 2 +- 5 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 src/lib/flashSale/api/flashSaleApi.js create mode 100644 src/lib/flashSale/components/FlashSale.jsx (limited to 'src/lib') diff --git a/src/lib/auth/components/CompanyProfile.jsx b/src/lib/auth/components/CompanyProfile.jsx index 854aa246..13d4a194 100644 --- a/src/lib/auth/components/CompanyProfile.jsx +++ b/src/lib/auth/components/CompanyProfile.jsx @@ -76,7 +76,7 @@ const CompanyProfile = () => { Dibawah ini adalah data usaha yang anda masukkan, periksa kembali data usaha anda. -
+
{!isOpen && } {isOpen && }
diff --git a/src/lib/auth/components/PersonalProfile.jsx b/src/lib/auth/components/PersonalProfile.jsx index 4a533ae9..bca54e24 100644 --- a/src/lib/auth/components/PersonalProfile.jsx +++ b/src/lib/auth/components/PersonalProfile.jsx @@ -9,7 +9,7 @@ import editPersonalProfileApi from '../api/editPersonalProfileApi' const PersonalProfile = () => { const auth = useAuth() - const [isOpen, setIsOpen] = useState(false) + const [isOpen, setIsOpen] = useState(true) const toggle = () => setIsOpen(!isOpen) const { register, setValue, handleSubmit } = useForm({ defaultValues: { @@ -54,7 +54,7 @@ const PersonalProfile = () => { Dibawah ini adalah data diri yang anda masukan, periksa kembali data diri anda
-
+
{!isOpen && } {isOpen && }
diff --git a/src/lib/flashSale/api/flashSaleApi.js b/src/lib/flashSale/api/flashSaleApi.js new file mode 100644 index 00000000..115b07dc --- /dev/null +++ b/src/lib/flashSale/api/flashSaleApi.js @@ -0,0 +1,8 @@ +import odooApi from '@/core/api/odooApi' + +const flashSaleApi = async () => { + const flashSale = await odooApi('GET', '/api/v1/flashsale/header') + return flashSale +} + +export default flashSaleApi diff --git a/src/lib/flashSale/components/FlashSale.jsx b/src/lib/flashSale/components/FlashSale.jsx new file mode 100644 index 00000000..0167dc57 --- /dev/null +++ b/src/lib/flashSale/components/FlashSale.jsx @@ -0,0 +1,37 @@ +import { useEffect, useState } from 'react' +import flashSaleApi from '../api/flashSaleApi' +import Image from '@/core/components/elements/Image/Image' +import CountDown from '@/core/components/elements/CountDown/CountDown' + +const FlashSale = () => { + const [flashSales, setFlashSales] = useState(null) + + useEffect(() => { + const loadFlashSales = async () => { + const dataFlashSales = await flashSaleApi() + setFlashSales(dataFlashSales) + } + loadFlashSales() + }, []) + + return flashSales?.length > 0 && ( +
+ + {flashSales.map((flashSale, index) => ( +
+
{flashSale.name}
+ +
+
+ +
+ {flashSale.name} +
+ +
+ ))} +
+ ) +} + +export default FlashSale diff --git a/src/lib/home/components/PreferredBrand.jsx b/src/lib/home/components/PreferredBrand.jsx index f97943cb..34c50220 100644 --- a/src/lib/home/components/PreferredBrand.jsx +++ b/src/lib/home/components/PreferredBrand.jsx @@ -14,7 +14,7 @@ const PreferredBrand = () => {
Brand Pilihan
{isDesktop && ( - + Lihat Semua )} -- cgit v1.2.3