webapp/src/components/_shared/ShowIfAuthenticated.tsx

19 lines
438 B
TypeScript
Raw Normal View History

2023-02-17 09:21:02 +00:00
import type { JSX } from 'solid-js'
import { Show } from 'solid-js'
import { useSession } from '../../context/session'
type ShowIfAuthenticatedProps = {
children: JSX.Element
fallback?: JSX.Element
}
export const ShowIfAuthenticated = (props: ShowIfAuthenticatedProps) => {
const { isAuthenticated } = useSession()
return (
<Show when={isAuthenticated()} fallback={props.fallback}>
{props.children}
</Show>
)
}