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

15 filelist page 개편 및 다운로드 패스워드 확인 #36

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ae8d6da
feat: fix: api res data
ananjaemin Nov 4, 2022
9ea88fa
feat: useDownloaddPageNavigate custom hook
ananjaemin Nov 4, 2022
0daa1ff
feat: button, fix: navigate/미완성
ananjaemin Nov 4, 2022
62ac8a7
fix: api res data
ananjaemin Nov 4, 2022
de99bb0
.
ananjaemin Nov 4, 2022
b0ffe33
Merge pull request #32 from ananjaemin/dev
ananjaemin Nov 4, 2022
f8b328c
feat: fix: api res data
ananjaemin Nov 4, 2022
d9b1052
feat: useDownloaddPageNavigate custom hook
ananjaemin Nov 4, 2022
0ea80d6
feat: button, fix: navigate/미완성
ananjaemin Nov 4, 2022
de32a1b
.
ananjaemin Nov 4, 2022
c938ec8
rebase main
ananjaemin Nov 4, 2022
862b3c4
fix: git
ananjaemin Nov 4, 2022
e76388f
feat: fix: api res data
ananjaemin Nov 4, 2022
c854d33
feat: useDownloaddPageNavigate custom hook
ananjaemin Nov 4, 2022
df2af69
feat: button, fix: navigate/미완성
ananjaemin Nov 4, 2022
8d168e1
.
ananjaemin Nov 4, 2022
5c5caaf
fix: git
ananjaemin Nov 4, 2022
e35b93d
.
ananjaemin Nov 4, 2022
3db8682
.
ananjaemin Nov 4, 2022
eeaa120
fix: test코드 삭제
ananjaemin Nov 6, 2022
8faf2f8
feat: Lock Icon추가 및 isEncrypted 인수 추가
ananjaemin Nov 8, 2022
68ff073
feat: FileBox component 추가
ananjaemin Nov 8, 2022
81e9efe
feat: isEncrypted handle, fix: redux 이름
ananjaemin Nov 9, 2022
feebcc7
fix: token
ananjaemin Nov 9, 2022
3a5803a
feat: checkpw page (미완성)
ananjaemin Nov 9, 2022
0c6ac1d
feat: token handle 추가, fix: redux 이름, 함수
ananjaemin Nov 9, 2022
014e01b
Success page삭제, CheckpasswordPage 추가
ananjaemin Nov 9, 2022
b74fa08
feat: lockicon
ananjaemin Nov 9, 2022
8a65489
feat: token 추가 및 isEncrypted핸들링 추가
ananjaemin Nov 9, 2022
01b55d7
feat:CheckPasswordFileProps, fix: successFileProps 삭제
ananjaemin Nov 9, 2022
7cbfa41
fix: BaseURL local(개발용 서버)로 번경
ananjaemin Nov 9, 2022
1f05c02
fix: success page 삭제
ananjaemin Nov 9, 2022
8b46546
Merge branch '15-filelist-page-개편-및-다운로드-패스워드-확인' into 24-download-pa…
ananjaemin Nov 9, 2022
50f7983
Merge pull request #34 from ananjaemin/24-download-page-구조-개편-및-합치기
ananjaemin Nov 9, 2022
8f1ce83
fix: util name
ananjaemin Nov 9, 2022
6f337e8
fix: utils 위치 변경 bugfix
ananjaemin Nov 9, 2022
fde0993
feat: password check 기능 추가
ananjaemin Nov 9, 2022
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
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
PUBLIC_URL=/tempfiles-frontend
REACT_APP_BACKEND_BASEURL= https://tfb.minpeter.cf
REACT_APP_BACKEND_BASEURL=http://localhost:5000
# dev - http://localhost:5000
# main - https://tfb.minpeter.cf
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import 'react-toastify/dist/ReactToastify.css';
import { Navbar } from './components';
import {
MainPage,
SuccessPage,
DownloadPage,
DeletePage,
FileListPage,
ApiPage,
NotFoundPage,
CheckPasswordPage,
} from './pages';
import { store } from './state/store';

Expand Down Expand Up @@ -45,11 +45,11 @@ export const App: React.FC = () => (
}
>
<Route index element={<MainPage />} />
<Route path="/success" element={<SuccessPage />} />
<Route path="/download" element={<DownloadPage />} />
<Route path="/delete" element={<DeletePage />} />
<Route path="/filelist" element={<FileListPage />} />
<Route path="/api/*" element={<ApiPage />} />
<Route path="/checkpw" element={<CheckPasswordPage />} />
<Route path="*" element={<NotFoundPage />} />
</Route>
</Routes>
Expand Down
22 changes: 22 additions & 0 deletions src/assets/lockIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/components/common/FileBox/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import styled from '@emotion/styled';

export const FileBox = styled.div`
background-color: var(--color-backgorund-filelistbox);
color: var(--color-text-tertiary);
border-radius: 10px;
padding: 1.2rem 1.2rem 1.2rem 1.2rem;
display: flex;
flex-direction: row;
align-items: center;
font-size: 2.2rem;
`;
9 changes: 7 additions & 2 deletions src/components/common/FileFind/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ type FileFindProps = {

export const FileFind: React.FC<FileFindProps> = ({ handleChangeFile, fileProps }) => (
<S.FileFindContainer>
{fileProps.name != '' && fileProps.size != '' && fileProps.fileType != '' ? (
{fileProps.filename != '' && fileProps.size != '' && fileProps.fileType != '' ? (
<S.FileFindTextBox placeholders={false}>
{'이름:' + fileProps.name + ' / 크기:' + fileProps.size + ' / 타입:' + fileProps.fileType}
{'이름:' +
fileProps.filename +
' / 크기:' +
fileProps.size +
' / 타입:' +
fileProps.fileType}
</S.FileFindTextBox>
) : (
<S.FileFindTextBox placeholders={true}>업로드 할 파일을 선택해주세요....</S.FileFindTextBox>
Expand Down
4 changes: 4 additions & 0 deletions src/components/common/FileListBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import React from 'react';

import { ReactComponent as LockIcon } from '../../../assets/lockIcon.svg';
import * as S from './styled';

type FileListBoxProps = {
filename: string;
size: string;
LastModified: any;
isEncrypted: boolean;
click: () => void;
};

export const FileListBox: React.FC<FileListBoxProps> = ({
filename,
size,
LastModified,
isEncrypted,
click,
}) => (
<S.FileListBoxContainer onClick={click}>
{isEncrypted ? <LockIcon width={'2.3rem'} style={{ marginRight: '0.5rem' }} /> : <></>}
파일이름: {filename} / 크기:{size} / 업로드날짜:{LastModified.year}-{LastModified.month}-
{LastModified.day}
</S.FileListBoxContainer>
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/FileListBox/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const FileListBoxContainer = styled.div`
padding: 1.2rem 1.2rem 1.2rem 1.2rem;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
align-items: flex-end;
font-size: 2.2rem;
margin-bottom: 1.5rem;
cursor: pointer;
Expand Down
1 change: 1 addition & 0 deletions src/components/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './Button';
export * from './FileListBox';
export * from './Progress';
export * from './SkeletonUIBox';
export * from './FileBox';
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './useDeletePageNavigate';
export * from './useDownloadPageNavigate';
16 changes: 16 additions & 0 deletions src/hooks/useDownloadPageNavigate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useDispatch } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { bindActionCreators } from 'redux';

import { actionCreators } from '../state';

export const useDownloadPageNavigate = (props: any) => {
const navigate = useNavigate();
const dispatch = useDispatch();
const { SetDownloadFileProps } = bindActionCreators(actionCreators, dispatch);
const move = () => {
SetDownloadFileProps(props);
navigate('/download');
};
return [move];
};
90 changes: 90 additions & 0 deletions src/pages/checkpw/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { useDispatch } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';
import { bindActionCreators } from 'redux';

import { FileBox, Button } from '../../components';
import { actionCreators } from '../../state';
import { RootState } from '../../state/reducers';
import { getDate } from '../../utils';
import * as S from './styled';

export const CheckPasswordPage: React.FC = () => {
const checkPasswordFileProps = useSelector((state: RootState) => state.CheckPasswordFileProps);
const [password, setPassword] = useState('');
const { year, month, day } = getDate(checkPasswordFileProps.lastModified);
const dispatch = useDispatch();
const { SetDownloadFileProps } = bindActionCreators(actionCreators, dispatch);

const navigate = useNavigate();

const passwordCheck = async () => {
if (password === '') {
toast.error('비밀번호를 입력해주세요.', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
} else {
await axios({
method: 'get',
url: `${process.env.REACT_APP_BACKEND_BASEURL}/checkpw/${checkPasswordFileProps.filename}?pw=${password}`,
})
.then((res) => {
SetDownloadFileProps({
filename: checkPasswordFileProps.filename,
size: checkPasswordFileProps.size,
lastModified: checkPasswordFileProps.lastModified,
token: res.data.token,
});
navigate('/download');
toast.success('통과!', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
})
.catch((err) => {
console.log(err);
toast.error('비밀번호를 다시 확인해주세요...', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
});
}
};
useEffect(() => {
if (
checkPasswordFileProps.filename === null ||
checkPasswordFileProps.size === null ||
checkPasswordFileProps.lastModified === null
) {
navigate('/');
}
});
return (
<S.CheckPasswordPageContainer>
<FileBox>
파일이름:{checkPasswordFileProps.filename} / 크기:{checkPasswordFileProps.size} / 업로드된
날짜: {year}-{month}-{day}
</FileBox>
<S.PasswordInputSection>
<S.CheckPasswordInput
onChange={(text) => {
setPassword(text.target.value.replace(/(\s*)/g, ''));
}}
placeholder="비밀번호를 입력해주세요."
/>

<Button
click={() => {
passwordCheck();
}}
bgColor="var(--color-button-primary)"
label="전송"
/>
</S.PasswordInputSection>
</S.CheckPasswordPageContainer>
);
};
24 changes: 24 additions & 0 deletions src/pages/checkpw/styled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import styled from '@emotion/styled';

export const CheckPasswordPageContainer = styled.div`
display: flex;
align-items: center;
flex-direction: column;
width: 100%;
`;

export const PasswordInputSection = styled.div`
display: flex;
margin: 4rem;
`;

export const CheckPasswordInput = styled.input`
border: 4px solid var(--color-border);
border-radius: 10px;
outline: none;
width: 50rem;
height: 6rem;
padding-left: 12px;
font-size: 1.8rem;
font-weight: 700;
`;
50 changes: 37 additions & 13 deletions src/pages/download/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,59 @@ import { useSelector } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';

import { Button } from '../../components';
import { Button, FileBox } from '../../components';
import { RootState } from '../../state/reducers';
import { getFileSize, getDate } from '../../utils';
import { getDate } from '../../utils';
import * as S from './styled';

export const DownloadPage: React.FC = () => {
const navigate = useNavigate();
const downloadFileProps: any = useSelector((state: RootState) => state.DownloadFileProps);
const { year, month, day } = getDate(downloadFileProps.LastModified);
const { year, month, day } = getDate(downloadFileProps.lastModified);
useEffect(() => {
if (
downloadFileProps.Name === null ||
downloadFileProps.Size === null ||
downloadFileProps.LastModified === null
downloadFileProps.filename === null ||
downloadFileProps.size === null ||
downloadFileProps.lastModified === null
) {
navigate(-1);
navigate('/');
}
});
}, [navigate, downloadFileProps]);
return (
<S.DownloadPageContainer>
<S.DonwloadFileBox>
파일이름:{downloadFileProps.Name} / 크기:{getFileSize(downloadFileProps.Size)} / 업로드된
날짜:
<FileBox>
파일이름:{downloadFileProps.filename} / 크기:{downloadFileProps.size} / 업로드된 날짜:
{year}-{month}-{day}
</S.DonwloadFileBox>
</FileBox>
<S.DownloadPageButtonSection>
<a href={`${process.env.REACT_APP_BACKEND_BASEURL}/dl/${downloadFileProps.Name}`}>
<a
href={`${process.env.REACT_APP_BACKEND_BASEURL}/dl/${downloadFileProps.name}${
downloadFileProps.token != null ? `?${downloadFileProps.token}` : ''
}`}
>
<Button click={() => {}} bgColor="var(--color-button-primary)" label="다운로드" />
</a>
<Button
click={() => {
navigator.clipboard.writeText(``);
toast.success('복사 완료', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
}}
bgColor="var(--color-button-primary)"
label="링크복사"
/>
<Button
click={() => {
toast.success('제작중!', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
}}
bgColor="var(--color-button-secondary)"
label="파일삭제"
/>
<Button
click={() => {
toast.success('제작중!', {
Expand Down
12 changes: 1 addition & 11 deletions src/pages/download/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styled from '@emotion/styled';
export const DownloadPageContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
`;

Expand All @@ -12,14 +13,3 @@ export const DownloadPageButtonSection = styled.div`
justify-content: center;
margin-top: 3rem;
`;

export const DonwloadFileBox = styled.div`
background-color: var(--color-backgorund-filelistbox);
color: var(--color-text-tertiary);
border-radius: 10px;
padding: 1.2rem 1.2rem 1.2rem 1.2rem;
display: flex;
flex-direction: row;
align-items: center;
font-size: 2.2rem;
`;
Loading