admin/lib/viewerDiscoveryCity.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

16 lines
627 B
TypeScript

/**
* Viewer city for discovery lists (home popular/category, category landing).
*
* - Guest / incomplete profile → no city filter (nationwide — marketing cold start)
* - Logged-in with `profile.cityId` → that city
*
* City-scoped URLs (`/city/...`, category+city combo) always use the URL city
* and do not call this helper. Home city-preview strip is separate (cookie).
*/
export function resolveViewerDiscoveryCityId(profileCityId: number | null | undefined, isLoggedIn: boolean): number | undefined {
if (!isLoggedIn) return undefined
if (profileCityId == null) return undefined
return profileCityId
}