File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import {
3737 readAsBase64 ,
3838} from "../image-uploader" ;
3939import { HYPERCERTS_API_URL_REST } from "@/configs/hypercerts" ;
40+ import isURL from "validator/lib/isURL" ;
4041
4142const formSchema = z . object ( {
4243 displayName : z . string ( ) . max ( 30 , "Max. 30 characters" ) . optional ( ) ,
@@ -88,8 +89,10 @@ export const SettingsForm = () => {
8889
8990 const onSubmit = async ( data : SettingsFormValues ) => {
9091 try {
91- if ( data . avatar ) {
92+ // if data.avatar is not an url, that means the user has uploaded a new image
93+ if ( data . avatar && ! isURL ( data . avatar ) ) {
9294 const formData = new FormData ( ) ;
95+
9396 const blob = base64ToBlob ( data . avatar ) ;
9497 const file = new File ( [ blob ] , "avatar.jpg" , {
9598 type : "image/jpeg" ,
@@ -193,8 +196,8 @@ export const SettingsForm = () => {
193196
194197 const isSubmitDisabled =
195198 form . formState . isSubmitting ||
196- isFormDisabled ||
197199 ! form . formState . isValid ||
200+ isFormDisabled ||
198201 ! form . formState . isDirty ;
199202
200203 const shouldShowAvatar =
You can’t perform that action at this time.
0 commit comments