23 lines
781 B
TypeScript
23 lines
781 B
TypeScript
import type { PartnerMe } from '@dukang/shared-types';
|
|
|
|
export function isPrimaryAccount(account: PartnerMe | null | undefined): boolean {
|
|
return account?.isPrimary !== false;
|
|
}
|
|
|
|
export function isSubAccount(account: PartnerMe | null | undefined): boolean {
|
|
return !!account && account.isPrimary === false;
|
|
}
|
|
|
|
export function partnerHomePath(account: PartnerMe | null | undefined): string {
|
|
return isSubAccount(account) ? '/stores/new?step=1' : '/';
|
|
}
|
|
|
|
export const SUB_ACCOUNT_ALLOWED_PREFIXES = ['/stores', '/login'];
|
|
|
|
export function isSubAccountPath(pathname: string): boolean {
|
|
if (pathname === '/login') return true;
|
|
return SUB_ACCOUNT_ALLOWED_PREFIXES.some(
|
|
(prefix) => prefix !== '/login' && (pathname === prefix || pathname.startsWith(`${prefix}/`)),
|
|
);
|
|
}
|