test
This commit is contained in:
@@ -19,6 +19,7 @@ import { getLocalStorage, setLocalStorage } from '@/shared/lib';
|
||||
import { StorageKeys } from '@/shared/constants/local-storage';
|
||||
import { HomeGroupsParams, HomeGroupsResponse } from '@/entities/home/model/types';
|
||||
import { LoginResponse } from '@/entities/user/model/types';
|
||||
import { useCodesListByCodeClMutation } from '@/entities/common/api/use-codes-list-by-codeCl-mutaion';
|
||||
|
||||
export interface ContextType {
|
||||
setOnBack: (onBack: () => void) => void;
|
||||
@@ -31,8 +32,18 @@ export interface ContextType {
|
||||
setFavoriteEdit: (favoriteEdit?: boolean) => void;
|
||||
};
|
||||
|
||||
export interface CallServiceCodeProps {
|
||||
codeCl: string;
|
||||
code1Filter?: Array<any>;
|
||||
};
|
||||
|
||||
export const SubLayout = () => {
|
||||
useScrollToTop();
|
||||
const {
|
||||
callLogin,
|
||||
updateUserData
|
||||
} = useUserInfo();
|
||||
|
||||
const [onBack, setOnBack] = useState(undefined);
|
||||
const [headerTitle, setHeaderTitle] = useState<string>('');
|
||||
const [isPullToRefreshEnabled, setIsPullToRefreshEnabled] = useState<boolean>(false);
|
||||
@@ -42,15 +53,12 @@ export const SubLayout = () => {
|
||||
const [footerCurrentPage, setFooterCurrentPage] = useState<undefined | string | null>(undefined);
|
||||
const [favoriteEdit, setFavoriteEdit] = useState<boolean>(false);
|
||||
const [headerNavigationKey, setHeaderNavigationKey] = useState<number>(1);
|
||||
|
||||
const {
|
||||
callLogin,
|
||||
updateUserData
|
||||
} = useUserInfo();
|
||||
|
||||
const [loginSuccess, setLoginSuccess] = useState<boolean>(false);
|
||||
|
||||
const { isNativeEnvironment } = useAppBridge();
|
||||
const { mutateAsync: homeGroups } = useHomeGroupsMutation();
|
||||
const [loginSuccess, setLoginSuccess] = useState<boolean>(false);
|
||||
const { mutateAsync: codesListByCodeCl} = useCodesListByCodeClMutation();
|
||||
|
||||
|
||||
const wrapperClassName = 'wrapper';
|
||||
|
||||
@@ -68,13 +76,19 @@ export const SubLayout = () => {
|
||||
};
|
||||
});
|
||||
useStore.getState().UserStore.setSelectOptionsMids(options);
|
||||
console.log('mids: [' + JSON.stringify(rs.mids) + ']');
|
||||
|
||||
if(!!rs.mids[0]){
|
||||
useStore.getState().UserStore.setMid(rs.mids[0]);
|
||||
}
|
||||
setLoginSuccess(true);
|
||||
setHeaderNavigationKey(headerNavigationKey + 1);
|
||||
|
||||
|
||||
let filter0022: Array<string> = ['01', '02', '03', '05', '14', '21', '24', '26', '31'];
|
||||
callServiceCode({
|
||||
codeCl: '0022',
|
||||
code1Filter: filter0022
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
@@ -93,6 +107,34 @@ export const SubLayout = () => {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const callServiceCode = ({
|
||||
codeCl,
|
||||
code1Filter
|
||||
}: CallServiceCodeProps) => {
|
||||
let params = {
|
||||
codeCl: codeCl
|
||||
};
|
||||
let options = [];
|
||||
codesListByCodeCl(params).then((rs) => {
|
||||
options = rs.map((value, index) => {
|
||||
return {
|
||||
name: value.desc1,
|
||||
value: value.code1
|
||||
}
|
||||
});
|
||||
if(!!code1Filter){
|
||||
options = options.filter((value, index) => {
|
||||
return code1Filter.includes(value.value);
|
||||
});
|
||||
}
|
||||
options = options.sort((a, b) => a.value - b.value);
|
||||
options.unshift({
|
||||
name: '전체', value: ''
|
||||
});
|
||||
useStore.getState().CommonStore.setServiceCodes(options);
|
||||
});
|
||||
};
|
||||
|
||||
const saveToken = (token: LoginResponse) => {
|
||||
updateUserData(token);
|
||||
};
|
||||
@@ -101,6 +143,7 @@ export const SubLayout = () => {
|
||||
|
||||
useEffect(() => {
|
||||
handleLogin();
|
||||
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user