From f0ba0d5eb3d350c961094bc60acb188fcad94c79 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 30 Jan 2023 23:09:37 -0800 Subject: [PATCH] Don't switch tabs when creating a party We changed the method in the New route to use the Next.js Router, which is causing us to navigate to the Party route and causing issues. This change makes it so that users stay on the same tab when they reach their destination. --- components/Party/index.tsx | 12 +++++++++++- utils/enums.tsx | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/components/Party/index.tsx b/components/Party/index.tsx index f9f2196b..e935947c 100644 --- a/components/Party/index.tsx +++ b/components/Party/index.tsx @@ -167,8 +167,18 @@ const Party = (props: Props) => { storeWeapons(team.weapons) storeSummons(team.summons) + // Create a string to send the user back to the tab they're currently on + let tab = '' + if (currentTab === GridType.Character) { + tab = 'characters' + } else if (currentTab === GridType.Summon) { + tab = 'summons' + } + // Then, push the browser history to the new party's URL - if (props.pushHistory) props.pushHistory(`/p/${team.shortcode}`) + if (props.pushHistory) { + props.pushHistory(`/p/${team.shortcode}/${tab}`) + } return team } diff --git a/utils/enums.tsx b/utils/enums.tsx index a1de0ccf..df2c0c84 100644 --- a/utils/enums.tsx +++ b/utils/enums.tsx @@ -5,7 +5,6 @@ export enum ButtonType { } export enum GridType { - Class, Character, Weapon, Summon,