This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
forked from helium/maker-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
57 lines (49 loc) · 1.55 KB
/
index.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import example from './example'
import customAntennas from './custom/antennas'
import { LangType, supportedLangs } from '../utils/i18n/i18nTypes'
import { HotspotMakerLangField } from './hotspotMakerTypes'
export const Makers: Record<string, { id: number; supportEmail: string }> = {
example,
}
export const AntennaModels = {
...example.antennas,
...customAntennas,
}
export const HotspotMakerModels = {
...example.hotspots,
}
export type HotspotType = keyof typeof HotspotMakerModels
export const HotspotModelKeys = Object.keys(
HotspotMakerModels,
).sort() as HotspotType[]
export const HotspotTypeCount = HotspotModelKeys.length
type MakerLangType = Record<
HotspotType,
Record<
HotspotMakerLangField,
string | { title: string; body: string; button: string }[]
>
>
export const getTranslations = () => {
const trans: Record<LangType, MakerLangType> = {
en: {} as MakerLangType,
ko: {} as MakerLangType,
zh: {} as MakerLangType,
ja: {} as MakerLangType,
}
supportedLangs.forEach((l) => {
HotspotModelKeys.forEach((ht) => {
trans[l][ht] = HotspotMakerModels[ht].translations[l]
})
})
return trans
}
export type AntennaType = keyof typeof AntennaModels
export const AntennaModelKeys = Object.keys(
AntennaModels,
).sort() as AntennaType[]
export const AntennaTypeCount = AntennaModelKeys.length
export const getMakerSupportEmail = (makerId?: number): string => {
const makerKey = Object.keys(Makers).find((m) => Makers[m].id === makerId)
return makerKey ? Makers[makerKey].supportEmail : 'support@helium.com'
}