Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/utils/src/us-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
// 与 packages/tryit/src/utils/app-id.ts、BaseLayout 的 apiProxyBootstrap 中的美国租户 app_id 一致
const US_APP_IDS = ['longbridge_us', 'longbridge_us_uat']

/** Longbridge US Terms of Service / Privacy Policy (PDF) */
export const US_LEGAL_LINKS = {
terms: 'https://assets.lbkrs.com/uploads/317ef02f-85e7-4afa-9e76-8acd8c0b42fe/Terms-of-Service-final-.pdf',
privacy: 'https://assets.lbkrs.com/uploads/e4890745-e18b-42f2-9817-da63148e0ac4/Privacy-Policy-final-.pdf',
}

let cached: Promise<boolean> | undefined

function readCookie(name: string): string | undefined {
Expand Down
23 changes: 19 additions & 4 deletions src/components/shell/DocFooter.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ const { locale } = Astro.props
const lp = (path: string) => (locale === 'en' ? path : `/${locale}${path}`)
const sgBase = locale === 'en' ? 'https://longbridge.com/sg' : 'https://longbridge.com/sg/zh-CN'

type Link = { label: string; href: string; ext?: boolean }
type Link = { label: string; href: string; ext?: boolean; legal?: 'terms' | 'privacy' }

const leftLinks: Link[] = [
{ label: 'Longbridge', href: 'https://longbridge.com', ext: true },
{ label: t(locale, 'footer.download'), href: 'https://longbridge.com/download', ext: true },
{ label: t(locale, 'footer.terms'), href: `${sgBase}/support/topics/us-trade/user-agreement`, ext: true },
{ label: t(locale, 'footer.privacy'), href: `${sgBase}/support/topics/Other/privacy-policy`, ext: true },
{ label: t(locale, 'footer.terms'), href: `${sgBase}/support/topics/us-trade/user-agreement`, ext: true, legal: 'terms' },
{ label: t(locale, 'footer.privacy'), href: `${sgBase}/support/topics/Other/privacy-policy`, ext: true, legal: 'privacy' },
]

const rightLinks: Link[] = [
Expand All @@ -45,7 +45,7 @@ const rightLinks: Link[] = [
<div class="docs-doc-footer__group">
{
leftLinks.map((l) => (
<a href={l.href} {...(l.ext ? { target: '_blank', rel: 'noreferrer' } : {})}>
<a href={l.href} data-legal={l.legal} {...(l.ext ? { target: '_blank', rel: 'noreferrer' } : {})}>
{l.label}
</a>
))
Expand All @@ -66,3 +66,18 @@ const rightLinks: Link[] = [
</a>
</div>
</footer>

<script>
// Statically rendered: swap Terms / Privacy to the US versions on the client for US users (see isUSUser)
import { isUSUser, US_LEGAL_LINKS } from '@longbridge/openapi-utils'

function applyUSLegalLinks() {
isUSUser().then((isUS) => {
if (!isUS) return
document.querySelectorAll<HTMLAnchorElement>('[data-lbus-component="docs-footer"] a[data-legal]').forEach((a) => {
a.href = a.dataset.legal === 'terms' ? US_LEGAL_LINKS.terms : US_LEGAL_LINKS.privacy
})
})
}
document.addEventListener('astro:page-load', applyUSLegalLinks)
</script>
13 changes: 10 additions & 3 deletions src/components/shell/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { t } from '@longbridge/openapi-utils'
import { useEffect, useState } from 'react'
import { t, isUSUser, US_LEGAL_LINKS } from '@longbridge/openapi-utils'
import type { Locale } from '@longbridge/openapi-utils'

interface Props {
Expand All @@ -22,6 +23,12 @@ function sgBaseUrl(locale: Locale): string {
export default function Footer({ locale }: Props) {
const year = new Date().getFullYear()
const base = sgBaseUrl(locale)
const [isUS, setIsUS] = useState(false)
useEffect(() => {
isUSUser().then(setIsUS)
}, [])
const termsHref = isUS ? US_LEGAL_LINKS.terms : `${base}/support/topics/us-trade/user-agreement`
const privacyHref = isUS ? US_LEGAL_LINKS.privacy : `${base}/support/topics/Other/privacy-policy`
const homeHref = locale === 'en' ? '/' : `/${locale}/`

return (
Expand Down Expand Up @@ -121,7 +128,7 @@ export default function Footer({ locale }: Props) {
<li>
<a
className="text-[color:var(--lb-fg-2)] no-underline text-[0.85rem] leading-6 hover:text-[color:var(--lb-brand)]"
href={`${base}/support/topics/us-trade/user-agreement`}
href={termsHref}
target="_blank"
rel="noreferrer"
>
Expand All @@ -131,7 +138,7 @@ export default function Footer({ locale }: Props) {
<li>
<a
className="text-[color:var(--lb-fg-2)] no-underline text-[0.85rem] leading-6 hover:text-[color:var(--lb-brand)]"
href={`${base}/support/topics/Other/privacy-policy`}
href={privacyHref}
target="_blank"
rel="noreferrer"
>
Expand Down
Loading