Skip to content

Commit

Permalink
Refactor: 폴더 구조 변경 및 모듈화 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobbymin committed Oct 25, 2024
1 parent 23fea72 commit 44cc2fd
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
3 changes: 2 additions & 1 deletion src/pages/common/redirect/api/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { getKakaoCallback } from './kakao-callback.api';
export { getKakaoCallback, KakaoCallbackQueryKey } from './kakao-callback.api';
export type { KakaoCallbackResponse } from './kakao-callback.api';
2 changes: 1 addition & 1 deletion src/pages/common/redirect/hooks/useGetKakaoCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
getKakaoCallback,
KakaoCallbackQueryKey,
KakaoCallbackResponse,
} from '../api/kakao-callback.api';
} from '@/pages';
import { useQuery } from '@tanstack/react-query';

export const useGetKakaoCallback = (code: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './components';
export * from './constants';
// export * from './constants';
export * from './hooks';
export * from './provider';
export * from './types';
Expand Down
2 changes: 2 additions & 0 deletions src/shared/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { handleCallbackError } from './handle-callback-error';

export * from './storage';
export * from './phone-number';
26 changes: 26 additions & 0 deletions src/shared/utils/storage/authLocalStorage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type StorageKey = {
accessToken?: string;
};

const initStorage = <T extends keyof StorageKey>(
key: T,
storage = window.localStorage
) => {
const storageKey = `${key}`;

const get = (): StorageKey[T] => {
const value = storage.getItem(storageKey);
return value as StorageKey[T];
};

const set = (value: StorageKey[T]) => {
if (value === undefined || value === null) {
return storage.removeItem(storageKey);
}
storage.setItem(storageKey, String(value));
};

return { get, set };
};

export const authLocalStorage = initStorage('accessToken', localStorage);
27 changes: 1 addition & 26 deletions src/shared/utils/storage/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1 @@
type StorageKey = {
accessToken?: string;
};

const initStorage = <T extends keyof StorageKey>(
key: T,
storage = window.localStorage
) => {
const storageKey = `${key}`;

const get = (): StorageKey[T] => {
const value = storage.getItem(storageKey);
return value as StorageKey[T];
};

const set = (value: StorageKey[T]) => {
if (value === undefined || value === null) {
return storage.removeItem(storageKey);
}
storage.setItem(storageKey, String(value));
};

return { get, set };
};

export const authLocalStorage = initStorage('accessToken', localStorage);
export { authLocalStorage } from './authLocalStorage';

0 comments on commit 44cc2fd

Please sign in to comment.