File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ const Page = async ({ params }: PageProps) => {
23
23
// title: 'need Signin'
24
24
// })
25
25
26
- redirect ( '/dashboard ' )
26
+ redirect ( '/' )
27
27
}
28
28
29
29
const file = await db . file . findFirst ( {
Original file line number Diff line number Diff line change @@ -51,12 +51,26 @@ const UploadDropzone = ({ isSubscribed }: { isSubscribed: boolean }) => {
51
51
onDrop = { async ( acceptedFile ) => {
52
52
setIsUploading ( true )
53
53
54
- const progressInterval = startSimulatedProgress ( )
54
+ const fileSize = acceptedFile [ 0 ] . size / 1024 / 1024
55
55
56
+ if ( fileSize > ( isSubscribed ? 16 : 4 ) ) {
57
+ setIsUploading ( false )
58
+ acceptedFile . splice ( 0 , 1 ) // remove file
59
+ return toast ( {
60
+ title : 'The file size exceeds the limit.' ,
61
+ description : `Files cannot exceed ${ isSubscribed ? 16 : 4 } MB or Upgrade the plan.` ,
62
+ variant : 'destructive'
63
+ } )
64
+ }
65
+
66
+ const progressInterval = startSimulatedProgress ( )
56
67
// handle file uploading
57
68
const res = await startUpload ( acceptedFile )
58
69
59
70
if ( ! res ) {
71
+ clearInterval ( progressInterval )
72
+ setUploadProgress ( 0 )
73
+ setIsUploading ( false )
60
74
return toast ( {
61
75
title : 'Something went wrong' ,
62
76
description : 'Please try again later' ,
@@ -69,6 +83,9 @@ const UploadDropzone = ({ isSubscribed }: { isSubscribed: boolean }) => {
69
83
const key = fileResponse ?. key
70
84
71
85
if ( ! key ) {
86
+ clearInterval ( progressInterval )
87
+ setUploadProgress ( 0 )
88
+ setIsUploading ( false )
72
89
return toast ( {
73
90
title : 'Something went wrong' ,
74
91
description : 'Please try again later' ,
You can’t perform that action at this time.
0 commit comments