63af3321dd
支持 HQ 账户改手机号(格式校验)、合伙人日志包含子账号且子账号不显示主账号信息;改手机号时清除微信绑定。合伙人 H5 子账号页签与我的页、录入门店底部按钮及上传失败提示。 Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import type { PartnerMe, PartnerPermissionKey } 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 hasPartnerPermission(
|
|
account: PartnerMe | null | undefined,
|
|
permission: PartnerPermissionKey,
|
|
): boolean {
|
|
if (!account) return false;
|
|
if (isPrimaryAccount(account)) return true;
|
|
return account.permissions?.includes(permission) ?? false;
|
|
}
|
|
|
|
export function partnerHomePath(account: PartnerMe | null | undefined): string {
|
|
return isSubAccount(account) ? '/stores/new?step=1' : '/';
|
|
}
|
|
|
|
export const SUB_ACCOUNT_ALLOWED_PREFIXES = ['/stores', '/me', '/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}/`)),
|
|
);
|
|
}
|