summaryrefslogtreecommitdiff
path: root/src-migrate/modules/footer-banner
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2024-07-02 15:37:19 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2024-07-02 15:37:19 +0700
commit5724e3b75c9bcb568d123fe86135205df1bb1c76 (patch)
tree6ae46a1d8408d181d01d9569f52e86f5ccc7d76a /src-migrate/modules/footer-banner
parentf287fc062c4ceb5039b5ca946da2e6854c27b007 (diff)
parentf7b024585b70f1bd600ba5e0d26368c532ac9723 (diff)
Merge branch 'release' into feature/step_approval
# Conflicts: # src-migrate/modules/product-detail/components/PriceAction.tsx # src/lib/transaction/components/Transaction.jsx # src/pages/index.jsx
Diffstat (limited to 'src-migrate/modules/footer-banner')
-rw-r--r--src-migrate/modules/footer-banner/index.tsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/src-migrate/modules/footer-banner/index.tsx b/src-migrate/modules/footer-banner/index.tsx
index 7db1363c..b214493d 100644
--- a/src-migrate/modules/footer-banner/index.tsx
+++ b/src-migrate/modules/footer-banner/index.tsx
@@ -1,15 +1,19 @@
import Link from "next/link"
+import React, { useMemo } from "react";
import { useQuery } from "react-query"
import Image from "~/components/ui/image"
import { getBanner } from "~/services/banner"
+import { getRandomInt } from '@/utils/getRandomInt'
const FooterBanner = () => {
const fetchFooterBanner = useQuery({
queryKey: 'footerBanner',
queryFn: () => getBanner({ type: 'bottom-search-promotion' })
})
-
- const banner = fetchFooterBanner?.data?.[0] || false
+ // ubah dari static menjadid dynamic dengan menggunakan random index
+ const length = useMemo(() => fetchFooterBanner.data?.length, [fetchFooterBanner.data]);
+ const randomIndex = useMemo(() => getRandomInt(length), [length]);
+ const banner = fetchFooterBanner?.data?.[randomIndex] || false;
return banner && (
<>
@@ -25,5 +29,4 @@ const FooterBanner = () => {
</>
)
}
-
export default FooterBanner \ No newline at end of file