fix: landing list crash — title is now LocaleDict, not string

- Update LandingListItem.title type to LocaleDict
- Add resolveLocaleDisplay() helper for extracting display string
- Use resolveLocaleDisplay() in landing list and delete confirm
This commit is contained in:
Fringg
2026-03-06 17:00:05 +03:00
parent 6a92814ce2
commit 6755c1dc45
2 changed files with 13 additions and 4 deletions

View File

@@ -108,7 +108,7 @@ export interface AdminLandingFeature {
export interface LandingListItem {
id: number;
slug: string;
title: string;
title: LocaleDict;
is_active: boolean;
display_order: number;
gift_enabled: boolean;
@@ -167,6 +167,13 @@ export type LandingUpdateRequest = Partial<LandingCreateRequest>;
* If it's a string, wraps it as `{ ru: value }`.
* If null/undefined, returns the fallback.
*/
/** Extract best display string from a LocaleDict: ru → en → first available → '' */
export function resolveLocaleDisplay(dict: LocaleDict | string | null | undefined): string {
if (!dict) return '';
if (typeof dict === 'string') return dict;
return dict.ru || dict.en || Object.values(dict).find((v) => v?.trim()) || '';
}
export function toLocaleDict(
value: string | LocaleDict | null | undefined,
fallback: LocaleDict = {},