({
className,
showLogo = true,
fallbackPath,
}: WithClassNameProps & {
showLogo?: boolean;
fallbackPath?: string;
})
| 31 | }; |
| 32 | |
| 33 | export const GoBackButton = ({ |
| 34 | className, |
| 35 | showLogo = true, |
| 36 | fallbackPath, |
| 37 | }: WithClassNameProps & { |
| 38 | showLogo?: boolean; |
| 39 | fallbackPath?: string; |
| 40 | }): JSX.Element | null => { |
| 41 | const router = useRouter(); |
| 42 | const goHome = useCallback(() => router.push('/'), [router]); |
| 43 | const featureTheme = useFeatureTheme(); |
| 44 | |
| 45 | const canGoBack = |
| 46 | globalThis?.history?.length > 1 && (checkSameSite() || isDevelopment); |
| 47 | |
| 48 | const goBack = useCallback(() => { |
| 49 | if (canGoBack) { |
| 50 | router.back(); |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | if (fallbackPath) { |
| 55 | router.push(fallbackPath); |
| 56 | } |
| 57 | }, [canGoBack, fallbackPath, router]); |
| 58 | |
| 59 | const logoButton = showLogo ? ( |
| 60 | <Logo |
| 61 | className="my-2" |
| 62 | onLogoClick={goHome} |
| 63 | position={LogoPosition.Initial} |
| 64 | featureTheme={featureTheme} |
| 65 | /> |
| 66 | ) : null; |
| 67 | |
| 68 | return canGoBack || fallbackPath ? ( |
| 69 | <Button |
| 70 | icon={<ArrowIcon className="-rotate-90" />} |
| 71 | size={ButtonSize.Small} |
| 72 | variant={ButtonVariant.Tertiary} |
| 73 | onClick={goBack} |
| 74 | className={className} |
| 75 | type="button" |
| 76 | aria-label="Go back" |
| 77 | /> |
| 78 | ) : ( |
| 79 | logoButton |
| 80 | ); |
| 81 | }; |
| 82 | |
| 83 | export function GoBackHeaderMobile({ |
| 84 | children, |
nothing calls this directly
no test coverage detected