From 9c41efb3c0827c6b4a504f961dabe2c65e1f2fc6 Mon Sep 17 00:00:00 2001 From: gwansikk Date: Sat, 21 Sep 2024 19:14:12 +0900 Subject: [PATCH] =?UTF-8?q?refactor(member):=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=83=80=EC=9E=85=20=EC=A0=9C=EA=B1=B0=20(#238)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/member/src/api/accuse.ts | 11 ++++++++--- apps/member/src/api/blog.ts | 13 ++++++++++++- apps/member/src/api/notification.ts | 9 +++++++-- apps/member/src/api/recruitment.ts | 14 ++++++++++++-- apps/member/src/components/common/Toast/Toast.tsx | 10 ++++------ apps/member/src/constants/select.ts | 4 ---- apps/member/src/{styles => }/globals.css | 0 apps/member/src/hooks/common/useToast.ts | 12 ++++++++---- apps/member/src/main.tsx | 2 +- .../SupportPage/components/RequestSection.tsx | 11 ++++++----- .../SupportPage/hooks/useSupportRequestForm.ts | 14 ++++++++++---- apps/member/src/store/toast.ts | 4 ++-- apps/member/src/types/accuses.ts | 5 ----- apps/member/src/types/blog.ts | 11 ----------- apps/member/src/types/notification.ts | 5 ----- apps/member/src/types/recruitment.ts | 11 ----------- apps/member/src/types/support.ts | 10 ---------- apps/member/src/types/toast.ts | 1 - 18 files changed, 70 insertions(+), 77 deletions(-) rename apps/member/src/{styles => }/globals.css (100%) delete mode 100644 apps/member/src/types/accuses.ts delete mode 100644 apps/member/src/types/blog.ts delete mode 100644 apps/member/src/types/notification.ts delete mode 100644 apps/member/src/types/recruitment.ts delete mode 100644 apps/member/src/types/support.ts delete mode 100644 apps/member/src/types/toast.ts diff --git a/apps/member/src/api/accuse.ts b/apps/member/src/api/accuse.ts index 8b3bccb7..73f4a965 100644 --- a/apps/member/src/api/accuse.ts +++ b/apps/member/src/api/accuse.ts @@ -1,13 +1,18 @@ import { END_POINT } from '@constants/api'; -import type { AccusesType } from '@type/accuses'; import { BaseResponse } from '@type/api'; import { server } from './server'; +export interface Accuses { + targetType: string; + targetId: number; + reason: string; +} + // 신고하기 -export const postAccuses = async (body: AccusesType) => { - const { data } = await server.post>({ +export const postAccuses = async (body: Accuses) => { + const { data } = await server.post>({ url: END_POINT.ACCUSES, body, }); diff --git a/apps/member/src/api/blog.ts b/apps/member/src/api/blog.ts index b52fd3b6..10ca58e5 100644 --- a/apps/member/src/api/blog.ts +++ b/apps/member/src/api/blog.ts @@ -3,10 +3,21 @@ import { createPagination } from '@clab-platforms/utils'; import { END_POINT } from '@constants/api'; import type { BaseResponse, ResponsePagination } from '@type/api'; -import type { BlogPost } from '@type/blog'; import { server } from './server'; +export interface BlogPost { + id: number; + memberId: string; + name: string; + title: string; + subTitle: string; + content: string; + imageUrl: string; + createdAt: string; + isOwner: boolean; +} + /** * 블로그 포스트 조회 */ diff --git a/apps/member/src/api/notification.ts b/apps/member/src/api/notification.ts index 119b5ee0..4d4c30b7 100644 --- a/apps/member/src/api/notification.ts +++ b/apps/member/src/api/notification.ts @@ -3,16 +3,21 @@ import { createPagination } from '@clab-platforms/utils'; import { END_POINT } from '@constants/api'; import type { ResponsePagination } from '@type/api'; -import type { NotificationItem } from '@type/notification'; import { server } from './server'; +export interface Notification { + id: number; + content: string; + createdAt: string; +} + /** * 내 알림을 조회합니다. */ export const getMyNotifications = async (page: number, size: number) => { const params = { page, size }; - const { data } = await server.get>({ + const { data } = await server.get>({ url: createPagination(END_POINT.MY_NOTIFICATION, params), }); diff --git a/apps/member/src/api/recruitment.ts b/apps/member/src/api/recruitment.ts index eb6176a9..28dbc0af 100644 --- a/apps/member/src/api/recruitment.ts +++ b/apps/member/src/api/recruitment.ts @@ -1,15 +1,25 @@ import { END_POINT } from '@constants/api'; import { BaseResponse } from '@type/api'; -import { RecruitmentType } from '@type/recruitment'; +import type { ApplicationType } from '@type/application'; import { server } from './server'; +export interface Recruitment { + id: number; + startDate: string; + endDate: string; + applicationType: ApplicationType; + target: string; + status: string; + updatedAt: string; +} + /** * 최신 모집 공고 5개 조회 */ export async function getRecruitment() { - const { data } = await server.get>({ + const { data } = await server.get>({ url: END_POINT.RECRUITMENT, }); diff --git a/apps/member/src/components/common/Toast/Toast.tsx b/apps/member/src/components/common/Toast/Toast.tsx index af2fb301..142dc244 100644 --- a/apps/member/src/components/common/Toast/Toast.tsx +++ b/apps/member/src/components/common/Toast/Toast.tsx @@ -7,17 +7,15 @@ import { } from '@clab-platforms/icon'; import { cn } from '@clab-platforms/utils'; -import { useSetToastStore } from '@store/toast'; - -import type { ToastStateType } from '@type/toast'; +import { type TToastState, useSetToastStore } from '@store/toast'; interface ToastProps { id: number; - state: ToastStateType; + state: TToastState; message: string; } -const stateIcon = { +const STATE_ICON = { success: , error: , warning: , @@ -58,7 +56,7 @@ const Toast = ({ id, state, message }: ToastProps) => { )} onClick={handleClick} > -
{stateIcon[state]}
+
{STATE_ICON[state]}

{message}

); diff --git a/apps/member/src/constants/select.ts b/apps/member/src/constants/select.ts index 541bd0a3..1df43cfd 100644 --- a/apps/member/src/constants/select.ts +++ b/apps/member/src/constants/select.ts @@ -8,10 +8,6 @@ type Options = { value: V; }; -// type SelectOptions = { -// [key: string]: Options[]; -// }; - export const SELECT_DEFAULT_OPTION = 'none'; export const SELECT_OPTIONS = { diff --git a/apps/member/src/styles/globals.css b/apps/member/src/globals.css similarity index 100% rename from apps/member/src/styles/globals.css rename to apps/member/src/globals.css diff --git a/apps/member/src/hooks/common/useToast.ts b/apps/member/src/hooks/common/useToast.ts index f2e5ff40..de801b14 100644 --- a/apps/member/src/hooks/common/useToast.ts +++ b/apps/member/src/hooks/common/useToast.ts @@ -1,15 +1,19 @@ -import { useSetToastStore } from '@store/toast'; - -import type { ToastStateType } from '@type/toast'; +import { type TToastState, useSetToastStore } from '@store/toast'; interface AddToastProps { - state: ToastStateType; + state: TToastState; message: string; } +/** + * 토스트 알림을 조작합니다. + */ const useToast = () => { const setToast = useSetToastStore(); + /** + * 새로운 토스트를 생성합니다. + */ const addToast = ({ state, message }: AddToastProps) => { setToast((prev) => [ ...prev, diff --git a/apps/member/src/main.tsx b/apps/member/src/main.tsx index 9a9ca508..952af7c6 100644 --- a/apps/member/src/main.tsx +++ b/apps/member/src/main.tsx @@ -21,9 +21,9 @@ import { } from '@constants/environment.ts'; import { queryClient } from '@hooks/queries'; import * as Sentry from '@sentry/react'; -import '@styles/globals.css'; import App from './App.tsx'; +import './globals.css'; /** * Channel Talk diff --git a/apps/member/src/pages/SupportPage/components/RequestSection.tsx b/apps/member/src/pages/SupportPage/components/RequestSection.tsx index 741df35c..6b391710 100644 --- a/apps/member/src/pages/SupportPage/components/RequestSection.tsx +++ b/apps/member/src/pages/SupportPage/components/RequestSection.tsx @@ -19,15 +19,16 @@ import useToast from '@hooks/common/useToast'; import { useMembershipFeeMutation } from '@hooks/queries/useMembershipFeeMutation'; import { createFormData } from '@utils/api'; -import type { SupportRequestDataType } from '@type/support'; - -import { useSupportRequestForm } from '../hooks/useSupportRequestForm'; +import { + type SupportRequestData, + useSupportRequestForm, +} from '../hooks/useSupportRequestForm'; export function RequestSection() { const { membershipFeeMutate, isPending, isSuccess } = useMembershipFeeMutation(); - const handleRequestSubmit = async (data: SupportRequestDataType) => { + const handleRequestSubmit = async (data: SupportRequestData) => { membershipFeeMutate({ ...data, multipartFile: createFormData(data.file), @@ -70,7 +71,7 @@ const TABS_OPTIONS = [ interface RequestFormProps { isPending: boolean; isSuccess: boolean; - onSubmit: (data: SupportRequestDataType) => void; + onSubmit: (data: SupportRequestData) => void; } export function RequestForm({ diff --git a/apps/member/src/pages/SupportPage/hooks/useSupportRequestForm.ts b/apps/member/src/pages/SupportPage/hooks/useSupportRequestForm.ts index caf04ae4..1b48d769 100644 --- a/apps/member/src/pages/SupportPage/hooks/useSupportRequestForm.ts +++ b/apps/member/src/pages/SupportPage/hooks/useSupportRequestForm.ts @@ -2,9 +2,8 @@ import { useCallback, useState } from 'react'; import { SELECT_DEFAULT_OPTION } from '@constants/select'; -import type { SupportRequestDataType } from '@type/support'; - const INIT_CHECK_LIST = [false, false, false]; + const INIT_FORM_DATA = { category: SELECT_DEFAULT_OPTION, amount: 0, @@ -13,9 +12,16 @@ const INIT_FORM_DATA = { file: null, }; +export interface SupportRequestData { + category: string; + amount: number; + content: string; + account: string; + file?: File | null; +} + export const useSupportRequestForm = () => { - const [formData, setFormData] = - useState(INIT_FORM_DATA); + const [formData, setFormData] = useState(INIT_FORM_DATA); const [checkList, setCheckList] = useState(INIT_CHECK_LIST); const handleInputChange = useCallback( diff --git a/apps/member/src/store/toast.ts b/apps/member/src/store/toast.ts index 7c9f9eeb..8919fd67 100644 --- a/apps/member/src/store/toast.ts +++ b/apps/member/src/store/toast.ts @@ -7,11 +7,11 @@ import { import { ATOM_KEY } from '@constants/key'; -import type { ToastStateType } from '@type/toast'; +export type TToastState = 'success' | 'error' | 'warning'; interface ToastItem { id: number; - state: ToastStateType; + state: TToastState; message: string; } diff --git a/apps/member/src/types/accuses.ts b/apps/member/src/types/accuses.ts deleted file mode 100644 index 3582b29b..00000000 --- a/apps/member/src/types/accuses.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface AccusesType { - targetType: string; - targetId: number; - reason: string; -} diff --git a/apps/member/src/types/blog.ts b/apps/member/src/types/blog.ts deleted file mode 100644 index ac37e255..00000000 --- a/apps/member/src/types/blog.ts +++ /dev/null @@ -1,11 +0,0 @@ -export interface BlogPost { - id: number; - memberId: string; - name: string; - title: string; - subTitle: string; - content: string; - imageUrl: string; - createdAt: string; - isOwner: boolean; -} diff --git a/apps/member/src/types/notification.ts b/apps/member/src/types/notification.ts deleted file mode 100644 index 98c5384d..00000000 --- a/apps/member/src/types/notification.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface NotificationItem { - id: number; - content: string; - createdAt: string; -} diff --git a/apps/member/src/types/recruitment.ts b/apps/member/src/types/recruitment.ts deleted file mode 100644 index 6bda8a33..00000000 --- a/apps/member/src/types/recruitment.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ApplicationType } from './application'; - -export interface RecruitmentType { - id: number; - startDate: string; - endDate: string; - applicationType: ApplicationType; - target: string; - status: string; - updatedAt: string; -} diff --git a/apps/member/src/types/support.ts b/apps/member/src/types/support.ts deleted file mode 100644 index 9cf0f0e2..00000000 --- a/apps/member/src/types/support.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * SupportRequestForm에서 사용되는 데이터 타입 - */ -export interface SupportRequestDataType { - category: string; - amount: number; - content: string; - account: string; - file?: File | null; -} diff --git a/apps/member/src/types/toast.ts b/apps/member/src/types/toast.ts deleted file mode 100644 index 674d4ef1..00000000 --- a/apps/member/src/types/toast.ts +++ /dev/null @@ -1 +0,0 @@ -export type ToastStateType = 'success' | 'error' | 'warning';