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

Dev #82

Merged
merged 3 commits into from
Nov 16, 2022
Merged

Dev #82

Changes from all commits
Commits
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
101 changes: 56 additions & 45 deletions src/pages/download/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSelector } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';

import { Button, FileBox } from '../../components';
import { Button, FileBox, SkeletonUI } from '../../components';
import { useDeletePageNavigator } from '../../hooks';
import { RootState } from '../../state/reducers';
import { getDate, getFileSize } from '../../utils';
Expand All @@ -13,6 +13,7 @@ import * as S from './styled';
export const DownloadPage: React.FC = () => {
const navigate = useNavigate();
const downloadFileProps: any = useSelector((state: RootState) => state.DownloadFileProps);
const [loading, setLoading] = useState(true);
const [fileProps, setFileProps] = useState({
filename: '',
// fileId: '',
Expand All @@ -38,6 +39,7 @@ export const DownloadPage: React.FC = () => {
}${downloadFileProps.isEncrypted ? `?token=${downloadFileProps.token}` : ''}`,
})
.then((res) => {
setLoading(false);
setFileProps({
filename: res.data.filename,
// fileId: res.data.fileId,
Expand Down Expand Up @@ -65,51 +67,60 @@ export const DownloadPage: React.FC = () => {
}, [downloadFileProps, navigate]);
return (
<S.DownloadPageContainer>
<FileBox>
파일이름:{fileProps.filename} / 크기:{fileProps.size} / 업로드된 날짜:
{fileProps.uploadDate.year}-{fileProps.uploadDate.month}-{fileProps.uploadDate.day}
</FileBox>
<S.DownloadPageButtonSection>
<a
href={`${fileProps.download_url}${
fileProps.isEncrypted ? `?token=${downloadFileProps.token}` : ''
}`}
>
<Button click={() => {}} bgColor="var(--color-button-primary)" label="다운로드" />
</a>
<Button
click={() => {
navigator.clipboard.writeText(
`${fileProps.download_url}${
{!loading ? (
<>
<FileBox>
파일이름:{fileProps.filename} / 크기:{fileProps.size} / 업로드된 날짜:
{fileProps.uploadDate.year}-{fileProps.uploadDate.month}-{fileProps.uploadDate.day}
</FileBox>
<S.DownloadPageButtonSection>
<a
href={`${fileProps.download_url}${
fileProps.isEncrypted ? `?token=${downloadFileProps.token}` : ''
}`,
);
toast.success('복사 완료', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
}}
bgColor="var(--color-button-primary)"
label="링크복사"
/>
<Button
click={() => {
move();
}}
bgColor="var(--color-button-secondary)"
label="파일삭제"
/>
<Button
click={() => {
toast.success('제작중!', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
}}
bgColor="var(--color-button-secondary)"
label="신고"
/>
</S.DownloadPageButtonSection>
}`}
>
<Button click={() => {}} bgColor="var(--color-button-primary)" label="다운로드" />
</a>
<Button
click={() => {
navigator.clipboard.writeText(
`${fileProps.download_url}${
fileProps.isEncrypted ? `?token=${downloadFileProps.token}` : ''
}`,
);
toast.success('복사 완료', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
}}
bgColor="var(--color-button-primary)"
label="링크복사"
/>
<Button
click={() => {
move();
}}
bgColor="var(--color-button-secondary)"
label="파일삭제"
/>
<Button
click={() => {
toast.success('제작중!', {
autoClose: 1000,
position: toast.POSITION.BOTTOM_RIGHT,
});
}}
bgColor="var(--color-button-secondary)"
label="신고"
/>
</S.DownloadPageButtonSection>
</>
) : (
<>
<SkeletonUI width="80rem" height="4.6rem" margin="0" />
<SkeletonUI width="64rem" height="6rem" margin="3rem 0px 0px 0px" />
</>
)}
</S.DownloadPageContainer>
);
};