remove unused
This commit is contained in:
@@ -1,56 +0,0 @@
|
|||||||
import type { Admin } from '../entities/admin.entity';
|
|
||||||
|
|
||||||
export interface AdminDetailResponse {
|
|
||||||
id: string;
|
|
||||||
firstName?: string;
|
|
||||||
lastName?: string;
|
|
||||||
phone: string;
|
|
||||||
role: {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
};
|
|
||||||
permissions: string[];
|
|
||||||
shop?: {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
slug: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export class AdminDetailTransformer {
|
|
||||||
static transform(admin: Admin, shopId?: string): AdminDetailResponse | null {
|
|
||||||
if (!admin) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract role information - filter by shop if shopId is provided
|
|
||||||
const adminRoles = admin.roles.getItems();
|
|
||||||
const adminRole = shopId
|
|
||||||
? adminRoles.find(r => r.role && r.shop?.id === shopId)
|
|
||||||
: adminRoles.find(r => r.role);
|
|
||||||
|
|
||||||
if (!adminRole || !adminRole.role) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const role = adminRole.role;
|
|
||||||
return {
|
|
||||||
id: admin.id,
|
|
||||||
firstName: admin.firstName,
|
|
||||||
lastName: admin.lastName,
|
|
||||||
phone: admin.phone,
|
|
||||||
role: {
|
|
||||||
id: role.id,
|
|
||||||
name: role.name,
|
|
||||||
},
|
|
||||||
permissions: role.permissions.getItems().map(p => p.name) || [],
|
|
||||||
shop: {
|
|
||||||
id: adminRole.shop?.id || '',
|
|
||||||
name: adminRole.shop?.name || '',
|
|
||||||
slug: adminRole.shop?.slug || '',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract permissions - ensure collection is loaded if needed
|
|
||||||
Reference in New Issue
Block a user