대시보드 추가기능 + 계좌인증
This commit is contained in:
@@ -30,6 +30,8 @@ interface KisRuntimeStoreState {
|
||||
|
||||
verifiedCredentials: KisRuntimeCredentials | null;
|
||||
isKisVerified: boolean;
|
||||
isKisProfileVerified: boolean;
|
||||
verifiedAccountNo: string | null;
|
||||
tradingEnv: KisTradingEnv;
|
||||
|
||||
wsApprovalKey: string | null;
|
||||
@@ -47,6 +49,10 @@ interface KisRuntimeStoreActions {
|
||||
credentials: KisRuntimeCredentials,
|
||||
tradingEnv: KisTradingEnv,
|
||||
) => void;
|
||||
setVerifiedKisProfile: (profile: {
|
||||
accountNo: string;
|
||||
}) => void;
|
||||
invalidateKisProfileVerification: () => void;
|
||||
invalidateKisVerification: () => void;
|
||||
clearKisRuntimeSession: (tradingEnv: KisTradingEnv) => void;
|
||||
getOrFetchWsConnection: () => Promise<KisWsConnection | null>;
|
||||
@@ -60,15 +66,23 @@ const INITIAL_STATE: KisRuntimeStoreState = {
|
||||
kisAccountNoInput: "",
|
||||
verifiedCredentials: null,
|
||||
isKisVerified: false,
|
||||
isKisProfileVerified: false,
|
||||
verifiedAccountNo: null,
|
||||
tradingEnv: "real",
|
||||
wsApprovalKey: null,
|
||||
wsUrl: null,
|
||||
_hasHydrated: false,
|
||||
};
|
||||
|
||||
const RESET_PROFILE_STATE = {
|
||||
isKisProfileVerified: false,
|
||||
verifiedAccountNo: null,
|
||||
} as const;
|
||||
|
||||
const RESET_VERIFICATION_STATE = {
|
||||
verifiedCredentials: null,
|
||||
isKisVerified: false,
|
||||
...RESET_PROFILE_STATE,
|
||||
wsApprovalKey: null,
|
||||
wsUrl: null,
|
||||
};
|
||||
@@ -105,10 +119,16 @@ export const useKisRuntimeStore = create<
|
||||
}),
|
||||
|
||||
setKisAccountNoInput: (accountNo) =>
|
||||
set({
|
||||
set((state) => ({
|
||||
kisAccountNoInput: accountNo,
|
||||
...RESET_VERIFICATION_STATE,
|
||||
}),
|
||||
...RESET_PROFILE_STATE,
|
||||
verifiedCredentials: state.verifiedCredentials
|
||||
? {
|
||||
...state.verifiedCredentials,
|
||||
accountNo: "",
|
||||
}
|
||||
: null,
|
||||
})),
|
||||
|
||||
setVerifiedKisSession: (credentials, tradingEnv) =>
|
||||
set({
|
||||
@@ -119,6 +139,33 @@ export const useKisRuntimeStore = create<
|
||||
wsUrl: null,
|
||||
}),
|
||||
|
||||
setVerifiedKisProfile: ({ accountNo }) =>
|
||||
set((state) => ({
|
||||
isKisProfileVerified: true,
|
||||
verifiedAccountNo: accountNo,
|
||||
verifiedCredentials: state.verifiedCredentials
|
||||
? {
|
||||
...state.verifiedCredentials,
|
||||
accountNo,
|
||||
}
|
||||
: state.verifiedCredentials,
|
||||
wsApprovalKey: null,
|
||||
wsUrl: null,
|
||||
})),
|
||||
|
||||
invalidateKisProfileVerification: () =>
|
||||
set((state) => ({
|
||||
...RESET_PROFILE_STATE,
|
||||
verifiedCredentials: state.verifiedCredentials
|
||||
? {
|
||||
...state.verifiedCredentials,
|
||||
accountNo: "",
|
||||
}
|
||||
: state.verifiedCredentials,
|
||||
wsApprovalKey: null,
|
||||
wsUrl: null,
|
||||
})),
|
||||
|
||||
invalidateKisVerification: () =>
|
||||
set({
|
||||
...RESET_VERIFICATION_STATE,
|
||||
@@ -196,6 +243,8 @@ export const useKisRuntimeStore = create<
|
||||
kisAccountNoInput: state.kisAccountNoInput,
|
||||
verifiedCredentials: state.verifiedCredentials,
|
||||
isKisVerified: state.isKisVerified,
|
||||
isKisProfileVerified: state.isKisProfileVerified,
|
||||
verifiedAccountNo: state.verifiedAccountNo,
|
||||
tradingEnv: state.tradingEnv,
|
||||
// wsApprovalKey/wsUrl are kept in memory only (expiration-sensitive).
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user