Created
October 6, 2025 16:28
-
-
Save broguinn/2f984b6490ab0396a755e4b604a3d60e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/apps/command-center/src/app/dashboard/gate-events/auto-recognition/instant-gate-support/page.tsx b/apps/command-center/src/app/dashboard/gate-events/auto-recognition/instant-gate-support/page.tsx | |
| index cdbffec0..fb2942be 100644 | |
| --- a/apps/command-center/src/app/dashboard/gate-events/auto-recognition/instant-gate-support/page.tsx | |
| +++ b/apps/command-center/src/app/dashboard/gate-events/auto-recognition/instant-gate-support/page.tsx | |
| @@ -105,8 +105,10 @@ export default function InstantGateSupport() { | |
| serialize: (v) => JSON.stringify(v), | |
| }); | |
| - const [selectedTab, setSelectedTab] = useState(0); | |
| - const [dropdownOption, setDropdownOption] = useState<DropdownOption>(DropdownOption.LOAD_STATUS); | |
| + const [userSelectedTab, setUserSelectedTab] = useState(0); | |
| + const [userDropdownOption, setUserDropdownOption] = useState<DropdownOption>( | |
| + DropdownOption.LOAD_STATUS | |
| + ); | |
| const { data: yardData } = useQuery(getYardsQuery); | |
| const yards = yardData?.viewer?.yards || []; | |
| @@ -139,36 +141,29 @@ export default function InstantGateSupport() { | |
| const showDriverSessionTab = | |
| !!yardForTheLane?.customer && yardForTheLane?.customer?.id === HUB_GROUP_CUSTOMER_ID; // Only HUB GROUP uses Driver Session Load Status | |
| - // Reset to first tab when switching yards if the current tab becomes unavailable | |
| - useEffect(() => { | |
| - const isUnavailableTabSelected = | |
| - dropdownOption === DropdownOption.ACCESS_CODE || | |
| - dropdownOption === DropdownOption.LOAD_STATUS; | |
| - | |
| - if (!showDriverSessionTab && isUnavailableTabSelected) { | |
| - setSelectedTab(0); | |
| - } | |
| - }, [dropdownOption, showDriverSessionTab]); | |
| - | |
| - // Reset to first available option when switching customers if current option becomes unavailable | |
| - useEffect(() => { | |
| - const availableOptions = [ | |
| - ...(showAccessCodeTab ? [DropdownOption.ACCESS_CODE] : []), | |
| - ...(showDriverSessionTab ? [DropdownOption.LOAD_STATUS] : []), | |
| - ]; | |
| - | |
| - if (availableOptions.length > 0 && !availableOptions.includes(dropdownOption)) { | |
| - setDropdownOption(availableOptions[0]); | |
| - } | |
| - }, [showAccessCodeTab, showDriverSessionTab, dropdownOption]); | |
| + // Derive validated dropdown option - reset to first available option if current one becomes unavailable | |
| + const availableOptions = [ | |
| + ...(showAccessCodeTab ? [DropdownOption.ACCESS_CODE] : []), | |
| + ...(showDriverSessionTab ? [DropdownOption.LOAD_STATUS] : []), | |
| + ]; | |
| + const dropdownOption = | |
| + availableOptions.length > 0 && !availableOptions.includes(userDropdownOption) | |
| + ? availableOptions[0] | |
| + : userDropdownOption; | |
| + | |
| + // Derive validated tab - reset to first tab if current tab becomes unavailable | |
| + const isUnavailableTabSelected = | |
| + dropdownOption === DropdownOption.ACCESS_CODE || dropdownOption === DropdownOption.LOAD_STATUS; | |
| + const selectedTab = | |
| + !showDriverSessionTab && isUnavailableTabSelected ? 0 : userSelectedTab; | |
| const handleTabChange = (event: React.SyntheticEvent, newValue: number) => { | |
| - setSelectedTab(newValue); | |
| + setUserSelectedTab(newValue); | |
| }; | |
| const handleDropdownOptionChange = (option: DropdownOption) => { | |
| - setDropdownOption(option); | |
| - setSelectedTab(2); | |
| + setUserDropdownOption(option); | |
| + setUserSelectedTab(2); | |
| }; | |
| const handleSwitchLane = () => { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment