File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
apps/web/app/(org)/dashboard/settings/account/components Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
66import clsx from "clsx" ;
77import Image from "next/image" ;
88import { useEffect , useRef , useState } from "react" ;
9+ import { toast } from "sonner" ;
910
1011interface ProfileImageProps {
1112 initialPreviewUrl ?: string | null ;
@@ -38,7 +39,13 @@ export function ProfileImage({
3839
3940 const handleFileChange = ( ) => {
4041 const file = fileInputRef . current ?. files ?. [ 0 ] ;
41- if ( file ) {
42+ if ( ! file ) return ;
43+ const sizeLimit = 1024 * 1024 * 1 ;
44+ if ( file . size > sizeLimit ) {
45+ toast . error ( "File size must be 1MB or less" ) ;
46+ return ;
47+ }
48+ if ( file && file . size <= sizeLimit ) {
4249 const objectUrl = URL . createObjectURL ( file ) ;
4350 setPreviewUrl ( objectUrl ) ;
4451 onChange ?.( file ) ;
You can’t perform that action at this time.
0 commit comments