Repository navigation
feat: 신고 문서 작성 기능 보완 #96
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
35ce1e8
feat: 신고 문서(PDF) 내려받기 버튼과 AI 요약 표시 컴포넌트 추가 (#95)
ryusuye0n 8e130cf
fix: 신고 화면의 임시 "문서 준비 중" 안내를 PDF 내려받기와 요약 표시로 교체 (#95)
ryusuye0n 11e4ece
fix: 내려받기 직후 파일 주소를 바로 해제해 다운로드가 끊길 수 있는 문제 수정
ryusuye0n b062490
fix: 신고서를 수정하는 중에는 PDF 내려받기 버튼을 비활성화
ryusuye0n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| "use client"; | ||
|
|
||
| import { useMutation } from "@tanstack/react-query"; | ||
| import { toast } from "sonner"; | ||
| import { downloadReportDocument } from "@/entities/report/api"; | ||
| import { useT } from "@/shared/i18n/I18nProvider"; | ||
| import Button, { type ButtonVariant } from "@/shared/ui/Button"; | ||
| import { reportDocumentMessages } from "./reportDocumentMessages"; | ||
|
|
||
| interface ReportDocumentDownloadButtonProps { | ||
| reportId: number; | ||
| variant?: ButtonVariant; | ||
| className?: string; | ||
| disabled?: boolean; | ||
| } | ||
|
|
||
| /** 신고 문서(PDF)는 로그인이 필요한 API라 링크가 아니라 blob으로 받아 저장한다. */ | ||
| export default function ReportDocumentDownloadButton({ | ||
| reportId, | ||
| variant = "outline", | ||
| className = "", | ||
| disabled = false, | ||
| }: ReportDocumentDownloadButtonProps) { | ||
| const t = useT(reportDocumentMessages); | ||
|
|
||
| const downloadMutation = useMutation({ | ||
| mutationFn: () => downloadReportDocument(reportId), | ||
| onSuccess: (blob) => { | ||
| const url = URL.createObjectURL(blob); | ||
| const link = document.createElement("a"); | ||
| link.href = url; | ||
| link.download = `signal-report-${reportId}.pdf`; | ||
| link.click(); | ||
| setTimeout(() => URL.revokeObjectURL(url), 1000); | ||
| }, | ||
| onError: () => { | ||
| toast.error(t.downloadFailed); | ||
| }, | ||
| }); | ||
|
|
||
| return ( | ||
| <Button | ||
| type="button" | ||
| variant={variant} | ||
| className={className} | ||
| disabled={disabled || downloadMutation.isPending} | ||
| onClick={() => downloadMutation.mutate()} | ||
| > | ||
| {downloadMutation.isPending ? t.downloading : t.download} | ||
| </Button> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| "use client"; | ||
|
|
||
| import { useT } from "@/shared/i18n/I18nProvider"; | ||
| import { reportDocumentMessages } from "./reportDocumentMessages"; | ||
|
|
||
| interface ReportSummaryProps { | ||
| summary: string | null | undefined; | ||
| className?: string; | ||
| } | ||
|
|
||
| /** AI가 만든 사건 개요. 요약이 없으면(원문이 짧거나 만들지 못함) 아무것도 그리지 않는다. */ | ||
| export default function ReportSummary({ summary, className = "" }: ReportSummaryProps) { | ||
| const t = useT(reportDocumentMessages); | ||
| if (!summary?.trim()) return null; | ||
|
|
||
| return ( | ||
| <div | ||
| className={`flex flex-col gap-1.5 rounded-lg border border-gray-300 p-3 md:p-4 ${className}`} | ||
| > | ||
| <p className="text-body-2 md:text-body-1 font-semibold text-black">{t.summaryTitle}</p> | ||
| <p className="text-body-2 md:text-body-1 w-full break-words whitespace-pre-wrap text-black"> | ||
| {summary} | ||
| </p> | ||
| <p className="text-small text-gray-650">{t.summaryNotice}</p> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { defineMessages } from "@/shared/i18n/defineMessages"; | ||
|
|
||
| export const reportDocumentMessages = defineMessages( | ||
| { | ||
| download: "신고 문서(PDF) 내려받기", | ||
| downloading: "문서 만드는 중...", | ||
| downloadFailed: "신고 문서를 내려받지 못했어요. 잠시 후 다시 시도해 주세요.", | ||
| summaryTitle: "사건 개요 (AI 요약)", | ||
| summaryNotice: | ||
| "AI가 입력하신 피해 내용을 요약한 것으로 원문과 다를 수 있어요. 제출 전에 꼭 확인해 주세요.", | ||
| }, | ||
| { | ||
| en: { | ||
| download: "Download report (PDF)", | ||
| downloading: "Preparing the file...", | ||
| downloadFailed: "Couldn't download the report. Please try again in a moment.", | ||
| summaryTitle: "Case summary (AI)", | ||
| summaryNotice: | ||
| "AI summarized what you wrote and it may differ from the original. Please check it before submitting.", | ||
| }, | ||
| ja: { | ||
| download: "通報書類(PDF)をダウンロード", | ||
| downloading: "ファイルを作成中...", | ||
| downloadFailed: | ||
| "通報書類をダウンロードできませんでした。しばらくしてからもう一度お試しください。", | ||
| summaryTitle: "事件の概要(AI要約)", | ||
| summaryNotice: | ||
| "入力された被害内容をAIが要約したもので、原文と異なる場合があります。提出前に必ずご確認ください。", | ||
| }, | ||
| zh: { | ||
| download: "下载举报文件(PDF)", | ||
| downloading: "正在生成文件...", | ||
| downloadFailed: "无法下载举报文件。请稍后再试。", | ||
| summaryTitle: "事件概要(AI摘要)", | ||
| summaryNotice: "这是AI对你填写的伤害内容的摘要,可能与原文不同。提交前请务必确认。", | ||
| }, | ||
| }, | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.