Skip to content

Commit 2488f67

Browse files
committed
fix translation logic
1 parent 3142e1a commit 2488f67

18 files changed

Lines changed: 79 additions & 44 deletions

src/i18n/useTranslation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import { helpwaveIdTranslation, type HelpwaveIdTranslationLocales } from './tran
33

44
export function useTranslation(locale?: string) {
55
const lang = (locale ?? 'en') as HelpwaveIdTranslationLocales
6+
console.log(locale, lang)
67
return combineTranslation(helpwaveIdTranslation, lang)
7-
}
8+
}

src/index.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@
1212
--hw-color-secondary-800: #1f2937;
1313
--hw-color-secondary-900: #111827;
1414
}
15+
16+
@layer base {
17+
body {
18+
min-height: 100vh;
19+
background-color: var(--hw-color-background) !important;
20+
}
21+
}

src/login/KcPage.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ export default function KcPage(props: { kcContext: KcContext }) {
129129
return <WebauthnError kcContext={kcContext} />
130130
case 'webauthn-register.ftl':
131131
return <WebauthnRegister kcContext={kcContext} />
132-
default:
132+
default: {
133+
const fallback = kcContext as KcContext
133134
return (
134135
<div>
135-
<p>Page not implemented: {kcContext.pageId}</p>
136+
<p>Page not implemented: {fallback.pageId}</p>
136137
</div>
137138
)
139+
}
138140
}
139141
})()}
140142
</Suspense>

src/login/pages/FrontchannelLogout.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,18 @@ export default function FrontchannelLogout({ kcContext }: FrontchannelLogoutProp
3434
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
3535
<p>{t('frontchannelLogoutMessage')}</p>
3636

37-
<form id="kc-frontchannel-logout-form" action={kcContext.url.logoutAction} method="POST" style={{ display: 'none' }}>
38-
{kcContext.frontchannelLogout?.map((url) => (
39-
<iframe key={url} src={url} style={{ display: 'none' }} />
37+
<form
38+
id="kc-frontchannel-logout-form"
39+
action={(kcContext.url as { logoutAction?: string }).logoutAction ?? '#'}
40+
method="POST"
41+
style={{ display: 'none' }}
42+
>
43+
{kcContext.logout.clients.map((client) => (
44+
<iframe
45+
key={client.frontChannelLogoutUrl}
46+
src={client.frontChannelLogoutUrl}
47+
style={{ display: 'none' }}
48+
/>
4049
))}
4150
<Button type="submit" color="primary">
4251
{t('doContinue')}

src/login/pages/LoginConfigTotp.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export default function LoginConfigTotp({ kcContext }: LoginConfigTotpProps) {
5252
</div>
5353
)}
5454

55-
{kcContext.totp?.qrCode && (
55+
{kcContext.totp?.qrUrl && (
5656
<div style={{ marginBottom: '1rem', textAlign: 'center' }}>
57-
<img src={`data:image/png;base64,${kcContext.totp.qrCode}`} alt="TOTP QR Code" style={{ maxWidth: '200px' }} />
57+
<img src={kcContext.totp.qrUrl} alt="TOTP QR Code" style={{ maxWidth: '200px' }} />
5858
<p style={{ marginTop: '0.5rem', fontSize: '0.875rem' }}>
5959
{t('loginTotpScanBarcode')}
6060
</p>

src/login/pages/LoginOauthGrant.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export default function LoginOauthGrant({ kcContext }: LoginOauthGrantProps) {
3333
<div style={{ marginBottom: '1rem' }}>
3434
<h3>{t('oauthGrantScopes')}</h3>
3535
<ul>
36-
{kcContext.oauth.clientScopesRequested.map((scope) => (
37-
<li key={scope.name}>{scope.displayName ?? scope.name}</li>
36+
{kcContext.oauth.clientScopesRequested.map((scope, index) => (
37+
<li key={scope.dynamicScopeParameter ?? index}>{scope.consentScreenText}</li>
3838
))}
3939
</ul>
4040
</div>

src/login/pages/LoginPasskeysConditionalAuthenticate.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useI18n } from '../i18n'
44
import Template from 'keycloakify/login/Template'
55
import { PageLayout } from '../components/PageLayout'
66
import { useEffect } from 'react'
7+
import { useTranslation } from '../../i18n/useTranslation'
78

89
type LoginPasskeysConditionalAuthenticateProps = {
910
kcContext: Extract<KcContext, { pageId: 'login-passkeys-conditional-authenticate.ftl' }>,
@@ -14,16 +15,17 @@ export default function LoginPasskeysConditionalAuthenticate({ kcContext }: Logi
1415
const locale = kcContext.locale?.currentLanguageTag ?? 'en'
1516
const t = useTranslation(locale)
1617

18+
const webauthnScriptUrl = (kcContext.url as { webauthnScriptUrl?: string }).webauthnScriptUrl
1719
useEffect(() => {
20+
if (!webauthnScriptUrl) return
1821
const script = document.createElement('script')
19-
script.src = kcContext.url.webauthnScriptUrl
22+
script.src = webauthnScriptUrl
2023
script.async = true
2124
document.body.appendChild(script)
22-
2325
return () => {
2426
document.body.removeChild(script)
2527
}
26-
}, [kcContext.url.webauthnScriptUrl])
28+
}, [webauthnScriptUrl])
2729

2830
return (
2931
<Template

src/login/pages/LoginResetOtp.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ type LoginResetOtpProps = {
1111

1212
export default function LoginResetOtp({ kcContext }: LoginResetOtpProps) {
1313
const { i18n } = useI18n({ kcContext })
14+
const locale = kcContext.locale?.currentLanguageTag ?? 'en'
15+
const t = useTranslation(locale)
1416

1517
return (
1618
<Template

src/login/pages/LoginUpdateProfile.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ type LoginUpdateProfileProps = {
1212

1313
export default function LoginUpdateProfile({ kcContext }: LoginUpdateProfileProps) {
1414
const { i18n } = useI18n({ kcContext })
15+
const locale = kcContext.locale?.currentLanguageTag ?? 'en'
16+
const t = useTranslation(locale)
1517

1618
const profile = kcContext.profile
1719
const attributes = profile?.attributesByName ?? {}

src/login/pages/LoginUsername.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { KcContext } from '../KcContext'
44
import { useI18n } from '../i18n'
55
import Template from 'keycloakify/login/Template'
66
import { PageLayout } from '../components/PageLayout'
7+
import { useTranslation } from '../../i18n/useTranslation'
78

89
type LoginUsernameProps = {
910
kcContext: Extract<KcContext, { pageId: 'login-username.ftl' }>,

0 commit comments

Comments
 (0)