WIP checkpoint
abandoning this though
This commit is contained in:
parent
973e7f34da
commit
31b590a542
8 changed files with 133 additions and 50 deletions
|
|
@ -9,6 +9,7 @@ import 'fix-date'
|
||||||
import { accountState } from '~utils/accountState'
|
import { accountState } from '~utils/accountState'
|
||||||
import { formatTimeAgo } from '~utils/timeAgo'
|
import { formatTimeAgo } from '~utils/timeAgo'
|
||||||
import { ElementMap } from '~utils/elements'
|
import { ElementMap } from '~utils/elements'
|
||||||
|
import { mapToGridArray } from '~utils/mapToGridArray'
|
||||||
|
|
||||||
import Button from '~components/common/Button'
|
import Button from '~components/common/Button'
|
||||||
|
|
||||||
|
|
@ -73,9 +74,18 @@ const GridRep = (props: Props) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (props.weapons && props.weapons.mainWeapon) {
|
||||||
setMainhand(props.weapons.mainWeapon?.object)
|
setMainhand(props.weapons.mainWeapon?.object)
|
||||||
setWeapons(Object.values(props.weapons.allWeapons).map((w) => w?.object))
|
}
|
||||||
|
|
||||||
|
if (props.weapons && props.weapons.allWeapons) {
|
||||||
|
setWeapons(
|
||||||
|
mapToGridArray(
|
||||||
|
Object.values(props.weapons.allWeapons).map((w) => w?.object)
|
||||||
|
)
|
||||||
|
)
|
||||||
setGrid(props.weapons.allWeapons)
|
setGrid(props.weapons.allWeapons)
|
||||||
|
}
|
||||||
}, [props.weapons])
|
}, [props.weapons])
|
||||||
|
|
||||||
function navigate() {
|
function navigate() {
|
||||||
|
|
@ -86,7 +96,7 @@ const GridRep = (props: Props) => {
|
||||||
let url = ''
|
let url = ''
|
||||||
|
|
||||||
if (mainhand) {
|
if (mainhand) {
|
||||||
const weapon = props.weapons.mainWeapon
|
const weapon = props.weapons?.mainWeapon
|
||||||
|
|
||||||
if (mainhand.element === ElementMap.null && weapon && weapon.element) {
|
if (mainhand.element === ElementMap.null && weapon && weapon.element) {
|
||||||
url = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-main/${mainhand.granblueId}_${weapon.element}.jpg`
|
url = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-main/${mainhand.granblueId}_${weapon.element}.jpg`
|
||||||
|
|
@ -190,7 +200,7 @@ const GridRep = (props: Props) => {
|
||||||
{` · ${t('party.details.labels.full_auto')}`}
|
{` · ${t('party.details.labels.full_auto')}`}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{props.raid && props.raid.group.extra && (
|
{props.raid && props.raid.group?.extra && (
|
||||||
<span className={styles.extra}>{` · EX`}</span>
|
<span className={styles.extra}>{` · EX`}</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import * as CharacterTransformer from '~transformers/CharacterTransformer'
|
||||||
import * as GridCharacterTransformer from '~transformers/GridCharacterTransformer'
|
import * as GridCharacterTransformer from '~transformers/GridCharacterTransformer'
|
||||||
|
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
import { use } from 'i18next'
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|
@ -77,16 +78,36 @@ const CharacterGrid = (props: Props) => {
|
||||||
[key: number]: number | undefined
|
[key: number]: number | undefined
|
||||||
}>({})
|
}>({})
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.log('loading chara grid')
|
||||||
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setJob(appState.party.protagonist.job)
|
setJob(appState.party.protagonist.job)
|
||||||
setJobSkills(appState.party.protagonist.skills)
|
setJobSkills(
|
||||||
setJobAccessory(appState.party.protagonist.accessory)
|
appState.party.protagonist.skills
|
||||||
}, [appState])
|
? appState.party.protagonist.skills
|
||||||
|
: {
|
||||||
|
0: undefined,
|
||||||
|
1: undefined,
|
||||||
|
2: undefined,
|
||||||
|
3: undefined,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
setJobAccessory(
|
||||||
|
appState.party.protagonist.accessory
|
||||||
|
? appState.party.protagonist.accessory
|
||||||
|
: undefined
|
||||||
|
)
|
||||||
|
}, [])
|
||||||
|
|
||||||
// Initialize an array of current uncap values for each characters
|
// Initialize an array of current uncap values for each characters
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let initialPreviousUncapValues: { [key: number]: number } = {}
|
let initialPreviousUncapValues: { [key: number]: number } = {}
|
||||||
Object.values(appState.party.grid.characters).map((o) => {
|
const values = appState.party.grid.characters
|
||||||
|
? appState.party.grid.characters
|
||||||
|
: {}
|
||||||
|
Object.values(values).map((o) => {
|
||||||
o ? (initialPreviousUncapValues[o.position] = o.uncapLevel) : 0
|
o ? (initialPreviousUncapValues[o.position] = o.uncapLevel) : 0
|
||||||
})
|
})
|
||||||
setPreviousUncapValues(initialPreviousUncapValues)
|
setPreviousUncapValues(initialPreviousUncapValues)
|
||||||
|
|
@ -151,7 +172,11 @@ const CharacterGrid = (props: Props) => {
|
||||||
|
|
||||||
function storeGridCharacter(data: any) {
|
function storeGridCharacter(data: any) {
|
||||||
const gridCharacter = GridCharacterTransformer.toObject(data)
|
const gridCharacter = GridCharacterTransformer.toObject(data)
|
||||||
appState.party.grid.characters[gridCharacter.position] = gridCharacter
|
|
||||||
|
appState.party.grid.characters = {
|
||||||
|
...appState.party.grid.characters,
|
||||||
|
[gridCharacter.position]: gridCharacter,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveConflict() {
|
async function resolveConflict() {
|
||||||
|
|
@ -169,7 +194,11 @@ const CharacterGrid = (props: Props) => {
|
||||||
|
|
||||||
// Remove conflicting characters from state
|
// Remove conflicting characters from state
|
||||||
conflicts.forEach(
|
conflicts.forEach(
|
||||||
(c) => (appState.party.grid.characters[c.position] = null)
|
(c) =>
|
||||||
|
(appState.party.grid.characters = {
|
||||||
|
...appState.party.grid.characters,
|
||||||
|
[c.position]: null,
|
||||||
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reset conflict
|
// Reset conflict
|
||||||
|
|
@ -191,7 +220,10 @@ const CharacterGrid = (props: Props) => {
|
||||||
async function removeCharacter(id: string) {
|
async function removeCharacter(id: string) {
|
||||||
try {
|
try {
|
||||||
const response = await api.endpoints.grid_characters.destroy({ id: id })
|
const response = await api.endpoints.grid_characters.destroy({ id: id })
|
||||||
appState.party.grid.characters[response.data.position] = null
|
appState.party.grid.characters = {
|
||||||
|
...appState.party.grid.characters,
|
||||||
|
[response.data.position]: null,
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
|
@ -383,10 +415,13 @@ const CharacterGrid = (props: Props) => {
|
||||||
position: number,
|
position: number,
|
||||||
uncapLevel: number | undefined
|
uncapLevel: number | undefined
|
||||||
) => {
|
) => {
|
||||||
const character = appState.party.grid.characters[position]
|
const character = appState.party.grid.characters?.[position]
|
||||||
if (character && uncapLevel) {
|
if (character && uncapLevel) {
|
||||||
character.uncapLevel = uncapLevel
|
character.uncapLevel = uncapLevel
|
||||||
appState.party.grid.characters[position] = character
|
appState.party.grid.characters = {
|
||||||
|
...appState.party.grid.characters,
|
||||||
|
[position]: character,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -394,7 +429,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
// Save the current value in case of an unexpected result
|
// Save the current value in case of an unexpected result
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousValues = { ...previousUncapValues }
|
||||||
|
|
||||||
if (party.grid.characters[position]) {
|
if (party.grid.characters && party.grid.characters[position]) {
|
||||||
newPreviousValues[position] = party.grid.characters[position]?.uncapLevel
|
newPreviousValues[position] = party.grid.characters[position]?.uncapLevel
|
||||||
setPreviousUncapValues(newPreviousValues)
|
setPreviousUncapValues(newPreviousValues)
|
||||||
}
|
}
|
||||||
|
|
@ -479,10 +514,13 @@ const CharacterGrid = (props: Props) => {
|
||||||
position: number,
|
position: number,
|
||||||
stage: number | undefined
|
stage: number | undefined
|
||||||
) => {
|
) => {
|
||||||
const character = appState.party.grid.characters[position]
|
const character = appState.party.grid.characters?.[position]
|
||||||
if (character && stage !== undefined) {
|
if (character && stage !== undefined) {
|
||||||
character.transcendenceStep = stage
|
character.transcendenceStep = stage
|
||||||
appState.party.grid.characters[position] = character
|
appState.party.grid.characters = {
|
||||||
|
...appState.party.grid.characters,
|
||||||
|
[position]: character,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -490,7 +528,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
// Save the current value in case of an unexpected result
|
// Save the current value in case of an unexpected result
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousValues = { ...previousUncapValues }
|
||||||
|
|
||||||
if (party.grid.characters[position]) {
|
if (party.grid.characters && party.grid.characters[position]) {
|
||||||
newPreviousValues[position] = party.grid.characters[position]?.uncapLevel
|
newPreviousValues[position] = party.grid.characters[position]?.uncapLevel
|
||||||
setPreviousTranscendenceStages(newPreviousValues)
|
setPreviousTranscendenceStages(newPreviousValues)
|
||||||
}
|
}
|
||||||
|
|
@ -545,7 +583,9 @@ const CharacterGrid = (props: Props) => {
|
||||||
return (
|
return (
|
||||||
<li key={`grid_unit_${i}`}>
|
<li key={`grid_unit_${i}`}>
|
||||||
<CharacterUnit
|
<CharacterUnit
|
||||||
gridCharacter={party.grid.characters[i]}
|
gridCharacter={
|
||||||
|
party.grid.characters ? party.grid.characters[i] : null
|
||||||
|
}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
position={i}
|
position={i}
|
||||||
updateObject={receiveCharacterFromSearch}
|
updateObject={receiveCharacterFromSearch}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,13 @@ const emptyExtendedMastery: ExtendedMastery = {
|
||||||
strength: 0,
|
strength: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const emptyRingset: CharacterOverMastery = {
|
||||||
|
1: { ...emptyExtendedMastery, modifier: 1 },
|
||||||
|
2: { ...emptyExtendedMastery, modifier: 2 },
|
||||||
|
3: emptyExtendedMastery,
|
||||||
|
4: emptyExtendedMastery,
|
||||||
|
}
|
||||||
|
|
||||||
const MAX_AWAKENING_LEVEL = 9
|
const MAX_AWAKENING_LEVEL = 9
|
||||||
|
|
||||||
// Styles and icons
|
// Styles and icons
|
||||||
|
|
@ -85,6 +92,15 @@ const CharacterModal = ({
|
||||||
}, [modalOpen])
|
}, [modalOpen])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
console.log('Setting up grid character')
|
||||||
|
console.log(gridCharacter)
|
||||||
|
|
||||||
|
if (gridCharacter.mastery.overMastery) {
|
||||||
|
setRings(gridCharacter.mastery.overMastery)
|
||||||
|
} else {
|
||||||
|
setRings(emptyRingset)
|
||||||
|
}
|
||||||
|
|
||||||
if (gridCharacter.mastery.aetherialMastery) {
|
if (gridCharacter.mastery.aetherialMastery) {
|
||||||
setEarring({
|
setEarring({
|
||||||
modifier: gridCharacter.mastery.aetherialMastery.modifier,
|
modifier: gridCharacter.mastery.aetherialMastery.modifier,
|
||||||
|
|
@ -93,7 +109,11 @@ const CharacterModal = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
setAwakening(gridCharacter.mastery.awakening.type)
|
setAwakening(gridCharacter.mastery.awakening.type)
|
||||||
setAwakeningLevel(gridCharacter.mastery.awakening.level)
|
setAwakeningLevel(
|
||||||
|
gridCharacter.mastery.awakening.level
|
||||||
|
? gridCharacter.mastery.awakening.level
|
||||||
|
: 1
|
||||||
|
)
|
||||||
setPerpetuity(gridCharacter.mastery.perpetuity)
|
setPerpetuity(gridCharacter.mastery.perpetuity)
|
||||||
}, [gridCharacter])
|
}, [gridCharacter])
|
||||||
|
|
||||||
|
|
@ -149,14 +169,6 @@ const CharacterModal = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
function ringsChanged() {
|
function ringsChanged() {
|
||||||
// Create an empty ExtendedMastery object
|
|
||||||
const emptyRingset: CharacterOverMastery = {
|
|
||||||
1: { ...emptyExtendedMastery, modifier: 1 },
|
|
||||||
2: { ...emptyExtendedMastery, modifier: 2 },
|
|
||||||
3: emptyExtendedMastery,
|
|
||||||
4: emptyExtendedMastery,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the current ringset is empty on the current GridCharacter and our local state
|
// Check if the current ringset is empty on the current GridCharacter and our local state
|
||||||
const isEmptyRingset =
|
const isEmptyRingset =
|
||||||
gridCharacter.mastery.overMastery === undefined &&
|
gridCharacter.mastery.overMastery === undefined &&
|
||||||
|
|
@ -259,7 +271,11 @@ const CharacterModal = ({
|
||||||
|
|
||||||
setRings(gridCharacter.mastery.overMastery || emptyExtendedMastery)
|
setRings(gridCharacter.mastery.overMastery || emptyExtendedMastery)
|
||||||
setAwakening(gridCharacter.mastery.awakening.type)
|
setAwakening(gridCharacter.mastery.awakening.type)
|
||||||
setAwakeningLevel(gridCharacter.mastery.awakening.level)
|
setAwakeningLevel(
|
||||||
|
gridCharacter.mastery.awakening.level
|
||||||
|
? gridCharacter.mastery.awakening.level
|
||||||
|
: 1
|
||||||
|
)
|
||||||
|
|
||||||
setAlertOpen(false)
|
setAlertOpen(false)
|
||||||
setOpen(false)
|
setOpen(false)
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,11 @@ const emptyRing: ExtendedMastery = {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
gridCharacter: GridCharacter
|
rings: CharacterOverMastery
|
||||||
sendValues: (overMastery: CharacterOverMastery) => void
|
sendValues: (overMastery: CharacterOverMastery) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const RingSelect = ({ gridCharacter, sendValues }: Props) => {
|
const RingSelect = ({ rings: overMastery, sendValues }: Props) => {
|
||||||
// Ring value states
|
// Ring value states
|
||||||
const [rings, setRings] = useState<CharacterOverMastery>({
|
const [rings, setRings] = useState<CharacterOverMastery>({
|
||||||
1: { ...emptyRing, modifier: 1 },
|
1: { ...emptyRing, modifier: 1 },
|
||||||
|
|
@ -33,15 +33,13 @@ const RingSelect = ({ gridCharacter, sendValues }: Props) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (gridCharacter.mastery.overMastery) {
|
|
||||||
setRings({
|
setRings({
|
||||||
1: gridCharacter.mastery.overMastery[1],
|
1: overMastery[1],
|
||||||
2: gridCharacter.mastery.overMastery[2],
|
2: overMastery[2],
|
||||||
3: gridCharacter.mastery.overMastery[3],
|
3: overMastery[3],
|
||||||
4: gridCharacter.mastery.overMastery[4],
|
4: overMastery[4],
|
||||||
})
|
})
|
||||||
}
|
}, [overMastery])
|
||||||
}, [gridCharacter])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
sendValues(rings)
|
sendValues(rings)
|
||||||
|
|
@ -80,6 +78,7 @@ const RingSelect = ({ gridCharacter, sendValues }: Props) => {
|
||||||
function receiveRingValues(index: number, left: number, right: number) {
|
function receiveRingValues(index: number, left: number, right: number) {
|
||||||
// console.log(`Receiving values from ${index}: ${left} ${right}`)
|
// console.log(`Receiving values from ${index}: ${left} ${right}`)
|
||||||
if (index == 1 || index == 2) {
|
if (index == 1 || index == 2) {
|
||||||
|
console.log('1 or 2')
|
||||||
setSyncedRingValues(index, right)
|
setSyncedRingValues(index, right)
|
||||||
} else if (index == 3 && left == 0) {
|
} else if (index == 3 && left == 0) {
|
||||||
setRings({
|
setRings({
|
||||||
|
|
@ -132,6 +131,7 @@ const RingSelect = ({ gridCharacter, sendValues }: Props) => {
|
||||||
{[...Array(4)].map((e, i) => {
|
{[...Array(4)].map((e, i) => {
|
||||||
const index = i + 1
|
const index = i + 1
|
||||||
const ringStat = rings[index]
|
const ringStat = rings[index]
|
||||||
|
console.log(ringStat)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ExtendedMasterySelect
|
<ExtendedMasterySelect
|
||||||
|
|
@ -140,8 +140,8 @@ const RingSelect = ({ gridCharacter, sendValues }: Props) => {
|
||||||
key={`ring-${index}`}
|
key={`ring-${index}`}
|
||||||
dataSet={dataSet(index)}
|
dataSet={dataSet(index)}
|
||||||
leftSelectDisabled={index === 1 || index === 2}
|
leftSelectDisabled={index === 1 || index === 2}
|
||||||
leftSelectValue={ringStat.modifier ? ringStat.modifier : 0}
|
leftSelectValue={ringStat?.modifier ? ringStat?.modifier : 0}
|
||||||
rightSelectValue={ringStat.strength ? ringStat.strength : 0}
|
rightSelectValue={ringStat?.strength ? ringStat?.strength : 0}
|
||||||
sendValues={(left: number, right: number) => {
|
sendValues={(left: number, right: number) => {
|
||||||
receiveRingValues(index, left, right)
|
receiveRingValues(index, left, right)
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,18 @@ export function toObject(data: any): GridCharacter {
|
||||||
mastery: {
|
mastery: {
|
||||||
overMastery: data.over_mastery
|
overMastery: data.over_mastery
|
||||||
? data.over_mastery
|
? data.over_mastery
|
||||||
: [null, null, null, null],
|
: [
|
||||||
|
{
|
||||||
|
modifier: 1,
|
||||||
|
strength: 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
modifier: 2,
|
||||||
|
strength: 0,
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
],
|
||||||
aetherialMastery: data.aetherial_mastery ? data.aetherial_mastery : null,
|
aetherialMastery: data.aetherial_mastery ? data.aetherial_mastery : null,
|
||||||
awakening: {
|
awakening: {
|
||||||
type: Awakening.toObject(data.awakening.type),
|
type: Awakening.toObject(data.awakening.type),
|
||||||
|
|
|
||||||
|
|
@ -24,19 +24,19 @@ export function toObject(data: any): Grid {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
characters: data.characters
|
characters: data.characters
|
||||||
? mapToGridArray(data.characters, GridCharacter.toObject)
|
? mapToGridArrayWithTransformer(data.characters, GridCharacter.toObject)
|
||||||
: null,
|
: null,
|
||||||
summons: {
|
summons: {
|
||||||
mainSummon: mainSummon ? GridSummon.toObject(mainSummon) : null,
|
mainSummon: mainSummon ? GridSummon.toObject(mainSummon) : null,
|
||||||
friendSummon: friendSummon ? GridSummon.toObject(friendSummon) : null,
|
friendSummon: friendSummon ? GridSummon.toObject(friendSummon) : null,
|
||||||
allSummons: allSummons
|
allSummons: allSummons
|
||||||
? mapToGridArray(allSummons, GridSummon.toObject)
|
? mapToGridArrayWithTransformer(allSummons, GridSummon.toObject)
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
weapons: {
|
weapons: {
|
||||||
mainWeapon: mainWeapon ? GridWeapon.toObject(mainWeapon) : null,
|
mainWeapon: mainWeapon ? GridWeapon.toObject(mainWeapon) : null,
|
||||||
allWeapons: data.weapons
|
allWeapons: data.weapons
|
||||||
? mapToGridArray(data.weapons, GridWeapon.toObject)
|
? mapToGridArrayWithTransformer(data.weapons, GridWeapon.toObject)
|
||||||
: null,
|
: null,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
@ -53,7 +53,7 @@ function removeItem<T>(arr: Array<T>, values: T[]): Array<T> {
|
||||||
return arr
|
return arr
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapToGridArray<T>(
|
export function mapToGridArrayWithTransformer<T>(
|
||||||
arr: any[],
|
arr: any[],
|
||||||
transformer: (data: any) => T
|
transformer: (data: any) => T
|
||||||
): GridArray<T> {
|
): GridArray<T> {
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,9 @@ export function toObject(data: any): Weapon {
|
||||||
},
|
},
|
||||||
ax: data.ax,
|
ax: data.ax,
|
||||||
axType: data.ax_type,
|
axType: data.ax_type,
|
||||||
awakenings: data.awakenings.map((awakening: any) =>
|
awakenings: data.awakenings
|
||||||
Awakening.toObject(awakening)
|
? data.awakenings.map((awakening: any) => Awakening.toObject(awakening))
|
||||||
),
|
: null,
|
||||||
maxAwakeningLevel: data.max_awakening_level,
|
maxAwakeningLevel: data.max_awakening_level,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
utils/mapToGridArray.tsx
Normal file
6
utils/mapToGridArray.tsx
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
export function mapToGridArray<T>(arr: any[]): GridArray<T> {
|
||||||
|
return arr.reduce(
|
||||||
|
(gridArray, item) => ({ ...gridArray, [item.position]: item }),
|
||||||
|
{} as GridArray<T>
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue