webapp/src/components/_shared/ShowIfAuthenticated.tsx
Untone 9a55056b9d
Some checks failed
deploy / test (push) Failing after 1m2s
deploy / deploy (push) Has been skipped
session-fx
2023-12-24 11:16:41 +03:00

21 lines
422 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 { author } = useSession()
return (
<Show when={author()} fallback={props.fallback}>
{props.children}
</Show>
)
}