File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 2727 button {
2828 margin : $sp-4 0 ;
2929 }
30+
31+ p {
32+ color : $red-100 ;
33+ }
3034 }
3135
3236 .preview {
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ const ModifyMemberPhotoModal: FC<ModifyMemberPhotoModalProps> = (props: ModifyMe
2121
2222 const fileElRef : MutableRefObject < HTMLDivElement | any > = useRef ( )
2323
24+ const [ fileSizeError , setFileSizeError ] : [ boolean , Dispatch < SetStateAction < boolean > > ]
25+ = useState < boolean > ( false )
26+
2427 function handleModifyPhotoSave ( ) : void {
2528 const formData : FormData = new FormData ( )
2629
@@ -48,10 +51,16 @@ const ModifyMemberPhotoModal: FC<ModifyMemberPhotoModalProps> = (props: ModifyMe
4851 function handleFilePickChange ( event : React . ChangeEvent < HTMLInputElement > ) : void {
4952 const pickedFile : File | undefined = event . target . files ?. [ 0 ]
5053
51- if ( pickedFile && pickedFile ?. size < 2000000 ) { // max 2mb limit
52- setFile ( pickedFile )
54+ if ( pickedFile ) {
55+ if ( pickedFile ?. size < 2000000 ) { // max 2mb limit
56+ setFile ( pickedFile )
57+ setFileSizeError ( false )
58+ } else {
59+ setFileSizeError ( true )
60+ }
5361 } else {
5462 setFile ( undefined )
63+ setFileSizeError ( false )
5564 }
5665 }
5766
@@ -95,6 +104,11 @@ const ModifyMemberPhotoModal: FC<ModifyMemberPhotoModalProps> = (props: ModifyMe
95104 primary
96105 onClick = { handleFilePickClick }
97106 />
107+ {
108+ fileSizeError && (
109+ < p > Please select an image that is less than 2MB.</ p >
110+ )
111+ }
98112 </ form >
99113 {
100114 file && (
You can’t perform that action at this time.
0 commit comments