fix auth modal, lang picking

This commit is contained in:
tonyrewin 2022-09-24 13:34:57 +03:00
parent 3ae82ecb59
commit f4c974d1e1
3 changed files with 20 additions and 5 deletions

View File

@ -135,9 +135,11 @@ export default (props: { code?: string; mode?: string }) => {
// hiding itself if finished // hiding itself if finished
console.log('[auth] success, hiding modal') console.log('[auth] success, hiding modal')
hideModal() hideModal()
} else if (session().error) { } else if (session()?.error) {
console.log('[auth] failure, showing error') console.log('[auth] failure, showing error')
setError(t(statuses[session().error || 'unknown error'])) setError(t(statuses[session().error || 'unknown error']))
} else {
console.log('[auth] session', session())
} }
}, [session()]) }, [session()])
return ( return (

View File

@ -1,9 +1,10 @@
// FIXME: breaks on vercel, research // FIXME: breaks on vercel, research
// import 'solid-devtools' // import 'solid-devtools'
import { Component, createMemo, lazy } from 'solid-js' import { setLocale } from '../stores/ui'
import { Component, createEffect, createMemo, lazy } from 'solid-js'
import { Routes, useRouter } from '../stores/router' import { Routes, useRouter } from '../stores/router'
import { Dynamic } from 'solid-js/web' import { Dynamic, isServer } from 'solid-js/web'
import { getLogger } from '../utils/logger' import { getLogger } from '../utils/logger'
import type { PageProps } from './types' import type { PageProps } from './types'
@ -76,6 +77,14 @@ export const Root = (props: PageProps) => {
return result return result
}) })
// TODO: move MainLayout here
if (!isServer) {
createEffect(() => {
const lang = new URLSearchParams(window.location.search).get('lang') || 'ru'
console.log('[root] client locale is', lang)
setLocale(lang)
}, [window.location.search])
}
return <Dynamic component={pageComponent()} {...props} /> return <Dynamic component={pageComponent()} {...props} />
} }

View File

@ -1,8 +1,12 @@
--- ---
import { setLocale } from '../stores/ui';
import '../styles/app.scss' import '../styles/app.scss'
import { t } from '../utils/intl' import { t } from '../utils/intl'
const lang = Astro.url.searchParams.get('lang') const lang = Astro.url.searchParams.get('lang') || 'ru'
console.log('[layout] server locale is', lang)
setLocale(lang)
--- ---
<html lang={lang || 'ru'}> <html lang={lang || 'ru'}>
<head> <head>