Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Utils] 공용 유틸리티 추가 #169

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
},
"dependencies": {
"@clab/design-system": "workspace:*",
"@clab/utils": "workspace:*",
"@gwansikk/server-chain": "^0.5.2",
"@hookform/resolvers": "^3.3.4",
"@tanstack/react-query": "^5.17.19",
"classnames": "^2.5.1",
"next": "14.2.3",
"qrcode.react": "^3.1.0",
"react": "^18",
Expand Down
1 change: 1 addition & 0 deletions apps/land/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@clab/design-system": "workspace:*",
"@clab/utils": "workspace:*",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18"
Expand Down
7 changes: 2 additions & 5 deletions apps/member/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,20 @@
"dependencies": {
"@channel.io/channel-web-sdk-loader": "^1.1.7",
"@clab/design-system": "workspace:*",
"@clab/utils": "workspace:*",
"@gwansikk/server-chain": "^0.5.2",
"@sentry/react": "^8.9.2",
"@sentry/vite-plugin": "^2.18.0",
"@tanstack/react-query": "^5.18.1",
"@tanstack/react-query-devtools": "^5.40.1",
"classnames": "^2.5.1",
"clsx": "^2.1.0",
"dayjs": "^1.11.10",
"entities": "^4.5.0",
"framer-motion": "^10.18.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-icons": "^5.0.1",
"react-router-dom": "^6.21.2",
"recoil": "^0.7.7",
"tailwind-merge": "^2.2.2"
"recoil": "^0.7.7"
},
"devDependencies": {
"@clab/config": "workspace:*",
Expand Down
24 changes: 13 additions & 11 deletions apps/member/src/api/activity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { createPagination } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination, createFormData } from '@utils/api';
import { createFormData } from '@utils/api';
import { groupBoardParser } from '@utils/group';

import type {
Expand Down Expand Up @@ -60,7 +62,7 @@ export interface PostActivityPhotoParams {
*/
export async function getActivityPhoto(page: number, size: number) {
const { data } = await server.get<ResponsePagination<ActivityPhotoItem>>({
url: createCommonPagination(END_POINT.MAIN_ACTIVITY_PHOTO, { page, size }),
url: createPagination(END_POINT.MAIN_ACTIVITY_PHOTO, { page, size }),
});

return data;
Expand All @@ -75,7 +77,7 @@ export async function getActivityGroupByStatus(
size: number,
) {
const { data } = await server.get<ResponsePagination<ActivityGroupItem>>({
url: createCommonPagination(END_POINT.ACTIVITY_GROUP_MEMBER_STATUS, {
url: createPagination(END_POINT.ACTIVITY_GROUP_MEMBER_STATUS, {
activityGroupStatus,
page,
size,
Expand Down Expand Up @@ -111,7 +113,7 @@ export async function postActivityGroupMemberApply({
}: PostActivityGroupMemberApplyParams) {
const { data } = await server.post<ActivityRequestType, BaseResponse<number>>(
{
url: createCommonPagination(END_POINT.ACTIVITY_GROUP_MEMBER_APPLY, {
url: createPagination(END_POINT.ACTIVITY_GROUP_MEMBER_APPLY, {
activityGroupId,
}),
body,
Expand All @@ -132,7 +134,7 @@ export async function getActivityGroupApplyByStatus(
const { data } = await server.get<
ResponsePagination<ActivityApplyMemberType>
>({
url: createCommonPagination(END_POINT.ACTIVITY_GROUP_ADMIN_MEMBERS, {
url: createPagination(END_POINT.ACTIVITY_GROUP_ADMIN_MEMBERS, {
activityGroupId,
page,
size,
Expand All @@ -149,7 +151,7 @@ export async function getActivityGroupMemberMy(page: number, size: number) {
const { data } = await server.get<
ResponsePagination<ActivityGroupMemberMyType>
>({
url: createCommonPagination(END_POINT.ACTIVITY_GROUP_MEMBER_MY, {
url: createPagination(END_POINT.ACTIVITY_GROUP_MEMBER_MY, {
page,
size,
}),
Expand All @@ -167,7 +169,7 @@ export async function patchActivityGroupMemberApply({
status,
}: PatchActivityGroupMemberApplyParams) {
const { data } = await server.patch<never, BaseResponse<string>>({
url: createCommonPagination(END_POINT.ACTIVITY_GROUP_ADMIN_ACCEPT, {
url: createPagination(END_POINT.ACTIVITY_GROUP_ADMIN_ACCEPT, {
activityGroupId,
memberId,
status,
Expand All @@ -182,7 +184,7 @@ export async function patchActivityGroupMemberApply({
*/
export async function getActivityBoard(activityGroupBoardId: number) {
const { data } = await server.get<BaseResponse<ActivityBoardType>>({
url: createCommonPagination(END_POINT.ACTIVITY_GROUP_BOARDS, {
url: createPagination(END_POINT.ACTIVITY_GROUP_BOARDS, {
activityGroupBoardId,
}),
});
Expand All @@ -195,7 +197,7 @@ export async function getActivityBoard(activityGroupBoardId: number) {
*/
export async function getActivityBoardMyAssignment(parentId: number) {
const { data } = await server.get<BaseResponse<ActivityBoardType[]>>({
url: createCommonPagination(END_POINT.ACTIVITY_GROUP_BOARDS_MY_ASSIGNMENT, {
url: createPagination(END_POINT.ACTIVITY_GROUP_BOARDS_MY_ASSIGNMENT, {
parentId,
}),
});
Expand Down Expand Up @@ -236,7 +238,7 @@ export async function postActivityBoard({
SubmitBoardType,
BaseResponse<{ id: number; parentId: number }>
>({
url: createCommonPagination(END_POINT.ACTIVITY_GROUP_BOARD, params),
url: createPagination(END_POINT.ACTIVITY_GROUP_BOARD, params),
body: {
...body,
fileUrls: fileUrl ? [fileUrl] : undefined,
Expand Down Expand Up @@ -273,7 +275,7 @@ export async function patchActivityBoard({
SubmitBoardType,
BaseResponse<{ id: number; parentId: number }>
>({
url: createCommonPagination(END_POINT.ACTIVITY_GROUP_BOARDS, {
url: createPagination(END_POINT.ACTIVITY_GROUP_BOARDS, {
activityGroupBoardId,
}),
body: {
Expand Down
9 changes: 5 additions & 4 deletions apps/member/src/api/birthday.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createPagination } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination } from '@utils/api';

import { PaginationType } from '@type/api';
import type { ResponsePagination } from '@type/api';
import type { MemberInfo } from '@type/member';

import { server } from './server';
Expand All @@ -13,8 +14,8 @@ export const getBirthday = async (
size: number,
) => {
const params = { month, page, size };
const { data } = await server.get<PaginationType<MemberInfo>>({
url: createCommonPagination(END_POINT.MY_BIRTHDAY, params),
const { data } = await server.get<ResponsePagination<MemberInfo>>({
url: createPagination(END_POINT.MY_BIRTHDAY, params),
});

return data;
Expand Down
9 changes: 5 additions & 4 deletions apps/member/src/api/blog.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { createPagination } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination } from '@utils/api';

import { BaseResponse, PaginationType } from '@type/api';
import type { BaseResponse, ResponsePagination } from '@type/api';
import type { BlogPost } from '@type/blog';

import { server } from './server';
Expand All @@ -11,8 +12,8 @@ import { server } from './server';
*/
export const getBlog = async (page: number, size: number) => {
const params = { page, size };
const { data } = await server.get<PaginationType<BlogPost>>({
url: createCommonPagination(END_POINT.BLOG, params),
const { data } = await server.get<ResponsePagination<BlogPost>>({
url: createPagination(END_POINT.BLOG, params),
});

return data;
Expand Down
9 changes: 5 additions & 4 deletions apps/member/src/api/board.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createPagination } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination } from '@utils/api';

import { BaseResponse, ResponsePagination } from '@type/api';
import type {
Expand Down Expand Up @@ -27,7 +28,7 @@ export interface PatchBoardsParams extends CommunityWriteItem {
*/
export async function getMyBoards(page: number, size: number) {
const { data } = await server.get<ResponsePagination<Board>>({
url: createCommonPagination(END_POINT.MY_BOARDS, { page, size }),
url: createPagination(END_POINT.MY_BOARDS, { page, size }),
});

return data;
Expand All @@ -37,7 +38,7 @@ export async function getMyBoards(page: number, size: number) {
*/
export async function getBoards(page: number, size: number) {
const { data } = await server.get<ResponsePagination<Board>>({
url: createCommonPagination(END_POINT.BOARDS, { page, size }),
url: createPagination(END_POINT.BOARDS, { page, size }),
});

return data;
Expand All @@ -51,7 +52,7 @@ export async function getBoardsList(
size: number,
) {
const { data } = await server.get<ResponsePagination<CommunityPostItem>>({
url: createCommonPagination(END_POINT.BOARDS_LIST, {
url: createPagination(END_POINT.BOARDS_LIST, {
category: category.toUpperCase(), // 백엔드 Enum 타입에 맞춰 대문자로 변경
page,
size,
Expand Down
11 changes: 6 additions & 5 deletions apps/member/src/api/book.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createPagination, createURL } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination, createPath } from '@utils/api';

import type {
BaseResponse,
Expand Down Expand Up @@ -31,7 +32,7 @@ export interface GetBookLoanRecordConditionsParams
*/
export async function getBooks(page: number, size: number) {
const { data } = await server.get<ResponsePagination<BookItem>>({
url: createCommonPagination(END_POINT.BOOK, { page, size }),
url: createPagination(END_POINT.BOOK, { page, size }),
});

return data;
Expand Down Expand Up @@ -96,7 +97,7 @@ export async function getBookLoanRecordConditions({
const { data } = await server.get<
ResponsePagination<BookLoanRecordConditionType>
>({
url: createCommonPagination(END_POINT.BOOK_LOAN_CONDITIONS, {
url: createPagination(END_POINT.BOOK_LOAN_CONDITIONS, {
bookId,
borrowerId,
isReturned,
Expand All @@ -118,7 +119,7 @@ export async function getBookLoanRecordOverdue({
const { data } = await server.get<
ResponsePagination<BookLoanRecordOverDueResponse>
>({
url: createCommonPagination(END_POINT.BOOK_LOAN_OVERDUE, {
url: createPagination(END_POINT.BOOK_LOAN_OVERDUE, {
page,
size,
}),
Expand All @@ -132,6 +133,6 @@ export async function getBookLoanRecordOverdue({
*/
export function patchBookLoanRecordApprove(id: number) {
return server.patch<null, BaseResponse<number>>({
url: createPath(END_POINT.BOOK_LOAN_RECORD_APPROVE, id),
url: createURL(END_POINT.BOOK_LOAN_RECORD_APPROVE, id),
});
}
9 changes: 5 additions & 4 deletions apps/member/src/api/comment.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createPagination, createURL } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination, createPath } from '@utils/api';

import type { BaseResponse, ResponsePagination } from '@type/api';
import type { CommentItem, CommentListItem } from '@type/comment';
Expand All @@ -21,7 +22,7 @@ export interface PostCommentWriteParams {
*/
export const getMyComments = async (page: number, size: number) => {
const { data } = await server.get<ResponsePagination<CommentItem>>({
url: createCommonPagination(END_POINT.MY_COMMENTS, {
url: createPagination(END_POINT.MY_COMMENTS, {
page,
size,
}),
Expand All @@ -35,7 +36,7 @@ export const getMyComments = async (page: number, size: number) => {
export const getComments = async (id: number, page: number, size: number) => {
const params = { id, page, size };
const { data } = await server.get<ResponsePagination<CommentListItem>>({
url: createCommonPagination(END_POINT.COMMENTS(id), params),
url: createPagination(END_POINT.COMMENTS(id), params),
});

return data;
Expand All @@ -49,7 +50,7 @@ export const postCommentWrite = ({
body,
}: PostCommentWriteParams) => {
return server.post<CommentWriteRequestData, BaseResponse<number>>({
url: createPath(
url: createURL(
END_POINT.COMMENTS(boardId),
parentId && `?parentId=${parentId}`,
),
Expand Down
5 changes: 3 additions & 2 deletions apps/member/src/api/hire.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createPagination } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination } from '@utils/api';

import type { BaseResponse, ResponsePagination } from '@type/api';
import type { CommunityHireBoard } from '@type/community';
Expand All @@ -10,7 +11,7 @@ import { server } from './server';
export const getMyHire = async (page: number, size: number) => {
const params = { page, size };
const { data } = await server.get<ResponsePagination<CommunityHireBoard>>({
url: createCommonPagination(END_POINT.MY_HIRE, params),
url: createPagination(END_POINT.MY_HIRE, params),
});

return data;
Expand Down
5 changes: 3 additions & 2 deletions apps/member/src/api/interceptors.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { createURL } from '@clab/utils';

import { API_BASE_URL, END_POINT, HTTP_STATUS_CODE } from '@constants/api';
import { IS_PRODUCTION } from '@constants/environment';
import type { FetchOptions, Interceptor } from '@gwansikk/server-chain';
import {
authorization,
createPath,
getAccessToken,
getRefreshToken,
removeTokens,
Expand Down Expand Up @@ -58,7 +59,7 @@ export const tokenHandler: Interceptor<Response> = async (response, method) => {
reissueLock = true;
// 토큰 갱신 요청
try {
const res = await fetch(createPath(API_BASE_URL, END_POINT.LOGIN_REISSUE), {
const res = await fetch(createURL(API_BASE_URL, END_POINT.LOGIN_REISSUE), {
method: 'POST',
headers: {
...authorization(preRefreshToken),
Expand Down
5 changes: 3 additions & 2 deletions apps/member/src/api/member.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createPagination } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination } from '@utils/api';

import type {
BaseResponse,
Expand Down Expand Up @@ -30,7 +31,7 @@ export interface PatchUserInfoParams {
*/
export async function getMembers({ id, name, page, size }: GetMembersParams) {
const { data } = await server.get<ResponsePagination<MemberInfo>>({
url: createCommonPagination(END_POINT.MEMBERS, {
url: createPagination(END_POINT.MEMBERS, {
id,
name,
page,
Expand Down
5 changes: 3 additions & 2 deletions apps/member/src/api/membershipFee.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createPagination } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination } from '@utils/api';

import type {
BaseResponse,
Expand Down Expand Up @@ -41,7 +42,7 @@ export const getMembershipFee = async ({
size,
}: GetMembershipFeeParams) => {
const { data } = await server.get<ResponsePagination<MembershipFeeType>>({
url: createCommonPagination(END_POINT.MEMBERSHIP_FEE, {
url: createPagination(END_POINT.MEMBERSHIP_FEE, {
memberId,
memberName,
category,
Expand Down
5 changes: 3 additions & 2 deletions apps/member/src/api/news.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createPagination } from '@clab/utils';

import { END_POINT } from '@constants/api';
import { createCommonPagination } from '@utils/api';

import { BaseResponse, ResponsePagination } from '@type/api';
import type { CommunityNewsBoard } from '@type/community';
Expand All @@ -10,7 +11,7 @@ import { server } from './server';
export const getNews = async (page: number, size: number) => {
const params = { page, size };
const { data } = await server.get<ResponsePagination<CommunityNewsBoard>>({
url: createCommonPagination(END_POINT.MY_NEWS, params),
url: createPagination(END_POINT.MY_NEWS, params),
});

return data;
Expand Down
Loading