瀏覽代碼

fixed register screen

Viktoriia 1 年之前
父節點
當前提交
28d5cab993
共有 2 個文件被更改,包括 24 次插入20 次删除
  1. 3 3
      src/modules/api/auth/queries/use-post-register.tsx
  2. 21 17
      src/screens/RegisterScreen/EditAccount/index.tsx

+ 3 - 3
src/modules/api/auth/queries/use-post-register.tsx

@@ -17,9 +17,9 @@ export type UserRegistrationData = {
     homebase2?: number;
   };
   photo: {
-    type: string;
-    uri: string;
-    name: string;
+    type: string | undefined;
+    uri: string | undefined;
+    name: string | undefined;
   };
 };
 

+ 21 - 17
src/screens/RegisterScreen/EditAccount/index.tsx

@@ -43,21 +43,6 @@ const EditAccount = () => {
     }, [])
   );
 
-  useEffect(() => {
-    if (data && data.token) {
-      storage.set('token', data.token);
-      storage.set('uid', data.uid.toString());
-      updateLocalData(data.token);
-
-      dispatch(
-        CommonActions.reset({
-          index: 1,
-          routes: [{ name: NAVIGATION_PAGES.INFO }]
-        })
-      );
-    }
-  }, [data]);
-
   const updateLocalData = async (token: string) => {
     await fetchAndSaveStatistics(token);
   };
@@ -97,14 +82,33 @@ const EditAccount = () => {
                     homebase: values.homebase,
                     homebase2: values.homebase2
                   },
-                  photo: {
+                  photo: values.photo.uri ? {
                     type: values.photo.type,
                     uri: values.photo.uri,
                     name: values.photo.uri.split('/').pop()!
+                  } : {
+                    type: undefined,
+                    uri: undefined,
+                    name: undefined
                   }
                 };
 
-                userRegister(data);
+                userRegister(data, {
+                  onSuccess: (data) => {
+                    if (data && data.token) {
+                      storage.set('token', data.token);
+                      storage.set('uid', data.uid.toString());
+                      updateLocalData(data.token);
+                
+                      dispatch(
+                        CommonActions.reset({
+                          index: 1,
+                          routes: [{ name: NAVIGATION_PAGES.INFO }]
+                        })
+                      );
+                    }
+                  }
+                });
               }}
             >
               {(props) => (