2023-02-17 09:21:02 +00:00
|
|
|
import type { JSX } from 'solid-js'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2023-02-17 09:21:02 +00:00
|
|
|
import { Show } from 'solid-js'
|
2023-11-14 15:10:00 +00:00
|
|
|
|
2023-02-17 09:21:02 +00:00
|
|
|
import { useSession } from '../../context/session'
|
|
|
|
|
|
|
|
type ShowIfAuthenticatedProps = {
|
|
|
|
children: JSX.Element
|
|
|
|
fallback?: JSX.Element
|
|
|
|
}
|
|
|
|
|
|
|
|
export const ShowIfAuthenticated = (props: ShowIfAuthenticatedProps) => {
|
2023-12-24 08:16:41 +00:00
|
|
|
const { author } = useSession()
|
2023-02-17 09:21:02 +00:00
|
|
|
|
|
|
|
return (
|
2023-12-24 08:16:41 +00:00
|
|
|
<Show when={author()} fallback={props.fallback}>
|
2023-02-17 09:21:02 +00:00
|
|
|
{props.children}
|
|
|
|
</Show>
|
|
|
|
)
|
|
|
|
}
|