diff --git a/apps/as/src/pages/esntl-atch-file-mng/ui/esntl-atch-file-form-dialog.tsx b/apps/as/src/pages/esntl-atch-file-mng/ui/esntl-atch-file-form-dialog.tsx index 710d6c93d..c7c63ffed 100644 --- a/apps/as/src/pages/esntl-atch-file-mng/ui/esntl-atch-file-form-dialog.tsx +++ b/apps/as/src/pages/esntl-atch-file-mng/ui/esntl-atch-file-form-dialog.tsx @@ -5,7 +5,7 @@ import { useForm } from "react-hook-form"; import { getDefaultFileKey, useTus } from "@/shared/lib"; import { AttachmentFileField } from "@/shared/ui"; -import { attachService } from "@/entities/attach"; +import { attachService, useDownloadAttachmentByAtflId } from "@/entities/attach"; import { CodeSelect } from "@/entities/code"; import type { EsntlAtchFileMng } from "@/entities/esntl"; import { @@ -61,6 +61,7 @@ function EsntlAtchFileFormDialog({ const formId = useId(); const atchFileGroupIdRef = useRef(""); const [uploadedFiles, setUploadedFiles] = useState([]); + const { mutate: downloadByAtflId } = useDownloadAttachmentByAtflId(); const { register, handleSubmit, reset, setValue, watch } = useForm({ defaultValues: { @@ -219,6 +220,9 @@ function EsntlAtchFileFormDialog({ files={uploadedFiles.map((item) => ({ fileKey: item.fileKey, fileName: item.fileName, + onDownload: item.atflId + ? () => downloadByAtflId(item.atflId!) + : undefined, }))} inputId={fileInputId} isUploadingByKey={isUploading} diff --git a/apps/as/src/pages/fnrs-cnsltn/ui/components/floating-action-buttons.tsx b/apps/as/src/pages/fnrs-cnsltn/ui/components/floating-action-buttons.tsx index 2c32522cc..5d6d58371 100644 --- a/apps/as/src/pages/fnrs-cnsltn/ui/components/floating-action-buttons.tsx +++ b/apps/as/src/pages/fnrs-cnsltn/ui/components/floating-action-buttons.tsx @@ -597,7 +597,7 @@ function FloatingActionButtons({ )} {shouldShowButton(FNRS_CNSLTN_VIEW_BUTTON_ACTION.sncnAprv) && ( - )} diff --git a/apps/as/src/pages/fnrs-cnsltn/ui/components/pwrk-cnsltn-doc-mng-dialog.tsx b/apps/as/src/pages/fnrs-cnsltn/ui/components/pwrk-cnsltn-doc-mng-dialog.tsx index a740f7356..97a7a9e9f 100644 --- a/apps/as/src/pages/fnrs-cnsltn/ui/components/pwrk-cnsltn-doc-mng-dialog.tsx +++ b/apps/as/src/pages/fnrs-cnsltn/ui/components/pwrk-cnsltn-doc-mng-dialog.tsx @@ -8,7 +8,7 @@ import { PanelRightClose, PanelRightOpen } from "lucide-react"; import { getDefaultFileKey, useAlertStore, useTus } from "@/shared/lib"; import { AttachmentFileField } from "@/shared/ui"; -import { attachService, parseFilenameFromResponse } from "@/entities/attach"; +import { attachService, parseFilenameFromResponse, useDownloadAttachmentByAtflId } from "@/entities/attach"; import { pwrkCnsltnDocCrtRsltSaveRequestSchema, pwrkCnsltnDocCrtRsltService, @@ -78,6 +78,7 @@ function PwrkCnsltnDocMngDialog({ const [atchFileGroupId, setAtchFileGroupId] = useState(""); const [uploadedFiles, setUploadedFiles] = useState([]); const [isPjtcoAjmtTableOpen, setIsPjtcoAjmtTableOpen] = useState(false); + const { mutate: downloadByAtflId } = useDownloadAttachmentByAtflId(); const { data: pwrkCnsltnData, @@ -344,6 +345,9 @@ function PwrkCnsltnDocMngDialog({ files={uploadedFiles.map((item) => ({ fileKey: item.fileKey, fileName: item.fileName, + onDownload: item.atflId + ? () => downloadByAtflId(item.atflId!) + : undefined, }))} inputId="pwrk-cnsltn-doc-atch-file-input" isUploadingByKey={isUploading} diff --git a/apps/as/src/pages/fnrs-cnsltn/ui/fnrs-form-page.tsx b/apps/as/src/pages/fnrs-cnsltn/ui/fnrs-form-page.tsx index 632c51e3b..cac88ea86 100644 --- a/apps/as/src/pages/fnrs-cnsltn/ui/fnrs-form-page.tsx +++ b/apps/as/src/pages/fnrs-cnsltn/ui/fnrs-form-page.tsx @@ -332,24 +332,26 @@ function FnrsFormPage({ mode, initialData, createDefaults }: FnrsFormPageProps) )} ) : ( - + <> + {fnrsCnsltnDocNo ? ( + + ) : null} + + )} - {isSplmntPrgrsStts && fnrsCnsltnDocNo ? ( - - ) : null} diff --git a/apps/as/src/pages/fnrs-cnsltn/ui/sections/tech-review-opinion-section.tsx b/apps/as/src/pages/fnrs-cnsltn/ui/sections/tech-review-opinion-section.tsx index a4c41d527..b00dfce22 100644 --- a/apps/as/src/pages/fnrs-cnsltn/ui/sections/tech-review-opinion-section.tsx +++ b/apps/as/src/pages/fnrs-cnsltn/ui/sections/tech-review-opinion-section.tsx @@ -5,7 +5,11 @@ import { forwardRef, useEffect, useImperativeHandle, useState } from "react"; import { dayjs, getDefaultFileKey, useTus } from "@/shared/lib"; import { AttachmentFileField, SectionCollapsible } from "@/shared/ui"; import { Field, FieldLabel, FieldSet } from "@/shared/ui/field"; -import { AttachmentDownloadLink, attachService } from "@/entities/attach"; +import { + AttachmentDownloadLink, + attachService, + useDownloadAttachmentByAtflId, +} from "@/entities/attach"; import type { FnrsCnsltnRvwOpnnResponseDto } from "@/entities/fnrs-cnsltn"; import { RadioGroup, @@ -79,6 +83,7 @@ const TechReviewOpinionSection = forwardRef< opnrSeComCd: editableReviewStep ?? "", }); const [uploadedFile, setUploadedFile] = useState(null); + const { mutate: downloadByAtflId } = useDownloadAttachmentByAtflId(); useEffect(() => { setFormData((prev) => ({ @@ -243,7 +248,15 @@ const TechReviewOpinionSection = forwardRef< downloadByAtflId(uploadedFile.atflId!) + : undefined, + }, + ] : [] } inputId={`rvw-opnn-${reviewStep}-file-input`} diff --git a/apps/as/src/shared/ui/attachment-file-field.tsx b/apps/as/src/shared/ui/attachment-file-field.tsx index 6867a8323..8eac0dce6 100644 --- a/apps/as/src/shared/ui/attachment-file-field.tsx +++ b/apps/as/src/shared/ui/attachment-file-field.tsx @@ -6,6 +6,7 @@ import { UploadedFileChip } from "./uploaded-file-chip"; interface AttachmentFileFieldItem { fileKey: string; fileName: string; + onDownload?: () => void; } interface AttachmentFileFieldProps { @@ -41,6 +42,7 @@ function AttachmentFileField({ fileName={file.fileName} isUploading={isUploadingByKey[file.fileKey] ?? false} onRemove={onRemove ? () => onRemove(index) : undefined} + onDownload={file.onDownload} /> ))} diff --git a/apps/as/src/shared/ui/uploaded-file-chip.tsx b/apps/as/src/shared/ui/uploaded-file-chip.tsx index 82be5d581..2fb4b437a 100644 --- a/apps/as/src/shared/ui/uploaded-file-chip.tsx +++ b/apps/as/src/shared/ui/uploaded-file-chip.tsx @@ -8,15 +8,36 @@ interface UploadedFileChipProps { fileName: string; isUploading?: boolean; onRemove?: () => void; + onDownload?: () => void; } -function UploadedFileChip({ fileName, isUploading = false, onRemove }: UploadedFileChipProps) { +function UploadedFileChip({ + fileName, + isUploading = false, + onRemove, + onDownload, +}: UploadedFileChipProps) { + const canDownload = Boolean(onDownload) && !isUploading; + return (
- - {fileName} - + {canDownload ? ( + + ) : ( + + {fileName} + + )} {onRemove ? (
diff --git a/apps/as/src/widgets/pbadms-sprt/ui/splmnt-dmnd-dialog.tsx b/apps/as/src/widgets/pbadms-sprt/ui/splmnt-dmnd-dialog.tsx index 2e225a286..8e1facf38 100644 --- a/apps/as/src/widgets/pbadms-sprt/ui/splmnt-dmnd-dialog.tsx +++ b/apps/as/src/widgets/pbadms-sprt/ui/splmnt-dmnd-dialog.tsx @@ -4,7 +4,7 @@ import { useEffect, useId, useState } from "react"; import { getDefaultFileKey, useTus } from "@/shared/lib"; import { AttachmentFileField } from "@/shared/ui"; -import { attachService } from "@/entities/attach"; +import { attachService, useDownloadAttachmentByAtflId } from "@/entities/attach"; import { CodeSelect } from "@/entities/code"; import { Button, @@ -96,6 +96,7 @@ function SplmntDmndDialog({ }: SplmntDmndDialogProps) { const formId = useId(); const [rows, setRows] = useState([createEmptyRow()]); + const { mutate: downloadByAtflId } = useDownloadAttachmentByAtflId(); const { uploadFileAsync, isUploading, uploads } = useTus({ onSuccess: (atflCd, atflId, _file, fileKey) => { @@ -289,6 +290,9 @@ function SplmntDmndDialog({ files={row.uploadedFiles.map((file) => ({ fileKey: file.fileKey, fileName: file.fileName, + onDownload: file.atflId + ? () => downloadByAtflId(file.atflId!) + : undefined, }))} inputId={fileInputId} isUploadingByKey={isUploading} diff --git a/apps/as/src/widgets/pbadms-sprt/ui/splmnt-dmnd-form-section.tsx b/apps/as/src/widgets/pbadms-sprt/ui/splmnt-dmnd-form-section.tsx index 348cfe52e..8fdbec031 100644 --- a/apps/as/src/widgets/pbadms-sprt/ui/splmnt-dmnd-form-section.tsx +++ b/apps/as/src/widgets/pbadms-sprt/ui/splmnt-dmnd-form-section.tsx @@ -5,7 +5,7 @@ import { Controller, useFormContext, useWatch } from "react-hook-form"; import { dayjs, getDefaultFileKey, useTus } from "@/shared/lib"; import { AttachmentFileField, SectionCollapsible } from "@/shared/ui"; -import { AttachmentDownloadLink, attachService } from "@/entities/attach"; +import { AttachmentDownloadLink, attachService, useDownloadAttachmentByAtflId } from "@/entities/attach"; import { Badge, Table, @@ -73,6 +73,7 @@ function SplmntDmndFormSection({ readOnly = false }: SplmntDmndFormSectionProps) const initialFilesMappedRef = useRef(false); const isMountedRef = useRef(true); const atflCdByRowRef = useRef>({}); + const { mutate: downloadByAtflId } = useDownloadAttachmentByAtflId(); const { uploadFileAsync, isUploading, uploads } = useTus({ onSuccess: (atflCd, atflId, _file, fileKey) => { @@ -306,6 +307,9 @@ function SplmntDmndFormSection({ readOnly = false }: SplmntDmndFormSectionProps) files={rowFiles.map((file) => ({ fileKey: file.fileKey, fileName: file.fileName, + onDownload: file.atflId + ? () => downloadByAtflId(file.atflId!) + : undefined, }))} inputId={fileInputId} isUploadingByKey={isUploading}