공통코드
This commit is contained in:
@@ -10,7 +10,12 @@ import { FooterNavigation } from '@/widgets/navigation/footer';
|
||||
import { PullToRefresh } from '@/widgets/pull-to-refresh/pull-to-refresh';
|
||||
import { useNavigate } from '@/shared/lib/hooks';
|
||||
import { useScrollToTop } from '@/shared/lib/hooks/use-scroll-to-top';
|
||||
import { HeaderType } from '@/entities/common/model/types';
|
||||
import {
|
||||
CodeListItem,
|
||||
CodesSelectParams,
|
||||
CodesSelectPostResponse,
|
||||
HeaderType
|
||||
} from '@/entities/common/model/types';
|
||||
import { useHomeGroupsMutation } from '@/entities/home/api/use-home-groups-mutation';
|
||||
import { useUserInfo } from '@/entities/user/lib/use-user-info';
|
||||
import { useAppBridge } from '@/hooks';
|
||||
@@ -19,11 +24,11 @@ import { getLocalStorage, setLocalStorage } from '@/shared/lib';
|
||||
import { StorageKeys } from '@/shared/constants/local-storage';
|
||||
import { HomeGroupsParams, HomeGroupsResponse } from '@/entities/home/model/types';
|
||||
import { BusinessPropertyByMidParams, BusinessPropertyByMidResponse, LoginResponse, ShortcutUserParams, ShortcutUserResponse, UserFindAuthMethodParams, UserFindAuthMethodResponse } from '@/entities/user/model/types';
|
||||
import { useCodesListByCodeClMutation } from '@/entities/common/api/use-codes-list-by-codeCl-mutaion';
|
||||
import { useShortcutUserMutation } from '@/entities/user/api/use-shortcut-user-mutation';
|
||||
import { useShortcutDefaultMutation } from '@/entities/user/api/use-shortcut-detault-mutation';
|
||||
import { useBusinessPropertyByMidMutation } from '@/entities/user/api/use-business-property-by-mid-mutation';
|
||||
import { useUserFindAuthMethodMutation } from '@/entities/user/api/use-user-find-authmethod-mutation';
|
||||
import { useCodesSelectMutation } from '@/entities/common/api/use-codes-select-mutation';
|
||||
|
||||
export interface ContextType {
|
||||
setOnBack: (onBack: () => void) => void;
|
||||
@@ -36,7 +41,12 @@ export interface ContextType {
|
||||
setFavoriteEdit: (favoriteEdit?: boolean) => void;
|
||||
};
|
||||
|
||||
export interface CallServiceCodeProps {
|
||||
export interface CallCodesSelectProps {
|
||||
codeCl: string;
|
||||
code1Filter?: Array<any>;
|
||||
};
|
||||
export interface OnSetCommonCodesProps {
|
||||
data: Array<CodeListItem>;
|
||||
codeCl: string;
|
||||
code1Filter?: Array<any>;
|
||||
};
|
||||
@@ -62,7 +72,7 @@ export const SubLayout = () => {
|
||||
|
||||
const { isNativeEnvironment } = useAppBridge();
|
||||
const { mutateAsync: homeGroups } = useHomeGroupsMutation();
|
||||
const { mutateAsync: codesListByCodeCl} = useCodesListByCodeClMutation();
|
||||
const { mutateAsync: codesSelect} = useCodesSelectMutation();
|
||||
const { mutateAsync: shortcutUser } = useShortcutUserMutation();
|
||||
const { mutateAsync: shortcutDefault } = useShortcutDefaultMutation();
|
||||
const { mutateAsync: businessPropertyByMid } = useBusinessPropertyByMidMutation();
|
||||
@@ -92,11 +102,7 @@ export const SubLayout = () => {
|
||||
setLoginSuccess(true);
|
||||
setHeaderNavigationKey(headerNavigationKey + 1);
|
||||
|
||||
let filter0022: Array<string> = ['01', '02', '03', '05', '14', '21', '24', '26', '31'];
|
||||
callServiceCode({
|
||||
codeCl: '0022',
|
||||
code1Filter: filter0022
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
@@ -206,21 +212,59 @@ export const SubLayout = () => {
|
||||
callLogin(userParmas).then(() => {
|
||||
callHomeGroups();
|
||||
callShortcutUser();
|
||||
|
||||
callCodesSelect({ codeCl: '0001' });
|
||||
callCodesSelect({ codeCl: '0002' });
|
||||
|
||||
let filter0022: Array<string> = ['01', '02', '03', '05', '14', '21', '24', '26', '31'];
|
||||
callCodesSelect({
|
||||
codeCl: '0022',
|
||||
code1Filter: filter0022
|
||||
});
|
||||
|
||||
callCodesSelect({ codeCl: '0074' });
|
||||
|
||||
}).catch((error: any) => {
|
||||
setLoginSuccess(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const callServiceCode = ({
|
||||
const callCodesSelect = ({
|
||||
codeCl,
|
||||
code1Filter
|
||||
}: CallServiceCodeProps) => {
|
||||
let params = {
|
||||
codeCl: codeCl
|
||||
}: CallCodesSelectProps) => {
|
||||
let params: CodesSelectParams = {
|
||||
codeCl: codeCl,
|
||||
useCl: 0,
|
||||
method: 'post'
|
||||
};
|
||||
let options = [];
|
||||
codesListByCodeCl(params).then((rs) => {
|
||||
options = rs.map((value, index) => {
|
||||
|
||||
codesSelect(params).then((rs: CodesSelectPostResponse) => {
|
||||
if(rs){
|
||||
onSetCommonCodes({
|
||||
data: rs.codeList,
|
||||
codeCl: codeCl,
|
||||
code1Filter: code1Filter
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const onSetCommonCodes = ({
|
||||
data,
|
||||
codeCl,
|
||||
code1Filter
|
||||
}: OnSetCommonCodesProps) => {
|
||||
if(codeCl === '0001'){
|
||||
|
||||
useStore.getState().CommonStore.setCreditCardList(data);
|
||||
}
|
||||
else if(codeCl === '0002'){
|
||||
useStore.getState().CommonStore.setBankList(data);
|
||||
}
|
||||
else if(codeCl === '0022'){
|
||||
let options = [];
|
||||
options = data.map((value, index) => {
|
||||
return {
|
||||
name: value.desc1,
|
||||
value: value.code1
|
||||
@@ -231,12 +275,19 @@ export const SubLayout = () => {
|
||||
return code1Filter.includes(value.value);
|
||||
});
|
||||
}
|
||||
options = options.sort((a, b) => a.value - b.value);
|
||||
options = options.sort((a, b) => {
|
||||
if(a > b) return 1;
|
||||
else if(a < b) return -1;
|
||||
else return 0;
|
||||
});
|
||||
options.unshift({
|
||||
name: '전체', value: ''
|
||||
});
|
||||
useStore.getState().CommonStore.setServiceCodes(options);
|
||||
});
|
||||
}
|
||||
else if(codeCl === '0074'){
|
||||
useStore.getState().CommonStore.setVirtualBankList(data);
|
||||
}
|
||||
};
|
||||
|
||||
const saveToken = (token: LoginResponse) => {
|
||||
|
||||
Reference in New Issue
Block a user