From 23ff979e8349183d4eff99e277eb4efdc09cf380 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sun, 27 Feb 2022 00:35:41 -0800 Subject: [PATCH] Add typing to the object grids and match new API --- components/CharacterGrid/index.tsx | 6 +++--- components/SummonGrid/index.tsx | 6 +++--- components/WeaponGrid/index.tsx | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/components/CharacterGrid/index.tsx b/components/CharacterGrid/index.tsx index c855c206..f5429e01 100644 --- a/components/CharacterGrid/index.tsx +++ b/components/CharacterGrid/index.tsx @@ -65,10 +65,10 @@ const CharacterGrid = (props: Props) => { function processResult(response: AxiosResponse) { // Store the response - const party = response.data.party + const party: Party = response.data.party // Get the party user and logged in user, if possible, to compare - const partyUser = (party.user_id) ? party.user_id : undefined + const partyUser = (party.user) ? party.user.id : undefined const loggedInUser = (cookies.user) ? cookies.user.user_id : '' if (partyUser != undefined && loggedInUser != undefined && partyUser === loggedInUser) @@ -97,7 +97,7 @@ const CharacterGrid = (props: Props) => { } } - function populateCharacters(list: [GridCharacter]) { + function populateCharacters(list: Array) { list.forEach((object: GridCharacter) => { if (object.position != null) appState.grid.characters[object.position] = object diff --git a/components/SummonGrid/index.tsx b/components/SummonGrid/index.tsx index 59ecb54f..97404734 100644 --- a/components/SummonGrid/index.tsx +++ b/components/SummonGrid/index.tsx @@ -75,10 +75,10 @@ const SummonGrid = (props: Props) => { function processResult(response: AxiosResponse) { // Store the response - const party = response.data.party + const party: Party = response.data.party // Get the party user and logged in user, if possible, to compare - const partyUser = (party.user_id) ? party.user_id : undefined + const partyUser = (party.user) ? party.user.id : undefined const loggedInUser = (cookies.user) ? cookies.user.user_id : '' if (partyUser != undefined && loggedInUser != undefined && partyUser === loggedInUser) @@ -107,7 +107,7 @@ const SummonGrid = (props: Props) => { } } - function populateSummons(list: [GridSummon]) { + function populateSummons(list: Array) { list.forEach((gridObject: GridSummon) => { if (gridObject.main) appState.grid.summons.mainSummon = gridObject diff --git a/components/WeaponGrid/index.tsx b/components/WeaponGrid/index.tsx index 276ae16b..103bf728 100644 --- a/components/WeaponGrid/index.tsx +++ b/components/WeaponGrid/index.tsx @@ -71,10 +71,10 @@ const WeaponGrid = (props: Props) => { function processResult(response: AxiosResponse) { // Store the response - const party = response.data.party - + const party: Party = response.data.party + // Get the party user and logged in user, if possible, to compare - const partyUser = (party.user_id) ? party.user_id : undefined + const partyUser = (party.user) ? party.user.id : undefined const loggedInUser = (cookies.user) ? cookies.user.user_id : '' if (partyUser != undefined && loggedInUser != undefined && partyUser === loggedInUser) @@ -84,7 +84,7 @@ const WeaponGrid = (props: Props) => { // Store the important party and state-keeping values appState.party.id = party.id - appState.party.extra = party.is_extra + appState.party.extra = party.extra setFound(true) @@ -105,7 +105,7 @@ const WeaponGrid = (props: Props) => { } } - function populateWeapons(list: [GridWeapon]) { + function populateWeapons(list: Array) { list.forEach((gridObject: GridWeapon) => { if (gridObject.mainhand) { appState.grid.weapons.mainWeapon = gridObject