diff --git a/src/pages/transaction/all-transaction/list-page.tsx b/src/pages/transaction/all-transaction/list-page.tsx index de9e699..e915cb0 100644 --- a/src/pages/transaction/all-transaction/list-page.tsx +++ b/src/pages/transaction/all-transaction/list-page.tsx @@ -1,5 +1,5 @@ import moment from 'moment'; -import { useStore } from '@/shared/model/store'; +import { useDetailOnStore, useStore } from '@/shared/model/store'; import { ChangeEvent, useEffect, useState } from 'react'; import { IMAGE_ROOT } from '@/shared/constants/common'; import { PATHS } from '@/shared/constants/paths'; @@ -89,7 +89,7 @@ export const AllTransactionListPage = () => { const [downloadBottomSheetOn, setDownloadBottomSheetOn] = useState(false); - const [detailOn, setDetailOn] = useState(false); + const { detailOn, setDetailOn } = useDetailOnStore(); const [detailTid, setDetailTid] = useState(''); const [detailServiceCode, setDetailServiceCode] = useState(''); diff --git a/src/pages/transaction/billing/list-page.tsx b/src/pages/transaction/billing/list-page.tsx index f536b8e..bfaa29c 100644 --- a/src/pages/transaction/billing/list-page.tsx +++ b/src/pages/transaction/billing/list-page.tsx @@ -1,7 +1,7 @@ import moment from 'moment'; import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { useStore } from '@/shared/model/store'; +import { useDetailOnStore, useStore } from '@/shared/model/store'; import { IMAGE_ROOT } from '@/shared/constants/common'; import { PATHS } from '@/shared/constants/paths'; import { useNavigate } from '@/shared/lib/hooks/use-navigate'; @@ -74,7 +74,7 @@ export const BillingListPage = () => { const [downloadBottomSheetOn, setDownloadBottomSheetOn] = useState(false); - const [detailOn, setDetailOn] = useState(false); + const { detailOn, setDetailOn } = useDetailOnStore(); const [detailTid, setDetailTid] = useState(''); const [filterUsed, setFilterUsed] = useState(false); diff --git a/src/pages/transaction/cash-receipt/list-page.tsx b/src/pages/transaction/cash-receipt/list-page.tsx index 3819a9e..f384dec 100644 --- a/src/pages/transaction/cash-receipt/list-page.tsx +++ b/src/pages/transaction/cash-receipt/list-page.tsx @@ -33,7 +33,7 @@ import { useSetFooterMode } from '@/widgets/sub-layout/use-sub-layout'; import { getCashReceiptTransactionTypeBtnGroup } from '@/entities/transaction/model/contant'; -import { useStore } from '@/shared/model/store'; +import { useDetailOnStore, useStore } from '@/shared/model/store'; import { useCashReceiptSummaryMutation } from '@/entities/transaction/api/use-cash-receipt-summary-mutation'; import { DownloadBottomSheet, DownloadSelectedMode } from '@/entities/common/ui/download-bottom-sheet'; import useIntersectionObserver from '@/widgets/intersection-observer'; @@ -80,7 +80,7 @@ export const CashReceiptListPage = () => { const [downloadBottomSheetOn, setDownloadBottomSheetOn] = useState(false); - const [detailOn, setDetailOn] = useState(false); + const { detailOn, setDetailOn } = useDetailOnStore(); const [detailTid, setDetailTid] = useState(''); const [detailServiceCode, setDetailServiceCode] = useState(''); diff --git a/src/pages/transaction/escrow/list-page.tsx b/src/pages/transaction/escrow/list-page.tsx index a0e0b7b..5799dc1 100644 --- a/src/pages/transaction/escrow/list-page.tsx +++ b/src/pages/transaction/escrow/list-page.tsx @@ -1,7 +1,7 @@ import moment from 'moment'; import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; -import { useStore } from '@/shared/model/store'; +import { useDetailOnStore, useStore } from '@/shared/model/store'; import { IMAGE_ROOT } from '@/shared/constants/common'; import { PATHS } from '@/shared/constants/paths'; import { useNavigate } from '@/shared/lib/hooks/use-navigate'; @@ -73,7 +73,7 @@ export const EscrowListPage = () => { const [downloadBottomSheetOn, setDownloadBottomSheetOn] = useState(false); - const [detailOn, setDetailOn] = useState(false); + const { detailOn, setDetailOn } = useDetailOnStore(); const [detailTid, setDetailTid] = useState(''); const [detailServiceCode, setDetailServiceCode] = useState(''); diff --git a/src/shared/model/store.ts b/src/shared/model/store.ts index 40ab49e..8b3034e 100644 --- a/src/shared/model/store.ts +++ b/src/shared/model/store.ts @@ -10,6 +10,10 @@ export interface ModalOnStore { modalOn: boolean; setModalOn: (modalOn: boolean) => void; }; +export interface DetailOnStore { + detailOn: boolean; + setDetailOn: (detailOn: boolean) => void; +}; export interface MenuOnStore { menuOn: boolean; setMenuOn: (menuOn: boolean) => void; @@ -33,6 +37,14 @@ export const useModalOnStore = create((set) => ({ })); } })); +export const useDetailOnStore = create((set) => ({ + detailOn: false, + setDetailOn: (detailOn: boolean) => { + set((state: {detailOn: boolean}) => ({ + detailOn: (state.detailOn = detailOn) + })); + } +})); export const useMenuOnStore = create((set) => ({ menuOn: false, setMenuOn: (menuOn: boolean) => { diff --git a/src/widgets/sub-layout/index.tsx b/src/widgets/sub-layout/index.tsx index f461a7b..453a218 100644 --- a/src/widgets/sub-layout/index.tsx +++ b/src/widgets/sub-layout/index.tsx @@ -18,7 +18,7 @@ import { import { useHomeGroupsMutation } from '@/entities/home/api/use-home-groups-mutation'; import { useUserInfo } from '@/entities/user/lib/use-user-info'; import { useAppBridge } from '@/hooks'; -import { useFavoriteEditOnStore, useMenuOnStore, useStore } from '@/shared/model/store'; +import { useDetailOnStore, useFavoriteEditOnStore, useMenuOnStore, useStore } from '@/shared/model/store'; import { HomeGroupsParams, HomeGroupsResponse } from '@/entities/home/model/types'; import { BusinessPropertyParams, @@ -70,6 +70,7 @@ export const SubLayout = () => { const { reload, navigateBack } = useNavigate(); const { menuOn, setMenuOn } = useMenuOnStore(); const { favoriteEditOn, setFavoriteEditOn } = useFavoriteEditOnStore(); + const { detailOn, setDetailOn } = useDetailOnStore(); const location = useLocation(); console.log(location) @@ -408,6 +409,9 @@ export const SubLayout = () => { setMenuOn(false); setFavoriteEditOn(false); } + else if(detailOn){ + setDetailOn(false); + } else{ navigateBack(); }