城市合伙人端的修改(后台)
This commit is contained in:
@@ -48,6 +48,8 @@ function accountFromProfile(profile: PartnerSessionProfile): PartnerAccount {
|
||||
companyName: profile.companyName ?? '',
|
||||
isPrimary: profile.isPrimary ?? true,
|
||||
staffRole: profile.staffRole,
|
||||
permissions: profile.permissions,
|
||||
primaryAccountId: profile.primaryAccountId,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ const AUTH_RECOVERY_EXEMPT_PATHS = [
|
||||
'/partner/auth/login/wechat',
|
||||
];
|
||||
|
||||
export type PartnerSessionProfile = Pick<PartnerMe, 'id' | 'name' | 'phone' | 'companyName' | 'isPrimary'> & {
|
||||
export type PartnerSessionProfile = Pick<PartnerMe, 'id' | 'name' | 'phone' | 'companyName' | 'isPrimary' | 'permissions' | 'primaryAccountId'> & {
|
||||
staffRole?: PartnerStaffRole;
|
||||
};
|
||||
|
||||
@@ -104,6 +104,8 @@ function profileFromMe(me: PartnerMe): PartnerSessionProfile {
|
||||
companyName: me.companyName,
|
||||
isPrimary: me.isPrimary,
|
||||
staffRole: me.staffRole ?? undefined,
|
||||
permissions: me.permissions,
|
||||
primaryAccountId: me.primaryAccountId,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { PartnerMe } from '@dukang/shared-types';
|
||||
import type { PartnerMe, PartnerPermissionKey } from '@dukang/shared-types';
|
||||
|
||||
export function isPrimaryAccount(account: PartnerMe | null | undefined): boolean {
|
||||
return account?.isPrimary !== false;
|
||||
@@ -8,6 +8,15 @@ 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' : '/';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user