File size: 521 Bytes
3206347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import permissionSerializer from './permission.js';

const roleSerializer = (role) => {
  let roleData = {
    id: role.id,
    name: role.name,
    key: role.key,
    description: role.description,
    createdAt: role.createdAt.getTime(),
    updatedAt: role.updatedAt.getTime(),
    isAdmin: role.isAdmin,
  };

  if (role.permissions?.length > 0) {
    roleData.permissions = role.permissions.map((permission) =>
      permissionSerializer(permission)
    );
  }

  return roleData;
};

export default roleSerializer;