-
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 #11 from ananjaemin/10-download-page-개발
download page version 1 ( no password)
- Loading branch information
Showing
11 changed files
with
126 additions
and
20 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
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,13 +1,48 @@ | ||
import React from 'react'; | ||
import React, { useEffect } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { toast } from 'react-toastify'; | ||
|
||
import { Button } from '../../components'; | ||
import { RootState } from '../../state/reducers'; | ||
import { getFileSize, getDate } from '../../utils'; | ||
import * as S from './styled'; | ||
|
||
export const DownloadPage: React.FC = () => ( | ||
<S.DownloadPageContainer> | ||
<S.DownloadPageButtonSection> | ||
<Button click={() => {}} bgColor="var(--color-button-secondary)" label="다운로드" /> | ||
<Button click={() => {}} bgColor="var(--color-button-secondary)" label="신고" /> | ||
</S.DownloadPageButtonSection> | ||
</S.DownloadPageContainer> | ||
); | ||
export const DownloadPage: React.FC = () => { | ||
const navigate = useNavigate(); | ||
const downloadFileProps: any = useSelector((state: RootState) => state.DownloadFileProps); | ||
const { year, month, day } = getDate(downloadFileProps.LastModified); | ||
useEffect(() => { | ||
if ( | ||
downloadFileProps.Name === null || | ||
downloadFileProps.Size === null || | ||
downloadFileProps.LastModified === null | ||
) { | ||
navigate(-1); | ||
} | ||
}); | ||
return ( | ||
<S.DownloadPageContainer> | ||
<S.DonwloadFileBox> | ||
파일이름:{downloadFileProps.Name} / 크기:{getFileSize(downloadFileProps.Size)} / 업로드된 | ||
날짜: | ||
{year}-{month}-{day} | ||
</S.DonwloadFileBox> | ||
<S.DownloadPageButtonSection> | ||
<a href={`https://tfb.minpeter.cf/dl/${downloadFileProps.Name}`}> | ||
<Button click={() => {}} bgColor="var(--color-button-primary)" label="다운로드" /> | ||
</a> | ||
<Button | ||
click={() => { | ||
toast.success('제작중!', { | ||
autoClose: 1000, | ||
position: toast.POSITION.BOTTOM_RIGHT, | ||
}); | ||
}} | ||
bgColor="var(--color-button-secondary)" | ||
label="신고" | ||
/> | ||
</S.DownloadPageButtonSection> | ||
</S.DownloadPageContainer> | ||
); | ||
}; |
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,12 +1,25 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const DownloadPageContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
`; | ||
|
||
export const DownloadPageButtonSection = styled.div` | ||
display: flex; | ||
width: 100%; | ||
min-width: 300px; | ||
justify-content: center; | ||
margin-top: 3rem; | ||
`; | ||
|
||
export const DonwloadFileBox = styled.div` | ||
background-color: var(--color-backgorund-filelistbox); | ||
color: var(--color-text-filelistbox); | ||
border-radius: 10px; | ||
padding: 1.2rem 1.2rem 1.2rem 1.2rem; | ||
display: flex; | ||
justify-content: space-between; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export enum ActionType { | ||
SusccesFileProps = 'SusccesFileProps', | ||
DeleteFileName = 'DeleteFileName', | ||
DownloadFileProps = 'DownloadFileProps', | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ActionType } from '../action-types'; | ||
import { Action } from '../actions'; | ||
|
||
const reducer = ( | ||
state: any = { Name: null, Size: null, LastModified: null }, | ||
action: Action, | ||
): any => { | ||
switch (action.type) { | ||
case ActionType.DownloadFileProps: | ||
return action.props; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default reducer; |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const getDate = (date: string) => { | ||
const NewDate = new Date(date); | ||
return { year: NewDate.getFullYear(), month: NewDate.getMonth() + 1, day: NewDate.getDay() }; | ||
}; |
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,3 @@ | ||
export * from './getFileSize'; | ||
export * from './getShortFileName'; | ||
export * from './getDate'; |