@@ -199,15 +199,23 @@ export class ProviderDetailsComponent implements OnInit, OnChanges {
199
199
const fileName = event . name . replace ( / [ ^ A - Z a - z 0 - 9 _ . ] / g, '' )
200
200
if ( this . thumbnailFile ) {
201
201
if ( fileName . toLowerCase ( ) . endsWith ( '.svg' ) || fileName . toLowerCase ( ) . endsWith ( '.png' ) ) {
202
- const reader = new FileReader ( )
203
- reader . onload = ( e : any ) => {
204
- const img = new Image ( )
205
- img . onload = ( ) => {
206
- this . cropImage ( img )
202
+ const fileSizeInKB = this . thumbnailFile . size / 1000
203
+ const minSizeKB = 300
204
+ const maxSizeMB = 2
205
+ const maxSizeKB = maxSizeMB * 1000
206
+ if ( fileSizeInKB >= minSizeKB && fileSizeInKB <= maxSizeKB ) {
207
+ const reader = new FileReader ( )
208
+ reader . onload = ( e : any ) => {
209
+ const img = new Image ( )
210
+ img . onload = ( ) => {
211
+ this . cropImage ( img )
212
+ }
213
+ img . src = e . target . result
207
214
}
208
- img . src = e . target . result
215
+ reader . readAsDataURL ( this . thumbnailFile )
216
+ } else {
217
+ this . showSnackBar ( 'Please upload image sized between 300 KB and 2 MB' )
209
218
}
210
- reader . readAsDataURL ( this . thumbnailFile )
211
219
} else {
212
220
this . showSnackBar ( 'Please upload svg or png image' )
213
221
}
@@ -411,6 +419,8 @@ export class ProviderDetailsComponent implements OnInit, OnChanges {
411
419
this . showSnackBar ( errmsg )
412
420
} ,
413
421
} )
422
+ } else {
423
+ this . showSnackBar ( 'Please fill all the mandator fields with proper data' )
414
424
}
415
425
}
416
426
@@ -447,6 +457,8 @@ export class ProviderDetailsComponent implements OnInit, OnChanges {
447
457
this . showSnackBar ( errmsg )
448
458
} ,
449
459
} )
460
+ } else {
461
+ this . showSnackBar ( 'Please fill all the mandator fields with proper data' )
450
462
}
451
463
}
452
464
0 commit comments