From c3815cb4ca16a2921197ef629e9a33c82e69c5f7 Mon Sep 17 00:00:00 2001 From: anjaemin Date: Wed, 16 Nov 2022 20:20:56 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20fileid=20post=20=EC=B9=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index 44b352b..210b159 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -45,7 +45,7 @@ export const App: React.FC = () => ( } > } /> - } /> + } /> } /> } /> } /> From 1bd002d39da832ec46af400125c1ba990797bbbe Mon Sep 17 00:00:00 2001 From: anjaemin Date: Wed, 16 Nov 2022 20:22:19 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20url=EC=97=90=EC=84=9C=20fileid?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=99=80=EC=84=9C=20=EC=82=AC=EC=9A=A9(post?= =?UTF-8?q?=20page=EA=B5=AC=ED=98=84)=20=EB=B0=8F=20err=20=ED=95=B8?= =?UTF-8?q?=EB=93=A4=EB=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/download/index.tsx | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/pages/download/index.tsx b/src/pages/download/index.tsx index 99fcb3c..33b93a4 100644 --- a/src/pages/download/index.tsx +++ b/src/pages/download/index.tsx @@ -2,6 +2,7 @@ import axios from 'axios'; import React, { useEffect, useState } from 'react'; import { useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; +import { useParams } from 'react-router-dom'; import { toast } from 'react-toastify'; import { Button, FileBox, SkeletonUI } from '../../components'; @@ -14,6 +15,7 @@ export const DownloadPage: React.FC = () => { const navigate = useNavigate(); const downloadFileProps: any = useSelector((state: RootState) => state.DownloadFileProps); const [loading, setLoading] = useState(true); + const { fileid } = useParams<{ fileid: string }>(); const [fileProps, setFileProps] = useState({ filename: '', // fileId: '', @@ -34,7 +36,7 @@ export const DownloadPage: React.FC = () => { const getFileProps = async () => { await axios({ method: 'get', - url: `${process.env.REACT_APP_BACKEND_BASEURL}/file/${downloadFileProps.fileId}${ + url: `${process.env.REACT_APP_BACKEND_BASEURL}/file/${fileid}${ downloadFileProps.isEncrypted ? `?token=${downloadFileProps.token}` : '' }`, }) @@ -51,20 +53,22 @@ export const DownloadPage: React.FC = () => { }); }) .catch((err) => { - navigate(-1); - toast.error(`error 문의해주세요. ${err.response.status}`, { - autoClose: 1000, - position: toast.POSITION.BOTTOM_RIGHT, - }); - console.log(err); + navigate('/'); + if (err.response.status != 401) { + toast.error(`error 문의해주세요. ${err.response.status}`, { + autoClose: 1000, + position: toast.POSITION.BOTTOM_RIGHT, + }); + } else { + toast.error(`잘못된 링크입니다`, { + autoClose: 1000, + position: toast.POSITION.BOTTOM_RIGHT, + }); + } }); }; - if (downloadFileProps.fileId != null) { - getFileProps(); - } else { - navigate('/'); - } - }, [downloadFileProps, navigate]); + getFileProps(); + }, [downloadFileProps, navigate, fileid]); return ( {!loading ? ( From 13168e2fc3339acde6235fa04c6d896b99b60dfa Mon Sep 17 00:00:00 2001 From: anjaemin Date: Wed, 16 Nov 2022 20:23:16 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20SetDownloadFileProps=20filename=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C,=20post=20page=20=EC=A0=81=EC=9A=A9=EC=97=90?= =?UTF-8?q?=20=EB=94=B0=EB=A5=B8=20=EB=A7=81=ED=81=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/filelist/index.tsx | 3 +-- src/pages/main/index.tsx | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/filelist/index.tsx b/src/pages/filelist/index.tsx index bc8d713..3feb545 100644 --- a/src/pages/filelist/index.tsx +++ b/src/pages/filelist/index.tsx @@ -62,12 +62,11 @@ export const FileListPage: React.FC = () => { navigate('/checkpw'); } else { SetDownloadFileProps({ - filename: item.filename, fileId: item.fileId, isEncrypted: item.isEncrypted, token: null, }); - navigate('/download'); + navigate(`/download/${item.fileId}`); } }} /> diff --git a/src/pages/main/index.tsx b/src/pages/main/index.tsx index 2cb689c..2a28c77 100644 --- a/src/pages/main/index.tsx +++ b/src/pages/main/index.tsx @@ -69,13 +69,12 @@ export const MainPage: React.FC = () => { position: toast.POSITION.BOTTOM_RIGHT, }); SetDownloadFileProps({ - filename: res.data.filename, fileId: res.data.fileId, token: res.data.isEncrypted ? res.data.token : null, isEncrypted: res.data.isEncrypted, //추후에 기한,다운로드횟수 추가예정 }); - navigate('/download'); + navigate(`/download/${res.data.fileId}`); }) .catch((err) => { console.log(err);