Normalize over mastery object
The over mastery object was sometimes 0-index, sometimes 1-index. This normalizes it to be 1-indexed, even though that is a little silly. I think this is the lesser amount of work though, since normalizing against 0-index might require API changes
This commit is contained in:
parent
09f6f7ddd1
commit
f7b3139abf
1 changed files with 16 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ import { useSnapshot } from 'valtio'
|
||||||
import { Trans, useTranslation } from 'next-i18next'
|
import { Trans, useTranslation } from 'next-i18next'
|
||||||
import { AxiosResponse } from 'axios'
|
import { AxiosResponse } from 'axios'
|
||||||
import classNames from 'classnames'
|
import classNames from 'classnames'
|
||||||
|
import cloneDeep from 'lodash.clonedeep'
|
||||||
|
|
||||||
import Alert from '~components/common/Alert'
|
import Alert from '~components/common/Alert'
|
||||||
import Button from '~components/common/Button'
|
import Button from '~components/common/Button'
|
||||||
|
|
@ -26,6 +27,7 @@ import SettingsIcon from '~public/icons/Settings.svg'
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import type {
|
import type {
|
||||||
|
CharacterOverMastery,
|
||||||
GridCharacterObject,
|
GridCharacterObject,
|
||||||
PerpetuityObject,
|
PerpetuityObject,
|
||||||
SearchableObject,
|
SearchableObject,
|
||||||
|
|
@ -143,7 +145,20 @@ const CharacterUnit = ({
|
||||||
// Save the server's response to state
|
// Save the server's response to state
|
||||||
function processResult(response: AxiosResponse) {
|
function processResult(response: AxiosResponse) {
|
||||||
const gridCharacter: GridCharacter = response.data
|
const gridCharacter: GridCharacter = response.data
|
||||||
appState.grid.characters[gridCharacter.position] = gridCharacter
|
let character = cloneDeep(gridCharacter)
|
||||||
|
|
||||||
|
if (character.over_mastery) {
|
||||||
|
const overMastery: CharacterOverMastery = {
|
||||||
|
1: gridCharacter.over_mastery[0],
|
||||||
|
2: gridCharacter.over_mastery[1],
|
||||||
|
3: gridCharacter.over_mastery[2],
|
||||||
|
4: gridCharacter.over_mastery[3],
|
||||||
|
}
|
||||||
|
|
||||||
|
character.over_mastery = overMastery
|
||||||
|
}
|
||||||
|
|
||||||
|
appState.grid.characters[gridCharacter.position] = character
|
||||||
}
|
}
|
||||||
|
|
||||||
function processError(error: any) {
|
function processError(error: any) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue