admin/lib/accountSuspension.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
683 B
TypeScript

export const ACCOUNT_SUSPENSION_STORAGE_KEY = 'accountSuspended'
export const ACCOUNT_SUSPENSION_CHANGED_EVENT = 'accountSuspensionChanged'
const isClient = () => typeof window !== 'undefined'
export const isAccountSuspended = (): boolean => isClient() && window.localStorage.getItem(ACCOUNT_SUSPENSION_STORAGE_KEY) === 'true'
export const setAccountSuspended = (suspended: boolean): void => {
if (!isClient()) return
if (suspended) window.localStorage.setItem(ACCOUNT_SUSPENSION_STORAGE_KEY, 'true')
else window.localStorage.removeItem(ACCOUNT_SUSPENSION_STORAGE_KEY)
window.dispatchEvent(new CustomEvent(ACCOUNT_SUSPENSION_CHANGED_EVENT, { detail: { suspended } }))
}