첫 커밋
This commit is contained in:
39
src/entities/user/model/store.ts
Normal file
39
src/entities/user/model/store.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { lens } from '@dhmk/zustand-lens';
|
||||
import { SetStateAction } from 'react';
|
||||
import { UserInfo } from '@/entities/user/model/types';
|
||||
import { StorageKeys } from '~/shared/constants/local-storage';
|
||||
|
||||
export interface UserInfoState {
|
||||
UserInfo: UserInfo;
|
||||
setUserInfo: (update: SetStateAction<Partial<UserInfo>>) => void;
|
||||
resetUserInfo: () => void;
|
||||
}
|
||||
|
||||
const initialState = {
|
||||
UserInfo: {} as UserInfo,
|
||||
} as UserInfoState;
|
||||
|
||||
export const createUserInfoStore = lens<UserInfoState>((set, get) => ({
|
||||
...initialState,
|
||||
setUserInfo: (update) => {
|
||||
set((state: UserInfoState) => {
|
||||
const newUserInfo = typeof update === 'function' ? update(state.UserInfo) : update;
|
||||
return {
|
||||
...state,
|
||||
UserInfo: { ...state.UserInfo, ...newUserInfo },
|
||||
};
|
||||
});
|
||||
},
|
||||
resetUserInfo: () => {
|
||||
window.localStorage.removeItem(StorageKeys.TokenType);
|
||||
window.localStorage.removeItem(StorageKeys.AccessToken);
|
||||
window.localStorage.removeItem(StorageKeys.RefreshToken);
|
||||
window.localStorage.removeItem(StorageKeys.AccessTokenExpiresIn);
|
||||
window.localStorage.removeItem(StorageKeys.RefreshTokenExpiresIn);
|
||||
window.localStorage.removeItem(StorageKeys.MenuGrants);
|
||||
window.localStorage.removeItem(StorageKeys.Usrid);
|
||||
window.localStorage.removeItem(StorageKeys.ClientAddressIP);
|
||||
window.localStorage.removeItem(StorageKeys.Requires2FA);
|
||||
set(initialState);
|
||||
},
|
||||
}));
|
||||
89
src/entities/user/model/types.ts
Normal file
89
src/entities/user/model/types.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
export interface LoginParams {
|
||||
id: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
export interface MenuGrantsItem {
|
||||
menuId: number;
|
||||
grant: number;
|
||||
};
|
||||
export interface LoginResponse {
|
||||
tokenType?: string;
|
||||
accessToken?: string;
|
||||
refreshToken?: string;
|
||||
accessTokenExpiresIn?: number;
|
||||
refreshTokenExpiresIn?: number;
|
||||
menuGrants?: Array<MenuGrantsItem>;
|
||||
usrid?: string;
|
||||
clientAddressIP?: string;
|
||||
tempToken?: string,
|
||||
tempTokenExpiresIn?: number;
|
||||
available2FAMethod?: Array<string>;
|
||||
requires2FA?: boolean;
|
||||
};
|
||||
export interface UserInfo extends LoginResponse{
|
||||
|
||||
}
|
||||
export interface UserParams {
|
||||
|
||||
};
|
||||
export interface UserExistsUseridParams {
|
||||
usrId: string;
|
||||
};
|
||||
export interface UserExistsUseridResponse {
|
||||
exists: boolean;
|
||||
};
|
||||
export interface VerificationsItem {
|
||||
type: string;
|
||||
contact: string;
|
||||
};
|
||||
export interface UserCreateParams {
|
||||
userId: string;
|
||||
password: string;
|
||||
loginRange: string;
|
||||
verification: Array<VerificationsItem>
|
||||
};
|
||||
export interface UserData {
|
||||
usrid: string;
|
||||
mid: string;
|
||||
gid: string;
|
||||
aid: string;
|
||||
pw: string;
|
||||
authCd: string;
|
||||
status: string;
|
||||
regDt: string;
|
||||
memo: string;
|
||||
changeDt: string;
|
||||
failCnt: number;
|
||||
oldPw1: string;
|
||||
oldPw2: string;
|
||||
oldPw3: string;
|
||||
oldPw4: string;
|
||||
worker: string;
|
||||
loginCd: string;
|
||||
pwWorkIp: string;
|
||||
pwCheckYn: string;
|
||||
loginFailDt: string;
|
||||
loginFailTm: string;
|
||||
loginFailIp: string;
|
||||
desaYn: string;
|
||||
desaAccType: string;
|
||||
desaAccIp: string;
|
||||
desaProcType: string;
|
||||
desaFormat: string;
|
||||
desaSvcCl: string;
|
||||
emailAuth1: string;
|
||||
emailAuth2: string;
|
||||
emailAuth3: string;
|
||||
authDt: string;
|
||||
authTm: string;
|
||||
userAidGroupYn: string;
|
||||
userAidGroupId: string;
|
||||
subNm: string;
|
||||
subLevel: string;
|
||||
multiAccessYn: string;
|
||||
};
|
||||
export interface UserCreateResponse {
|
||||
user: UserData;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user