refactor: refactor navigation components to use Link for improved routing
parent
4ae936b263
commit
9f724c19db
@ -1,33 +1,27 @@
|
|||||||
import { useRouter } from 'next/navigation'
|
import Link from 'next/link'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
type LinkProps = {
|
type OptionProps = {
|
||||||
Icon: React.ComponentType<{ className?: string }>
|
Icon: React.ComponentType<{ className?: string }>
|
||||||
text: string
|
text: string
|
||||||
href: string
|
href: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const Link = ({
|
const Option = ({
|
||||||
Icon,
|
Icon,
|
||||||
text,
|
text,
|
||||||
href,
|
href,
|
||||||
}: LinkProps) => {
|
}: OptionProps) => {
|
||||||
const { push } = useRouter()
|
|
||||||
|
|
||||||
const navigateTo = () => {
|
|
||||||
push(href)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<Link
|
||||||
type='button'
|
type='button'
|
||||||
className='flex w-full items-center gap-x-2 rounded-lg bg-transparent px-4 py-2 text-text-tertiary shadow-shadow-shadow-3 hover:bg-background-default-dodge hover:text-text-secondary hover:shadow-xs'
|
className='flex w-full items-center gap-x-2 rounded-lg bg-transparent px-4 py-2 text-text-tertiary shadow-shadow-shadow-3 hover:bg-background-default-dodge hover:text-text-secondary hover:shadow-xs'
|
||||||
onClick={navigateTo}
|
href={href}
|
||||||
>
|
>
|
||||||
<Icon className='h-4 w-4 shrink-0' />
|
<Icon className='h-4 w-4 shrink-0' />
|
||||||
<span className='system-sm-medium grow text-left'>{text}</span>
|
<span className='system-sm-medium grow text-left'>{text}</span>
|
||||||
</button>
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default React.memo(Link)
|
export default React.memo(Option)
|
||||||
Loading…
Reference in New Issue