-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from ananjaemin/15-filelist-page-개편-및-다운로드-패스워…
…드-확인 15 filelist page 개편 및 다운로드 패스워드 확인
- Loading branch information
Showing
25 changed files
with
297 additions
and
144 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -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 |
This file contains 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,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; | ||
`; |
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './useDeletePageNavigate'; | ||
export * from './useDownloadPageNavigate'; |
This file contains 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,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]; | ||
}; |
This file contains 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,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> | ||
); | ||
}; |
This file contains 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,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; | ||
`; |
This file contains 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 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.