summaryrefslogtreecommitdiff
path: root/src/core/components/elements
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-05-17 16:08:45 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-05-17 16:08:45 +0700
commitaf35f7c31c65b6fb42c67424674f1f8acd68a5a1 (patch)
treef5966873c96c8b55f5158d2b64d6e694668820cd /src/core/components/elements
parent6d57dbfd4e27eacfd1604b8d8326ee75326c0dd5 (diff)
Fix banner url
Diffstat (limited to 'src/core/components/elements')
-rw-r--r--src/core/components/elements/Link/Link.jsx2
-rw-r--r--src/core/components/elements/Navbar/TopBanner.jsx17
2 files changed, 12 insertions, 7 deletions
diff --git a/src/core/components/elements/Link/Link.jsx b/src/core/components/elements/Link/Link.jsx
index f6b39d45..716ce325 100644
--- a/src/core/components/elements/Link/Link.jsx
+++ b/src/core/components/elements/Link/Link.jsx
@@ -9,6 +9,8 @@ import NextLink from 'next/link'
* @returns {JSX.Element} - Rendered `Link` component.
*/
const Link = ({ children, ...props }) => {
+ if (!props?.href || props?.href == false) return children
+
return (
<NextLink
{...props}
diff --git a/src/core/components/elements/Navbar/TopBanner.jsx b/src/core/components/elements/Navbar/TopBanner.jsx
index 48b23a3d..9efd0a8d 100644
--- a/src/core/components/elements/Navbar/TopBanner.jsx
+++ b/src/core/components/elements/Navbar/TopBanner.jsx
@@ -1,6 +1,7 @@
import odooApi from '@/core/api/odooApi'
import { useQuery } from 'react-query'
import Image from 'next/image'
+import Link from '../Link/Link'
const TopBanner = () => {
const fetchTopBanner = async () => await odooApi('GET', '/api/v1/banner?type=top-banner')
@@ -10,13 +11,15 @@ const TopBanner = () => {
topBanner.isFetched &&
topBanner.data?.length > 0 && (
<div style={{ backgroundColor: topBanner.data[0]?.backgroundColor || 'transparent' }}>
- <Image
- src={topBanner.data[0].image}
- alt={topBanner.data[0].name}
- width={1440}
- height={40}
- className='object-cover object-center h-full mx-auto'
- />
+ <Link href={topBanner.data[0]?.url}>
+ <Image
+ src={topBanner.data[0].image}
+ alt={topBanner.data[0].name}
+ width={1440}
+ height={40}
+ className='object-cover object-center h-full mx-auto'
+ />
+ </Link>
</div>
)
)