Skip to content

Commit

Permalink
Merge pull request #95 from tempfiles-Team/93-upload-로딩후-백엔드-작업-로딩-추가
Browse files Browse the repository at this point in the history
93 upload 로딩후 백엔드 작업 로딩 추가
  • Loading branch information
ananjaemin committed Nov 17, 2022
2 parents 4aecd99 + 2fbd88c commit 92b6149
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/components/common/Progress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ type ProgressBarProps = {
value: number;
fileName: string;
typing: string;
stateText: string;
};

export const Progress: React.FC<ProgressBarProps> = ({ value, fileName, typing }) => {
export const Progress: React.FC<ProgressBarProps> = ({ value, fileName, typing, stateText }) => {
const likecontainer = useRef();
useEffect(() => {
Lottie.loadAnimation({
Expand All @@ -26,7 +27,8 @@ export const Progress: React.FC<ProgressBarProps> = ({ value, fileName, typing }
<S.ProgressAnimationBox ref={likecontainer} />
<S.ProgressBar width={value} />
<S.ProgressText>
{fileName} uploading{typing}
{fileName} {stateText}
{typing}
</S.ProgressText>
</S.ProgressContainer>
);
Expand Down
9 changes: 7 additions & 2 deletions src/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export const MainPage: React.FC = () => {
const typingText = ['.', '..', '...'];
const [typingCount, setTypingCount] = useState(0);
const [uploading, setUploading] = useState(true);
const [progressValue, serProgressValue] = useState(0);
const [progressValue, setProgressValue] = useState(0);
const [progressStateText, setProgressStateText] = useState('uploading');

const [retentionPeriod, setRetentionPeriod] = useState(false);
const [downloadCount, setDownloadCount] = useState(false);
Expand Down Expand Up @@ -58,7 +59,10 @@ export const MainPage: React.FC = () => {
},
onUploadProgress(progress) {
setUploading(false);
serProgressValue(Math.floor((progress.loaded / progress.total) * 100));
setProgressValue(Math.floor((progress.loaded / progress.total) * 100));
if (Math.floor((progress.loaded / progress.total) * 100) === 100) {
setProgressStateText('백엔드 처리중');
}
},
})
.then(async (res) => {
Expand Down Expand Up @@ -151,6 +155,7 @@ export const MainPage: React.FC = () => {
value={progressValue}
fileName={fileProps.filename}
typing={typingText[typingCount]}
stateText={progressStateText}
/>
)}
</S.MainPageContainer>
Expand Down

0 comments on commit 92b6149

Please sign in to comment.