webapp/src/components/_shared/ShowIfAuthenticated.tsx
2024-06-24 20:50:27 +03:00

21 lines
438 B
TypeScript

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 { session } = useSession()
return (
<Show when={session()?.access_token} fallback={props.fallback}>
{props.children}
</Show>
)
}