home 화면 mid 셋팅
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
|||||||
} from '../model/types';
|
} from '../model/types';
|
||||||
import { useNavigate } from '@/shared/lib/hooks';
|
import { useNavigate } from '@/shared/lib/hooks';
|
||||||
import { PATHS } from '@/shared/constants/paths';
|
import { PATHS } from '@/shared/constants/paths';
|
||||||
import { useStore } from '@/shared/model/store';
|
import { useNewMidStore, useStore } from '@/shared/model/store';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { showAlert } from '@/widgets/show-alert';
|
import { showAlert } from '@/widgets/show-alert';
|
||||||
import { checkGrant } from '@/shared/lib/check-grant';
|
import { checkGrant } from '@/shared/lib/check-grant';
|
||||||
@@ -19,9 +19,9 @@ import { snackBar } from '@/shared/lib';
|
|||||||
export const BoxContainer1 = () => {
|
export const BoxContainer1 = () => {
|
||||||
const { navigate } = useNavigate();
|
const { navigate } = useNavigate();
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const userMid = useStore.getState().UserStore.mid;
|
const { newMid } = useNewMidStore();
|
||||||
|
|
||||||
const [mid, setMid] = useState<string>(userMid);
|
const [mid, setMid] = useState<string>();
|
||||||
const [searchDate, setSearchDate] = useState<string>(moment().format('YYYYMMDD'));
|
const [searchDate, setSearchDate] = useState<string>(moment().format('YYYYMMDD'));
|
||||||
|
|
||||||
const [sales, setSales] = useState<Sales>();
|
const [sales, setSales] = useState<Sales>();
|
||||||
@@ -84,8 +84,19 @@ export const BoxContainer1 = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
callToday();
|
const userMid = useStore.getState().UserStore.mid;
|
||||||
|
setMid(userMid);
|
||||||
}, []);
|
}, []);
|
||||||
|
useEffect(() => {
|
||||||
|
if(mid){
|
||||||
|
callToday();
|
||||||
|
}
|
||||||
|
}, [mid]);
|
||||||
|
useEffect(() => {
|
||||||
|
if(!!newMid){
|
||||||
|
setMid(newMid);
|
||||||
|
}
|
||||||
|
}, [newMid]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useHomeOverviewMutation } from '../api/use-home-overview-mutation';
|
|||||||
import { useHomeMonthwMutation } from '../api/use-home-month-mutation';
|
import { useHomeMonthwMutation } from '../api/use-home-month-mutation';
|
||||||
import { useNavigate } from '@/shared/lib/hooks';
|
import { useNavigate } from '@/shared/lib/hooks';
|
||||||
import { PATHS } from '@/shared/constants/paths';
|
import { PATHS } from '@/shared/constants/paths';
|
||||||
import { useStore } from '@/shared/model/store';
|
import { useNewMidStore, useStore } from '@/shared/model/store';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { showAlert } from '@/widgets/show-alert';
|
import { showAlert } from '@/widgets/show-alert';
|
||||||
import { checkGrant } from '@/shared/lib/check-grant';
|
import { checkGrant } from '@/shared/lib/check-grant';
|
||||||
@@ -15,9 +15,9 @@ import { snackBar } from '@/shared/lib';
|
|||||||
export const BoxContainer2 = () => {
|
export const BoxContainer2 = () => {
|
||||||
const { navigate } = useNavigate();
|
const { navigate } = useNavigate();
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const userMid = useStore.getState().UserStore.mid;
|
const { newMid } = useNewMidStore();
|
||||||
|
|
||||||
const [mid, setMid] = useState<string>(userMid);
|
const [mid, setMid] = useState<string>();
|
||||||
const [searchMonth, setSearchMonth] = useState<string>(moment().format('YYYYMM'));
|
const [searchMonth, setSearchMonth] = useState<string>(moment().format('YYYYMM'));
|
||||||
const [searchDate, setSearchDate] = useState<string>(moment().format('YYYYMMDD'));
|
const [searchDate, setSearchDate] = useState<string>(moment().format('YYYYMMDD'));
|
||||||
|
|
||||||
@@ -89,9 +89,20 @@ export const BoxContainer2 = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
callMonth();
|
const userMid = useStore.getState().UserStore.mid;
|
||||||
callOverview();
|
setMid(userMid);
|
||||||
}, []);
|
}, []);
|
||||||
|
useEffect(() => {
|
||||||
|
if(!!mid){
|
||||||
|
callMonth();
|
||||||
|
callOverview();
|
||||||
|
}
|
||||||
|
}, [mid]);
|
||||||
|
useEffect(() => {
|
||||||
|
if(!!newMid){
|
||||||
|
setMid(newMid);
|
||||||
|
}
|
||||||
|
}, [newMid]);
|
||||||
|
|
||||||
const onClickToNavigate = (path: string) => {
|
const onClickToNavigate = (path: string) => {
|
||||||
if(path === 'allTransaction'){
|
if(path === 'allTransaction'){
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import { createUserInfoStore, UserInfoState } from '@/entities/user/model/store'
|
|||||||
import { createBannerInfoStore, BannerInfoState, createCommonStore, CommonState } from '@/entities/common/model/store';
|
import { createBannerInfoStore, BannerInfoState, createCommonStore, CommonState } from '@/entities/common/model/store';
|
||||||
import { StorageKeys } from '@/shared/constants/local-storage';
|
import { StorageKeys } from '@/shared/constants/local-storage';
|
||||||
|
|
||||||
|
export interface NewMidStore {
|
||||||
|
newMid: string;
|
||||||
|
setNewMid: (newMid: string) => void;
|
||||||
|
};
|
||||||
export interface DownloadBottomSheetOnStore {
|
export interface DownloadBottomSheetOnStore {
|
||||||
downloadBottomSheetOn: boolean;
|
downloadBottomSheetOn: boolean;
|
||||||
setDownloadBottomSheetOn: (downloadBottomSheetOn: boolean) => void;
|
setDownloadBottomSheetOn: (downloadBottomSheetOn: boolean) => void;
|
||||||
@@ -46,6 +50,15 @@ export interface MenuIdsStore {
|
|||||||
deleteMenuId: (menuId: number) => void;
|
deleteMenuId: (menuId: number) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useNewMidStore = create<NewMidStore>((set) => ({
|
||||||
|
newMid: '',
|
||||||
|
setNewMid: (newMid: string) => {
|
||||||
|
set((state: {newMid: string}) => ({
|
||||||
|
newMid: (state.newMid = newMid)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
export const useDownloadBottomSheetOnStore = create<DownloadBottomSheetOnStore>((set) => ({
|
export const useDownloadBottomSheetOnStore = create<DownloadBottomSheetOnStore>((set) => ({
|
||||||
downloadBottomSheetOn: false,
|
downloadBottomSheetOn: false,
|
||||||
setDownloadBottomSheetOn: (downloadBottomSheetOn: boolean) => {
|
setDownloadBottomSheetOn: (downloadBottomSheetOn: boolean) => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
HeaderType,
|
HeaderType,
|
||||||
HeaderNavigationProps
|
HeaderNavigationProps
|
||||||
} from '@/entities/common/model/types';
|
} from '@/entities/common/model/types';
|
||||||
import { useStore } from '@/shared/model/store';
|
import { useNewMidStore, useStore } from '@/shared/model/store';
|
||||||
import { ChangeEvent, useEffect, useState } from 'react';
|
import { ChangeEvent, useEffect, useState } from 'react';
|
||||||
import { AppAlarmUnreadCountParams, AppAlarmUnreadCountResponse, MERCHANT_ADMIN_APP } from '@/entities/alarm/model/types';
|
import { AppAlarmUnreadCountParams, AppAlarmUnreadCountResponse, MERCHANT_ADMIN_APP } from '@/entities/alarm/model/types';
|
||||||
import { useAppAlarmUnreadCountMutation } from '@/entities/alarm/api/use-app-alarm-unread-count-mutation';
|
import { useAppAlarmUnreadCountMutation } from '@/entities/alarm/api/use-app-alarm-unread-count-mutation';
|
||||||
@@ -24,10 +24,12 @@ export const HeaderNavigation = ({
|
|||||||
setMid
|
setMid
|
||||||
}: HeaderNavigationProps) => {
|
}: HeaderNavigationProps) => {
|
||||||
const { mutateAsync: appAlarmUnreadCount } = useAppAlarmUnreadCountMutation();
|
const { mutateAsync: appAlarmUnreadCount } = useAppAlarmUnreadCountMutation();
|
||||||
|
const { newMid, setNewMid } = useNewMidStore();
|
||||||
|
|
||||||
let [selectOptions, setSelectOptions] = useState<Array<Record<string, string>>>([]);
|
let [selectOptions, setSelectOptions] = useState<Array<Record<string, string>>>([]);
|
||||||
const [unreadCount, setUnreadCount] = useState<number>(0);
|
const [unreadCount, setUnreadCount] = useState<number>(0);
|
||||||
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
navigate,
|
navigate,
|
||||||
navigateBack,
|
navigateBack,
|
||||||
@@ -57,8 +59,8 @@ export const HeaderNavigation = ({
|
|||||||
let value = e.target.value;
|
let value = e.target.value;
|
||||||
useStore.getState().UserStore.setMid(value);
|
useStore.getState().UserStore.setMid(value);
|
||||||
setLocalStorage(StorageKeys.UserMid, value);
|
setLocalStorage(StorageKeys.UserMid, value);
|
||||||
reload();
|
setMid(value);
|
||||||
//setMid(value);
|
setNewMid(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const callAlarmCount = () => {
|
const callAlarmCount = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user