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

파일 명 받아오기 #99

Merged
merged 5 commits into from
Aug 16, 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
16 changes: 2 additions & 14 deletions src/features/content/model/useDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,24 @@ const useDetail = () => {
useGetCampusNoticeDetail(id);
if (isSuccessGeneral) {
return generalData;
} else {
router.push('/404');
}
} else if (organization === 'studentCouncil') {
const { data: studentCouncilData, isSuccess: isSuccessStudentCouncil } =
useGetNoticeDetail(id);
if (isSuccessStudentCouncil) {
return studentCouncilData;
} else {
router.push('/404');
}
} else if (organization === 'college') {
const { data: collegeData, isSuccess: isSuccessCollege } =
useGetNoticeDetail(id);
if (isSuccessCollege) {
return collegeData;
} else {
router.push('/404');
}
} else if (organization === 'department') {
const { data: departmentData, isSuccess: isSuccessDepartment } =
useGetNoticeDetail(id);
if (isSuccessDepartment) {
return departmentData;
} else {
router.push('/404');
}
}
};
Expand All @@ -51,25 +43,21 @@ const useDetail = () => {
useGetEventDetail(id);
if (isSuccessStudentCouncil) {
return studentCouncilData;
} else {
router.push('/404');
}
} else if (organization === 'college') {
const { data: collegeData, isSuccess: isSuccessCollege } =
useGetEventDetail(id);
if (isSuccessCollege) {
return collegeData;
} else {
router.push('/404');
}
} else if (organization === 'department') {
const { data: departmentData, isSuccess: isSuccessDepartment } =
useGetEventDetail(id);
if (isSuccessDepartment) {
return departmentData;
} else {
router.push('/404');
}
} else {
throw new Error('Invalid organization type');
}
};
return { returnNoticeDetailItem, returnEventDetailItem };
Expand Down
12 changes: 6 additions & 6 deletions src/features/content/ui/CommonDetailComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ const CommonDetailComponent = ({
</ReactMarkdown>
</div>
<hr />
{data.urlList.length > 0 &&
data.urlList.map((_, index) => (
{data.fileInfo.length > 0 &&
data.fileInfo.map((data, index) => (
<a
className="flex flex-row items-center gap-1 pt-2 text-sm"
href={data.urlList[0]}
download="다운로드 되는 파일명"
href={data.url}
download
key={index}
>
<TbDownload size={16} />
첨부파일 다운로드
<TbDownload size={16} color="#7B7B7B" />
{data.fileName}
</a>
))}
<div className="flex justify-end">
Expand Down
29 changes: 26 additions & 3 deletions src/features/contentList/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/**학과, 대학 get */
export interface GetCollegeResData {
data: Array<{
val: number;
Expand All @@ -12,16 +13,34 @@ export interface GetDepartmentResData {
}>;
}

/** 상세조회 관련 file */
interface DetailFileInfo {
fileName: string;
url: string;
}

/** 전체조회 관련 file */
interface ListFileInfo {
fileName: string;
url: string;
createAt: string;
updateAt: string;
id: number;
fileType: string;
}

/** 공지사항 content */
export interface NoticeContent {
createAt: string;
updateAt: string;
id: number;
title: string;
content: string;
affiliationId: number;
files: string[];
files: ListFileInfo[];
}

/**공지사항 전체 조회 */
export interface GetNoticeResData {
totalPages: number;
totalElements: number;
Expand Down Expand Up @@ -51,16 +70,18 @@ export interface GetNoticeResData {
empty: boolean;
}

/**공지사항 detail */
export interface GetNoticeDetailResData {
noticeId: number;
title: string;
content: string;
type: string;
urlList: string[];
fileInfo: DetailFileInfo[];
createAt: string;
updateAt: string;
}

/**이벤트 content */
export interface EventContent {
createAt: string;
updateAt: string;
Expand All @@ -73,6 +94,7 @@ export interface EventContent {
endDateTime: string;
}

/** 이벤트 전체 조회 */
export interface GetEventResData {
totalPages: number;
totalElements: number;
Expand Down Expand Up @@ -102,12 +124,13 @@ export interface GetEventResData {
empty: boolean;
}

/** 이벤트 detail */
export interface GetEventDetailResData {
eventId: number;
title: string;
content: string;
type: string;
urlList: string[];
fileInfo: DetailFileInfo[];
createAt: string;
updateAt: string;
}
Expand Down
Loading