Expose landing_* readers, fix OTP contrast on dark modal, and keep auth badge/card submit loading consistent. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
export const LANDING_SETTING_PREFIXES = [
|
|
'landing_site',
|
|
'landing_header',
|
|
'landing_hero',
|
|
'landing_live_price',
|
|
'landing_calculator',
|
|
'landing_feature',
|
|
'landing_steps',
|
|
'landing_trust',
|
|
'landing_faq',
|
|
'landing_buttom_cta',
|
|
'landing_footer'
|
|
] as const
|
|
|
|
export type LandingSettingPrefix = (typeof LANDING_SETTING_PREFIXES)[number]
|
|
|
|
function isFlagOn(value: unknown): boolean {
|
|
const v = String(value ?? '').trim().toLowerCase()
|
|
return v === 'true' || v === '1' || v === 'yes' || v === 'activate'
|
|
}
|
|
|
|
export function isLandingEnabled(getByKey: (key: string) => unknown): boolean {
|
|
return isFlagOn(getByKey('has_landing'))
|
|
}
|
|
|
|
export function getLandingSetting(getByKey: (key: string) => unknown, key: string): string {
|
|
return String(getByKey(key) ?? '')
|
|
}
|
|
|
|
export function matchesLandingPrefix(key: string, prefix: string): boolean {
|
|
return key === prefix || key.startsWith(`${prefix}_`)
|
|
}
|
|
|
|
export function pickLandingSettings(
|
|
settings: Array<{ key?: string | number; value?: unknown }>,
|
|
prefix: string
|
|
): Record<string, string> {
|
|
const out: Record<string, string> = {}
|
|
for (const row of settings) {
|
|
const key = String(row.key ?? '')
|
|
if (!matchesLandingPrefix(key, prefix)) continue
|
|
out[key] = String(row.value ?? '')
|
|
}
|
|
return out
|
|
}
|