summaryrefslogtreecommitdiff
path: root/src-migrate/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/modules')
-rw-r--r--src-migrate/modules/footer-banner/index.tsx29
-rw-r--r--src-migrate/modules/product-detail/components/PriceAction.tsx10
-rw-r--r--src-migrate/modules/side-banner/index.tsx29
3 files changed, 68 insertions, 0 deletions
diff --git a/src-migrate/modules/footer-banner/index.tsx b/src-migrate/modules/footer-banner/index.tsx
new file mode 100644
index 00000000..7db1363c
--- /dev/null
+++ b/src-migrate/modules/footer-banner/index.tsx
@@ -0,0 +1,29 @@
+import Link from "next/link"
+import { useQuery } from "react-query"
+import Image from "~/components/ui/image"
+import { getBanner } from "~/services/banner"
+
+const FooterBanner = () => {
+ const fetchFooterBanner = useQuery({
+ queryKey: 'footerBanner',
+ queryFn: () => getBanner({ type: 'bottom-search-promotion' })
+ })
+
+ const banner = fetchFooterBanner?.data?.[0] || false
+
+ return banner && (
+ <>
+ {banner.url && (
+ <Link href={banner.url}>
+ <Image src={banner.image} alt={banner.name} width={924} height={150} className='object-cover object-center rounded-lg' />
+ </Link>
+ )}
+
+ {!banner.url && (
+ <Image src={banner.image} alt={banner.name} width={924} height={150} className='object-cover object-center rounded-lg' />
+ )}
+ </>
+ )
+}
+
+export default FooterBanner \ No newline at end of file
diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx
index f25847a5..ad04de43 100644
--- a/src-migrate/modules/product-detail/components/PriceAction.tsx
+++ b/src-migrate/modules/product-detail/components/PriceAction.tsx
@@ -23,6 +23,16 @@ const PriceAction = ({ product }: Props) => {
useEffect(() => {
setActive(product.variants[0])
+ if(product.variants.length > 2 && product.variants[0].price.price === 0){
+ const variants = product.variants
+ for (let i = 0; i < variants.length; i++) {
+ if(variants[i].price.price > 0){
+ setActive(variants[i])
+ break;
+ }
+ }
+ }
+
}, [product, setActive]);
return (
diff --git a/src-migrate/modules/side-banner/index.tsx b/src-migrate/modules/side-banner/index.tsx
new file mode 100644
index 00000000..be52c554
--- /dev/null
+++ b/src-migrate/modules/side-banner/index.tsx
@@ -0,0 +1,29 @@
+import Link from "next/link"
+import { useQuery } from "react-query"
+import Image from "~/components/ui/image"
+import { getBanner } from "~/services/banner"
+
+const SideBanner = () => {
+ const fetchSideBanner = useQuery({
+ queryKey: 'sideBanner',
+ queryFn: () => getBanner({ type: 'side-banner-search' })
+ })
+
+ const banner = fetchSideBanner?.data?.[0] || false
+
+ return banner && (
+ <>
+ {banner.url && (
+ <Link href={banner.url}>
+ <Image src={banner.image} alt={banner.name} width={315} height={450} className='object-cover object-center rounded-lg' />
+ </Link>
+ )}
+
+ {!banner.url && (
+ <Image src={banner.image} alt={banner.name} width={315} height={450} className='object-cover object-center rounded-lg' />
+ )}
+ </>
+ )
+}
+
+export default SideBanner \ No newline at end of file