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): AdminDetailResponse | null { if (!admin) { return null; } // Extract role information const role = admin.roles.getItems().find(r => r.role)?.role; if (!role) { return null; } 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: role.shop?.id || '', name: role.shop?.name || '', slug: role.shop?.slug || '', }, }; } } // Extract permissions - ensure collection is loaded if needed