Skip to content

Commit

Permalink
refactor(member): 불필요한 타입 제거 (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
gwansikk committed Sep 21, 2024
1 parent b6cf59d commit 9c41efb
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 77 deletions.
11 changes: 8 additions & 3 deletions apps/member/src/api/accuse.ts
Original file line number Diff line number Diff line change
@@ -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<AccusesType, BaseResponse<number>>({
export const postAccuses = async (body: Accuses) => {
const { data } = await server.post<Accuses, BaseResponse<number>>({
url: END_POINT.ACCUSES,
body,
});
Expand Down
13 changes: 12 additions & 1 deletion apps/member/src/api/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
* 블로그 포스트 조회
*/
Expand Down
9 changes: 7 additions & 2 deletions apps/member/src/api/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResponsePagination<NotificationItem>>({
const { data } = await server.get<ResponsePagination<Notification>>({
url: createPagination(END_POINT.MY_NOTIFICATION, params),
});

Expand Down
14 changes: 12 additions & 2 deletions apps/member/src/api/recruitment.ts
Original file line number Diff line number Diff line change
@@ -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<BaseResponse<RecruitmentType[]>>({
const { data } = await server.get<BaseResponse<Recruitment[]>>({
url: END_POINT.RECRUITMENT,
});

Expand Down
10 changes: 4 additions & 6 deletions apps/member/src/components/common/Toast/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: <ApprovalColor />,
error: <CancelColor />,
warning: <HighPriorityColor />,
Expand Down Expand Up @@ -58,7 +56,7 @@ const Toast = ({ id, state, message }: ToastProps) => {
)}
onClick={handleClick}
>
<div>{stateIcon[state]}</div>
<div>{STATE_ICON[state]}</div>
<p className="break-keep text-sm font-semibold text-white">{message}</p>
</div>
);
Expand Down
4 changes: 0 additions & 4 deletions apps/member/src/constants/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ type Options<N = string, V = string> = {
value: V;
};

// type SelectOptions<N = string, V = string> = {
// [key: string]: Options<N, V>[];
// };

export const SELECT_DEFAULT_OPTION = 'none';

export const SELECT_OPTIONS = {
Expand Down
File renamed without changes.
12 changes: 8 additions & 4 deletions apps/member/src/hooks/common/useToast.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion apps/member/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions apps/member/src/pages/SupportPage/components/RequestSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -70,7 +71,7 @@ const TABS_OPTIONS = [
interface RequestFormProps {
isPending: boolean;
isSuccess: boolean;
onSubmit: (data: SupportRequestDataType) => void;
onSubmit: (data: SupportRequestData) => void;
}

export function RequestForm({
Expand Down
14 changes: 10 additions & 4 deletions apps/member/src/pages/SupportPage/hooks/useSupportRequestForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<SupportRequestDataType>(INIT_FORM_DATA);
const [formData, setFormData] = useState<SupportRequestData>(INIT_FORM_DATA);
const [checkList, setCheckList] = useState<boolean[]>(INIT_CHECK_LIST);

const handleInputChange = useCallback(
Expand Down
4 changes: 2 additions & 2 deletions apps/member/src/store/toast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 0 additions & 5 deletions apps/member/src/types/accuses.ts

This file was deleted.

11 changes: 0 additions & 11 deletions apps/member/src/types/blog.ts

This file was deleted.

5 changes: 0 additions & 5 deletions apps/member/src/types/notification.ts

This file was deleted.

11 changes: 0 additions & 11 deletions apps/member/src/types/recruitment.ts

This file was deleted.

10 changes: 0 additions & 10 deletions apps/member/src/types/support.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/member/src/types/toast.ts

This file was deleted.

0 comments on commit 9c41efb

Please sign in to comment.