-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from gdsc-ssu/feat/flow-setting
feat/flow-setting
- Loading branch information
Showing
46 changed files
with
1,208 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
declare module 'Auth' { | ||
export type AuthResponse = { | ||
success: boolean; | ||
code: string; | ||
message: string; | ||
data: AuthData; | ||
}; | ||
|
||
export type AuthData = { | ||
availableHomepages: number[]; | ||
isPrivacyPolicyAgree: boolean; | ||
privacyPolicyAgreePeriod: number; | ||
dept: Dept; | ||
accessToken: string; | ||
parentDept: UserDept; | ||
branch: Branch; | ||
showMobileMain: boolean; | ||
memberNo: string; | ||
alternativeId: string; | ||
lastUpdated: string; | ||
branchGroup: BranchGroup; | ||
isPortalLogin: boolean; | ||
patronType: PatronType; | ||
disableServices: string[]; | ||
hasFamily: boolean; | ||
name: string; | ||
printMemberNo: string; | ||
patronState: PatronState; | ||
id: number; | ||
multiTypePatrons: any[]; | ||
isExpired: boolean; | ||
isFamilyLogin: boolean; | ||
}; | ||
|
||
export type UserDept = { | ||
id: number; | ||
code: string; | ||
name: string; | ||
}; | ||
|
||
export type Branch = { | ||
id: number; | ||
name: string; | ||
alias: string; | ||
libraryCode: string; | ||
sortOrder: number; | ||
}; | ||
|
||
export type BranchGroup = { | ||
id: number; | ||
name: string; | ||
}; | ||
|
||
export type PatronType = { | ||
id: number; | ||
name: string; | ||
}; | ||
|
||
export type PatronState = { | ||
id: number; | ||
name: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
declare module 'AxiosCommon' { | ||
import { | ||
AxiosInstance, | ||
AxiosInterceptorManager, | ||
AxiosRequestConfig, | ||
AxiosResponse, | ||
} from 'axios'; | ||
|
||
type CustomAxiosResponse<T = any> = { | ||
response?: T; | ||
refreshToken?: string; | ||
}; | ||
|
||
export interface CustomAxiosInterface extends AxiosInstance { | ||
interceptors: { | ||
request: AxiosInterceptorManager<AxiosRequestConfig>; | ||
response: AxiosInterceptorManager<AxiosResponse<CustomAxiosResponse>>; | ||
}; | ||
|
||
get<T>(url: string, config?: AxiosRequestConfig): Promise<T>; | ||
delete<T>(url: string, config?: AxiosRequestConfig): Promise<T>; | ||
post<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>; | ||
put<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>; | ||
patch<T>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>; | ||
} | ||
|
||
export interface CommonRequest { | ||
status: number; | ||
message: string; | ||
success?: boolean; | ||
data?: any; | ||
} | ||
interface APIDataResponse<T> { | ||
data: T; | ||
} | ||
export interface CommonResponse<T> { | ||
data: APIDataResponse<T>; | ||
status: number; | ||
statusText: string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { getAccessToken, removeAccessToken } from '@/utils/lib/tokenHandler'; | ||
import axios, { AxiosRequestConfig } from 'axios'; | ||
import { CustomAxiosInterface, CommonResponse } from 'AxiosCommon'; | ||
|
||
const apiClient: CustomAxiosInterface = axios.create({ | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
baseURL: `${process.env.NEXT_PUBLIC_BASE_URL}`, | ||
}); | ||
|
||
// 요청 interceptor | ||
apiClient.interceptors.request.use( | ||
async (config: any) => { | ||
const token = getAccessToken(); | ||
config.headers = { | ||
Accept: 'application/json, text/plain, */*', | ||
'pyxis-auth-token': `${token}`, | ||
}; | ||
return config; | ||
}, | ||
(error: unknown) => { | ||
console.log(error); | ||
return Promise.reject(error); | ||
}, | ||
); | ||
|
||
// 응답 interceptor | ||
apiClient.interceptors.response.use( | ||
async (config: any) => { | ||
return config; | ||
}, | ||
async (error: any) => { | ||
if (error.response.status === 400) { | ||
removeAccessToken(); //만료시 토큰 제거 (업데이트가 없기 떄문) | ||
} | ||
return Promise.reject(error); | ||
}, | ||
); | ||
|
||
const Get = async <T>(url: string, config?: AxiosRequestConfig): Promise<T> => { | ||
const response = await apiClient.get<CommonResponse<T>>(url, config); | ||
return response.data.data; | ||
}; | ||
|
||
const Post = async <T>( | ||
url: string, | ||
data?: any, | ||
config?: AxiosRequestConfig, | ||
): Promise<T> => { | ||
const response = await apiClient.post<CommonResponse<T>>(url, data, config); | ||
return response.data.data; | ||
}; | ||
|
||
const Put = async <T>( | ||
url: string, | ||
data?: any, | ||
config?: AxiosRequestConfig, | ||
): Promise<T> => { | ||
const response = await apiClient.put<CommonResponse<T>>(url, data, config); | ||
return response.data.data; | ||
}; | ||
|
||
const Patch = async <T>( | ||
url: string, | ||
data?: any, | ||
config?: AxiosRequestConfig, | ||
): Promise<T> => { | ||
const response = await apiClient.patch<CommonResponse<T>>(url, data, config); | ||
return response.data.data; | ||
}; | ||
|
||
const Delete = async <T>( | ||
url: string, | ||
config?: AxiosRequestConfig, | ||
): Promise<T> => { | ||
const response = await apiClient.delete<CommonResponse<T>>(url, config); | ||
return response.data.data; | ||
}; | ||
|
||
export { | ||
Get as get, | ||
Post as post, | ||
Put as put, | ||
Patch as patch, | ||
Delete as remove, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { AuthData, AuthResponse } from 'Auth'; | ||
import axios, { AxiosResponse } from 'axios'; | ||
|
||
class AuthApi { | ||
/** 로그인 */ | ||
login = async (loginId: string, password: string): Promise<AuthData> => { | ||
const data: AxiosResponse<AuthResponse> = await axios({ | ||
method: 'post', | ||
url: `${process.env.NEXT_PUBLIC_BASE_URL}/login`, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
data: { | ||
loginId, | ||
password, | ||
}, | ||
}); | ||
|
||
return data.data.data; | ||
}; | ||
} | ||
|
||
export default AuthApi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { atom } from 'jotai'; | ||
|
||
export type authInfoType = { | ||
name: string; | ||
sId: string; | ||
}; | ||
|
||
export const authInfoState = atom<authInfoType | null>(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { atom } from 'jotai'; | ||
|
||
export const headerTitleState = atom<string>(''); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
client/src/components/Field/TextInput/TextInput.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { StoryObj } from '@storybook/react'; | ||
import TextInput from '.'; | ||
|
||
const meta = { | ||
title: 'Field/TextInput', | ||
component: TextInput, | ||
tags: ['autodocs'], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
value: '', | ||
placeholder: '값을 입력해주세요', | ||
warning: false, | ||
}, | ||
}; | ||
|
||
export const Input: Story = { | ||
args: { | ||
value: '입력 값 입니다.', | ||
warning: false, | ||
}, | ||
}; | ||
|
||
export const Warning: Story = { | ||
args: { | ||
value: '입력 값 입니다.', | ||
warning: true, | ||
}, | ||
}; | ||
|
||
export const WarningCaption: Story = { | ||
args: { | ||
value: '입력 값 입니다.', | ||
warning: true, | ||
warningCaption: '경고 문구입니다.', | ||
}, | ||
}; |
Oops, something went wrong.