Skip to content
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/graduate/src/pages/admin/all/ui/UserDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Descriptions, Modal, Spin, Table } from 'antd';
import { Header } from '~/shared/components';
import { Container } from '~/shared/components/Container';

import { useStudentDetail } from '~/features/studentDetail';

import type { PeriodData, StageData } from '../types/allManagement';
import {
Expand All @@ -13,6 +12,7 @@ import {
getStatusLabel,
} from '../utils';

import { useStudentDetail } from '~/feature/studentDetail';
import { vars } from '~/vars.css';

interface UserDetailModalProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { KEYS, ROUTE } from '~/shared/constants';
import { useToast, useUpdateGraduationUsersBatchApprove } from '~/shared/hooks';
import { queryClient } from '~/shared/utils';

import { useStudentDetail } from '~/features/studentDetail';

import FilePreviewContent from './FilePreviewContent';
import FilePreviewToolbar from './FilePreviewToolbar';
import { getSubmissionTypeIndex } from '../../schedule/constant';
import { useFile } from '../hooks';
import * as style from '../styles/PreviewPage.css';

import { useStudentDetail } from '~/feature/studentDetail';

export default function FilePreviewPage() {
const navigate = useNavigate();
Expand All @@ -21,12 +21,7 @@ export default function FilePreviewPage() {
from: '/_afterLogin/file-preview',
});

const {
data: fileData,
isPending,
error,
refetch,
} = useFile(fileId, type);
const { data: fileData, isPending, error, refetch } = useFile(fileId, type);

const { data: studentDetail } = useStudentDetail(
fileData?.graduationUserid ?? 0,
Expand Down
1 change: 0 additions & 1 deletion apps/graduate/src/pages/admin/notice/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './useCreateNotice';
export * from './useUpdateNotice';
export * from './useDeleteNotice';
export * from './useToggleNoticePinned';
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export function useCreateNotice() {
const queryClient = useQueryClient();

return useMutation({
mutationFn: (data: CreateNoticeRequest) => createNotice(data),
mutationFn: ({ fileId, ...data }: CreateNoticeRequest) =>
createNotice(data, fileId),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: [KEYS.NOTICE, 'list'] });
},
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ export default function NoticeAdminCreatePage({
name: 'file',
fileList: fileList,
maxCount: 1,
beforeUpload: file => {
toast.info(`${file.name} 파일이 선택되었습니다.`);
return false;
},
customRequest: async ({ file, onSuccess, onError }) => {
try {
const response = await uploadNoticeFile(file as File);
Expand Down Expand Up @@ -109,6 +105,7 @@ export default function NoticeAdminCreatePage({
title: data.title,
content: data.content,
isPinned: data.isPinned,
category: data.category,
fileId: uploadedFileId,
},
{
Expand Down
32 changes: 19 additions & 13 deletions apps/graduate/src/shared/api/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ interface GetRequestConfig<TParams = unknown> extends BaseRequestConfig {
responseType?: AxiosRequestConfig['responseType'];
}

interface MutationRequestConfig<TData = unknown> extends BaseRequestConfig {
interface MutationRequestConfig<TData = unknown, TParams = unknown>
extends BaseRequestConfig {
data?: TData;
params?: TParams;
}

interface DeleteRequestConfig<TData = unknown> extends BaseRequestConfig {
Expand Down Expand Up @@ -235,17 +237,18 @@ function createHttpMethods(instance: AxiosInstance) {
}
},

async post<TResponse = unknown, TData = unknown>(
config: MutationRequestConfig<TData>,
async post<TResponse = unknown, TData = unknown, TParams = unknown>(
config: MutationRequestConfig<TData, TParams>,
): Promise<AxiosResponse<TResponse>> {
const { request, data, headers } = config;
const { request, data, headers, params } = config;
try {
const response = await instance.post<
TResponse,
AxiosResponse<TResponse>,
TData
>(request, data, {
headers,
params,
});
return response;
} catch (error: unknown) {
Expand Down Expand Up @@ -289,17 +292,18 @@ function createHttpMethods(instance: AxiosInstance) {
}
},

async patch<TResponse = unknown, TData = unknown>(
config: MutationRequestConfig<TData>,
async patch<TResponse = unknown, TData = unknown, TParams = unknown>(
config: MutationRequestConfig<TData, TParams>,
): Promise<AxiosResponse<TResponse>> {
const { request, data, headers } = config;
const { request, data, headers, params } = config;
try {
const response = await instance.patch<
TResponse,
AxiosResponse<TResponse>,
TData
>(request, data, {
headers,
params,
});
return response;
} catch (error: unknown) {
Expand Down Expand Up @@ -330,18 +334,19 @@ async function get<TResponse = unknown, TParams = unknown>(
}
}

async function post<TResponse = unknown, TData = unknown>(
config: MutationRequestConfig<TData>,
async function post<TResponse = unknown, TData = unknown, TParams = unknown>(
config: MutationRequestConfig<TData, TParams>,
): Promise<AxiosResponse<TResponse>> {
const instance = selectInstanceByRequest(config.request);
const { request, data, headers } = config;
const { request, data, headers, params } = config;
try {
const response = await instance.post<
TResponse,
AxiosResponse<TResponse>,
TData
>(request, data, {
headers,
params,
});
return response;
} catch (error: unknown) {
Expand All @@ -368,18 +373,19 @@ async function del<TResponse = unknown, TData = unknown>(
}
}

async function patch<TResponse = unknown, TData = unknown>(
config: MutationRequestConfig<TData>,
async function patch<TResponse = unknown, TData = unknown, TParams = unknown>(
config: MutationRequestConfig<TData, TParams>,
): Promise<AxiosResponse<TResponse>> {
const instance = selectInstanceByRequest(config.request);
const { request, data, headers } = config;
const { request, data, headers, params } = config;
try {
const response = await instance.patch<
TResponse,
AxiosResponse<TResponse>,
TData
>(request, data, {
headers,
params,
});
return response;
} catch (error: unknown) {
Expand Down
3 changes: 1 addition & 2 deletions apps/graduate/src/shared/api/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ export async function uploadNoticeFile(
formData.append('file', file);

return post<NoticeFileIdResponse>({
request: '/api/v1/admin/files/post',
request: END_POINT.ADMIN.NOTICE_FILE_UPLOAD,
data: formData,
headers: { 'Content-Type': 'multipart/form-data' },
});
}

Expand Down
14 changes: 10 additions & 4 deletions apps/graduate/src/shared/api/notice.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AxiosResponse } from 'axios';

import { post, patch, del, get } from '~/shared/api';
import { post, patch, get } from '~/shared/api';
import { END_POINT } from '~/shared/constants';
import type {
NoticeApiResponse,
Expand Down Expand Up @@ -29,11 +29,17 @@ export interface NoticeListResponse {
}

export async function createNotice(
data: CreateNoticeRequest,
data: Omit<CreateNoticeRequest, 'fileId'>,
fileId?: number,
): Promise<AxiosResponse<NoticeApiResponse>> {
return post<NoticeApiResponse, CreateNoticeRequest>({
return post<
NoticeApiResponse,
Omit<CreateNoticeRequest, 'fileId'>,
{ fileId: number }
>({
request: END_POINT.ADMIN.NOTICE_CREATE,
data,
params: fileId ? { fileId } : undefined,
});
}

Expand All @@ -50,7 +56,7 @@ export async function updateNotice(
export async function deleteNotice(
noticeId: number,
): Promise<AxiosResponse<void>> {
return del<void>({
return patch<void>({
request: END_POINT.ADMIN.NOTICE_DELETE(noticeId),
});
}
Expand Down
4 changes: 3 additions & 1 deletion apps/graduate/src/shared/constants/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export const END_POINT = {
`/api/v1/admin/schedules/type/${submissionType}/content`,
NOTICE_CREATE: '/api/v1/admin/posts',
NOTICE_UPDATE: (noticeId: number) => `/api/v1/admin/posts/${noticeId}`,
NOTICE_DELETE: (noticeId: number) => `/api/v1/admin/posts/${noticeId}`,
NOTICE_DELETE: (noticeId: number) =>
`/api/v1/admin/posts/${noticeId}/delete`,
NOTICE_FILE_UPLOAD: '/api/v1/admin/files/post',
NOTICE_TOGGLE_PINNED: (noticeId: number) =>
`/api/v1/admin/posts/${noticeId}/pinned`,
CERTIFICATE_FILE: (certificateId: number) =>
Expand Down
1 change: 1 addition & 0 deletions apps/graduate/src/shared/types/notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface UpdateNoticeRequest {
title: string;
content: string;
isPinned: boolean;
category: 'GRADUATION';
fileId?: number;
}

Expand Down
Loading