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

공지사항 파일 nullabled 처리 #84

Merged
merged 1 commit into from
Nov 14, 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
1 change: 1 addition & 0 deletions src/Apis/Notices/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const useNoticeListData = () => {

useEffect(() => {
fetchNoticeList();

}, [fetchNoticeList]);

return { notices };
Expand Down
2 changes: 1 addition & 1 deletion src/Apis/Notices/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AttachmentType } from "./response";
export interface NoticeWrite {
title: string;
content: string;
attachments: AttachmentRequest[];
attachments?: AttachmentRequest[];
}

export interface NoticeEdit {
Expand Down
2 changes: 1 addition & 1 deletion src/Apis/Notices/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface NoticeDetailResponse {
title: string;
content: string;
created_at: string;
attachments: AttachmentResponse[];
attachments?: AttachmentResponse[];
}

export type AttachmentType =
Expand Down
10 changes: 8 additions & 2 deletions src/Pages/NoticePage/NoticeWritePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function NoticeWritePage() {
const navigate = useNavigate();

const { mutate: writeNotice } = useNoticeWriteData();

const { mutate: getPresignedUrl, data } = usePresignedUrl();

useEffect(() => {
Expand Down Expand Up @@ -91,6 +90,13 @@ export function NoticeWritePage() {
const handleNoticeSubmit = () => {
if (attachments.length > 0) {
getPresignedUrl(attachments);
} else {
writeNotice({
title,
content,
attachments: [{url: '', type: 'FILE'}],
});
navigate('/Notice')
}
};

Expand Down Expand Up @@ -136,7 +142,7 @@ export function NoticeWritePage() {
<_.FileWrap>
<_.Text>첨부파일</_.Text>
<_.AddFileWrapper>
{attachments.map(
{attachments?.map(
(file: File, index: number) => (
<_.AddFile key={index}>
{file.name}
Expand Down
Loading