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

[#74] Feat: 짤 이미지 신고 api 연결 구현 #76

Merged
merged 20 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
04790ca
Feat: 짤 이미지 신고 api 연결 구현
HY219 Feb 28, 2024
ea441fc
Rename: zzal 폴더 내 신고 관련 api 요청 데이터 전송 객체를 report폴더로 이동
HY219 Feb 28, 2024
e267a57
Refactor: mutate 함수 재정의 및 요청 파라미터 축약, 불필요한 로깅 삭제
HY219 Feb 28, 2024
f7ee5c8
Refactor: POST 요청에 대한 응답 타입 삭제 및 비동기 처리 추가
HY219 Feb 28, 2024
fa351b0
Refactor: api 요청 response 타입 명시
HY219 Feb 28, 2024
19ff65f
Rename: 신고하기 버튼을 클릭했을 때 호출되는 함수명 변경
HY219 Feb 28, 2024
a9d9df8
Refactor: api 요청 파라미터를 객체에서 변수 형식으로 변경
HY219 Feb 28, 2024
4bcd28d
Refactor: 추가적인 mutation 옵션을 사용할 수 있도록 나머지 연산자 추가
HY219 Feb 28, 2024
542520b
Refactor: API 요청에서 비동기 처리 제거 및 요청 결과를 직접 반환하도록 수정
HY219 Mar 1, 2024
6c8cb3d
Fix: api 요청 url 수정
HY219 Mar 3, 2024
300e074
Merge branch 'main' into #74/feature/report-zzal-api
HY219 Mar 3, 2024
4067fc1
Refactor: api 커스텀 훅인 usePostReportZzal() 선언문의 위치 상위로 변경
HY219 Mar 5, 2024
0c944a6
Merge branch 'main' of https://github.com/zzalmyu/zzalmyu-frontend in…
HY219 Mar 5, 2024
30938d3
Feat: 짤 이미지 신고 api 성공 시 toast 구현
HY219 Mar 5, 2024
20ed27c
Rename: DeleteReportImage를 DeleteReportZzal로 변경
HY219 Mar 5, 2024
4cca338
Feat: 신고 요청 api 실패 시 에러 코드에 따라 toast 메시지 출력
HY219 Mar 5, 2024
3e7b251
Merge branch 'main' of https://github.com/zzalmyu/zzalmyu-frontend in…
HY219 Mar 5, 2024
0249278
Merge branch 'main' of https://github.com/zzalmyu/zzalmyu-frontend in…
HY219 Mar 6, 2024
7b2619a
Cleanup: 짤 이미지 신고 api 연결 및 해당 TODO 주석 삭제
HY219 Mar 6, 2024
e23c0f6
Fix: 신고 확인 모달에서 신고 버튼 클릭 시 http error code 별 메시지 출력 코드 제거
HY219 Mar 6, 2024
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
10 changes: 10 additions & 0 deletions src/apis/report.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { PostReportZzalRequeust } from "@/types/report.dto";
import http from "./core";

export const postReportZzal = async ({ imageId }: PostReportZzalRequeust) => {
const response = await http.post({
Kim-Jaemin420 marked this conversation as resolved.
Show resolved Hide resolved
url: `/report/${imageId}`,
});

return response;
Kim-Jaemin420 marked this conversation as resolved.
Show resolved Hide resolved
};
hyeonjinan096 marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 11 additions & 1 deletion src/components/ImageDetailModal/ImageMenuBar.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import { useState } from "react";
import { FolderDown, SendHorizontal, Siren, Heart } from "lucide-react";
import usePostReportZzal from "@/hooks/api/zzal/usePostReportZzal";

const ImageMenuBar = () => {
const imageId = 152; // TODO: [2024-02-28] 이미지 상세보기 api 연결 후, 실제 imageId를 가져와야합니다.
const [isLiked, setIsLiked] = useState(false);

const handleClickLike = () => {
choi-ik marked this conversation as resolved.
Show resolved Hide resolved
setIsLiked((prevLiked) => !prevLiked);
};

const reportZzal = usePostReportZzal();

const handleReportZzal = () => {
Kim-Jaemin420 marked this conversation as resolved.
Show resolved Hide resolved
reportZzal({
imageId,
});
Kim-Jaemin420 marked this conversation as resolved.
Show resolved Hide resolved
};

const menuItems = [
{ Icon: FolderDown, name: "다운로드", onClick: () => {} },
{ Icon: Heart, name: "좋아요", onClick: handleClickLike },
{ Icon: SendHorizontal, name: "채팅 전송", onClick: () => {} },
{ Icon: Siren, name: "신고하기", onClick: () => {} },
{ Icon: Siren, name: "신고하기", onClick: handleReportZzal },
];

return (
Expand Down
12 changes: 12 additions & 0 deletions src/hooks/api/zzal/usePostReportZzal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useMutation } from "@tanstack/react-query";
import { postReportZzal } from "@/apis/report";

const usePostReportZzal = () => {
const { mutate: reportZzal } = useMutation({
mutationFn: postReportZzal,
yjc2021 marked this conversation as resolved.
Show resolved Hide resolved
});

return reportZzal;
Kim-Jaemin420 marked this conversation as resolved.
Show resolved Hide resolved
};

export default usePostReportZzal;
Empty file removed src/types/.empty
Empty file.
4 changes: 3 additions & 1 deletion src/types/report.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Report, ReportDetail } from "./report";
import { Report, ReportDetail, ReportZzal } from "./report";

export type GetReportResponse = Report[];
export type GetReportDetailResponse = ReportDetail[];

export type PostReportZzalRequeust = ReportZzal;
4 changes: 4 additions & 0 deletions src/types/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ export interface ReportDetail {
reportUserEmail: string;
tags?: { tagId: number; tagName: string }[];
}

export interface ReportZzal {
imageId: number;
}