import { Ico, Icon } from "components/Ico"; import { cIf, cJoin } from "helpers/className"; import { ConditionalWrapper, Wrapper } from "helpers/component"; import { isDefined, isDefinedAndNotEmpty } from "helpers/others"; import { useRouter } from "next/router"; import React, { MouseEventHandler } from "react"; interface Props { id?: string; className?: string; href?: string; active?: boolean; icon?: Icon; text?: string | null | undefined; locale?: string; target?: "_blank"; onClick?: MouseEventHandler; draggable?: boolean; badgeNumber?: number; } export function Button(props: Props): JSX.Element { const { draggable, id, onClick, active, className, icon, text, target, href, locale, badgeNumber, } = props; const router = useRouter(); return (
{ if (isDefined(href) || isDefined(locale)) { router.push(href ?? router.asPath, href, { locale: locale, }); } }} >
{isDefined(badgeNumber) && (

{badgeNumber}

)} {isDefinedAndNotEmpty(icon) && ( )} {isDefinedAndNotEmpty(text) && (

{text}

)}
); } interface LinkWrapperProps { href?: string; } function LinkWrapper(props: LinkWrapperProps & Wrapper) { const { children, href } = props; return ( {children} ); }