Skip to content

Commit 0993fa8

Browse files
authored
Merge pull request #1532 from kunalgaurav-bmw/fix/1367/back-button-return-app-company-subscription
fix(company subscription): fix back button returns on wrong tab
2 parents 0846bb5 + a45467e commit 0993fa8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: src/components/pages/CompanySubscriptions/CompanySubscriptionDetail.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export default function CompanySubscriptionDetail() {
9595
backButtonLabel={t('global.actions.back')}
9696
backButtonVariant="text"
9797
onBackButtonClick={() => {
98-
navigate(`/${PAGES.COMPANY_SUBSCRIPTIONS}`)
98+
navigate(`/${PAGES.COMPANY_SUBSCRIPTIONS}`, {
99+
state: { activeTab: items.app ? 0 : 1 },
100+
})
99101
}}
100102
/>
101103
</Box>

Diff for: src/components/pages/CompanySubscriptions/index.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
useUnsubscribeServiceMutation,
4747
} from 'features/serviceSubscription/serviceSubscriptionApiSlice'
4848
import { Box } from '@mui/material'
49+
import { useLocation } from 'react-router-dom'
4950

5051
interface FetchHookArgsType {
5152
statusId: string
@@ -55,6 +56,7 @@ interface FetchHookArgsType {
5556
export default function CompanySubscriptions() {
5657
const { t } = useTranslation()
5758
const dispatch = useDispatch()
59+
const location = useLocation()
5860
const [refresh, setRefresh] = useState(0)
5961
const [searchExpr, setSearchExpr] = useState<string>('')
6062
const [fetchHookArgs, setFetchHookArgs] = useState<FetchHookArgsType>()
@@ -73,7 +75,9 @@ export default function CompanySubscriptions() {
7375
const [unsubscribeAppMutation] = useUnsubscribeAppMutation()
7476
const [unsubscribeServiceMutation] = useUnsubscribeServiceMutation()
7577
const [enableErrorMessage, setEnableErrorMessage] = useState<boolean>(false)
76-
const [currentActive, setCurrentActive] = useState<number>(0)
78+
const [currentActive, setCurrentActive] = useState<number>(
79+
location.state?.activeTab ?? 0
80+
)
7781

7882
const setView = (e: React.MouseEvent<HTMLInputElement>) => {
7983
const viewValue = e.currentTarget.value

0 commit comments

Comments
 (0)