import Link from 'next/link' import { useTranslation } from 'next-i18next' import { useAccount } from 'shared/hooks/use-account.mjs' import { roles } from 'config/roles.mjs' export const ns = ['auth'] const Wrap = ({ children }) => (
{children}
) const ContactSupport = ({ t }) => (
{t('contactSupport')}
) const AuthRequired = ({ t }) => (

{t('authRequired')}

{t('membersOnly')}

{t('signUp')} {t('signIn')}
) const AccountInactive = ({ t }) => (

{t('accountInactive')}

{t('accountInactiveMsg')}

{t('signupAgain')}

{t('signUp')}
) const AccountDisabled = ({ t }) => (

{t('accountDisabled')}

{t('accountDisabledMsg')}

) const AccountProhibited = ({ t }) => (

{t('accountProhibited')}

{t('accountProhibitedMsg')}

) const AccountStatusUnknown = ({ t }) => (

{t('statusUnknown')}

{t('statusUnknownMsg')}

) const RoleLacking = ({ t, requiredRole, role }) => (

{t('roleLacking')}

) const ConsentLacking = ({ t }) => (

{t('consentLacking')}

{t('membersOnly')}

{t('signUp')} {t('signIn')}
) export const AuthWrapper = ({ children, app, requiredRole = 'user' }) => { const { t } = useTranslation(ns) const { account, token } = useAccount() if (!token || !account.username) return if (account.status !== 1) { if (account.status === 0) return if (account.status === -1) return if (account.status === -2) return return } if (account.consent < 1) return if (!roles.levels[account.role] || roles.levels[account.role] < roles.levels[requiredRole]) { return } return children }