-
Notifications
You must be signed in to change notification settings - Fork 14
/
adapter.ts
28 lines (26 loc) · 894 Bytes
/
adapter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { SignageTypeDictionary } from 'modules/signageType/interface';
import { getThumbnail } from 'modules/utils/adapter';
import { RawSignage, Signage, SignageDictionary } from './interface';
const adaptSignage = (
rawSignage: RawSignage,
signageTypeDictionary: SignageTypeDictionary,
): Signage => ({
id: rawSignage.id,
imageUrl: getThumbnail(rawSignage.attachments),
description: rawSignage.description,
geometry: rawSignage.geometry,
name: rawSignage.name,
type: signageTypeDictionary[rawSignage.type],
});
export const adaptSignages = ({
rawSignages,
signageTypeDictionary,
}: {
rawSignages: RawSignage[];
signageTypeDictionary: SignageTypeDictionary;
}): SignageDictionary | null => {
if (rawSignages.length === 0) {
return null;
}
return Object.fromEntries(rawSignages.map(signage => [signage.id, adaptSignage(signage, signageTypeDictionary)]));
};