mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-02-24 10:56:21 -05:00
* Test * Add pretty formatting * Fix Tests * Fix Tests * Fix Tests * Fix * Add pretty formatting fix * Fix * Test * Fix tests * Clean typeckech * Add prettier check * Fix api tsconfig * Fix api tsconfig * Fix tsconfig * Fix * Fix * Prettier
26 lines
839 B
TypeScript
26 lines
839 B
TypeScript
import {ArrowLeftIcon} from '@heroicons/react/solid'
|
|
import clsx from 'clsx'
|
|
import {useRouter} from 'next/navigation'
|
|
import {useEffect, useState} from 'react'
|
|
import {Button} from 'web/components/buttons/button'
|
|
|
|
export function BackButton(props: {className?: string}) {
|
|
const {className} = props
|
|
const router = useRouter()
|
|
const [canGoBack, setCanGoBack] = useState(false)
|
|
|
|
// Can't put this in a useMemo to avoid the page jump else we'll get hydration errors.
|
|
useEffect(() => {
|
|
setCanGoBack(typeof window !== 'undefined' && window.history.length > 1)
|
|
}, [])
|
|
|
|
if (!canGoBack) return null
|
|
|
|
return (
|
|
<Button className={clsx('rounded-none', className)} onClick={router.back} color={'gray-white'}>
|
|
<ArrowLeftIcon className="h-5 w-5" aria-hidden />
|
|
<div className="sr-only">Back</div>
|
|
</Button>
|
|
)
|
|
}
|