Create ElementTransformer
Transforms elements from numbers into objects and back again
This commit is contained in:
parent
9adcd50519
commit
cb4fd491ac
2 changed files with 9 additions and 8 deletions
9
transformers/ElementTransformer.tsx
Normal file
9
transformers/ElementTransformer.tsx
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { elements } from '../utils/elements'
|
||||||
|
|
||||||
|
export function toObject(value: number) {
|
||||||
|
return elements.find((element) => element.id === value) || elements[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toParam(value: string) {
|
||||||
|
return elements.find((element) => element.name.en === value)
|
||||||
|
}
|
||||||
|
|
@ -63,11 +63,3 @@ export const elements: GranblueElement[] = [
|
||||||
slug: 'light',
|
slug: 'light',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
export function numberToElement(value: number) {
|
|
||||||
return elements.find((element) => element.id === value) || elements[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
export function stringToElement(value: string) {
|
|
||||||
return elements.find((element) => element.name.en === value)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue