浏览代码

wednesday morning

Ian Fung 1 年之前
父节点
当前提交
f3068d5a9e

+ 3 - 0
app.json

@@ -19,6 +19,9 @@
             "infoPlist": {
                 "LSApplicationQueriesSchemes": ["whatsapp"],
                 "UIBackgroundModes": ["remote-notification"]
+            },
+            "config": {
+                "googleMapsApiKey": "AIzaSyDYVSNuXFDNOhZAKfqeSwBTc8Pa7hKma1A"
             }
         },
         "android": {

+ 34 - 4
app/_layout.tsx

@@ -6,16 +6,46 @@ import { useEffect, useState } from 'react';
 import { checkVersion } from '../component/checkVersion';
 import { authenticationService } from '../service/authService';
 import { usePushNotifications } from './hooks/usePushNotifications';
-
+import Constants from 'expo-constants';
+import { Alert } from 'react-native';
 export default function RootLayout() {
     const [isLoading, setIsLoading] = useState(true);
     const { user } = useAuth();
     const { expoPushToken, notification } = usePushNotifications();
+    const data = JSON.stringify(notification, undefined, 2);
+
+    useEffect(() => {
+        const logAppConfig = async () => {
+            console.log('=== App Configuration ===');
+            console.log('Environment:', EXPO_PUBLIC_NODE_ENV);
+            console.log('App Version:', Constants.expoConfig?.version);
+            console.log('Runtime Version:', Constants.expoConfig?.runtimeVersion);
+            console.log('Update Channel:', Constants.expoConfig?.updates?.channel);
+            console.log('Release Channel:', Constants.manifest?.releaseChannel);
+            console.log('======================');
+        };
 
-    console.log('notification', notification);
-    console.log('expoPushToken', expoPushToken?.data);
+        const init = async () => {
+            try {
+                await logAppConfig();
 
-    const data = JSON.stringify(notification, undefined, 2);
+                console.log('Fetching version info...');
+                const response = await authenticationService.getVersion();
+                console.log('Version response:', response);
+
+                console.log('Checking version...');
+                checkVersion(response);
+
+                console.log('Initialization complete');
+            } catch (error) {
+                console.error('Initialization error:', error);
+                // Log additional context but don't crash
+                Alert.alert('Initialization Error', 'Please check your connection and try again.');
+            }
+        };
+
+        init();
+    }, []);
 
     useEffect(() => {
         const fetchVersion = async () => {

二进制
assets/uber208.png


二进制
assets/uberUploadSample111.png


二进制
assets/uberUploadSample222.png


+ 2 - 2
component/accountPages/uberUploadPageComponent.tsx

@@ -108,13 +108,13 @@ const UberUploadPageComponent = () => {
                         <Text style={{ fontSize: 22, marginBottom: 9 }}>上傳範例</Text>
                         <View className="flex-row w-full justify-between">
                             <Image
-                                source={require('../../assets/uberUploadSample1.png')}
+                                source={require('../../assets/uberUploadSample111.png')}
                                 resizeMode="contain"
                                 className="flex-1 h-auto"
                                 style={{ aspectRatio: 1 }}
                             />
                             <Image
-                                source={require('../../assets/uberUploadSample2.png')}
+                                source={require('../../assets/uberUploadSample222.png')}
                                 resizeMode="contain"
                                 className="flex-1 h-auto"
                                 style={{ aspectRatio: 1 }}

+ 7 - 6
component/bindingMultiStepForm/formComponent/formPages/bindingFinishPage.tsx

@@ -10,17 +10,18 @@ const BindingFinishPage = () => {
                     <Text style={styles.titleText} className="pb-12">
                         綁定手機號碼成功
                     </Text>
-
                     <Text style={styles.text}>
                         <Text style={{ fontWeight: 'bold' }}>請使用手機號碼進行登入</Text>
                     </Text>
                     <Text style={styles.text}>謝謝</Text>
+                    <Image source={require('../../../../assets/forgetPasswordSuccess.png')} />
+                    <View className="w-full">
+                        <NormalButton
+                            title={<Text style={{ color: '#fff' }}>按我前往登入頁面</Text>}
+                            onPress={() => router.replace('/login')}
+                        />
+                    </View>
                 </View>
-
-                <NormalButton
-                    title={<Text style={{ color: '#fff' }}>按我前往登入頁面</Text>}
-                    onPress={() => router.replace('/login')}
-                />
             </View>
         </>
     );

+ 4 - 3
component/bindingMultiStepForm/formComponent/formPages/bindingPhoneNumberPageStepTwo.tsx

@@ -130,10 +130,10 @@ const BindingPhoneNumberPageStepTwo = ({ bindingFormData, setBindingFormData, se
             if (result.status == 200) {
                 setScreen(2);
             } else {
-                setError('確認手機號碼失敗,請稍後再試');
+                setError('綁定手機號碼失敗,請檢查您輸入的OTP並再試一次');
             }
         } catch (error) {
-            Alert.alert('確認手機號碼失敗,請檢查您輸入的OTP並再試一次');
+            Alert.alert('綁定手機號碼失敗,請檢查您輸入的OTP並再試一次');
         } finally {
             setIsLoading2(false);
         }
@@ -142,11 +142,12 @@ const BindingPhoneNumberPageStepTwo = ({ bindingFormData, setBindingFormData, se
         try {
             //this check if phone same,
             const checkPhoneSame = await authenticationService.checkPhoneSame(bindingFormData.phoneNumber);
+            console.log('checkPhoneSame', checkPhoneSame);
             if (checkPhoneSame?.status == 422) {
                 //this means phone not same
                 Alert.alert('確認您的手機號碼', '您以後將使用現在輸入的號碼進行登入。請按下確認表示您已知悉。', [
                     {
-                        text: '確認',
+                        text: '確認並發出驗證碼',
                         onPress: async () => {
                             try {
                                 const token = await SecureStore.getItemAsync('accessToken');

+ 33 - 5
component/checkVersion.tsx

@@ -1,13 +1,41 @@
 import Constants from 'expo-constants';
 import * as Linking from 'expo-linking';
-import { Alert, Platform } from 'react-native';
+import { Alert, Platform, BackHandler } from 'react-native';
+import * as Updates from 'expo-updates';
 
-export function checkVersion(fetchedVersion: string) {
+export function checkVersion(fetchedVersion: { version: string; isActive: boolean }) {
     const currentVersion = Constants.expoConfig?.version;
-    console.log('currentVersion', currentVersion);
-    console.log('fetchedVersion', fetchedVersion);
+    // console.log('currentVersion', currentVersion);
+    // console.log('fetchedVersion', fetchedVersion.version);
+    // console.log('fetchedVersion.isActive', fetchedVersion.isActive);
+    if (!fetchedVersion.isActive) {
+        Alert.alert(
+            '伺服器維護中,敬請見諒',
+            '',
+            [
+                {
+                    text: '確認',
+                    onPress: () => {
+                        if (Platform.OS === 'android') {
+                            BackHandler.exitApp();
+                        } else {
+                            // For iOS, we can force a reload of the app
+                            // This will create an infinite loop of the maintenance message
+                            // until maintenance is over
+                            setTimeout(() => {
+                                Updates.reloadAsync();
+                            }, 100);
+                        }
+                    }
+                }
+            ],
+            { cancelable: false }
+        );
+        // Prevent any further code execution
+        throw new Error('MAINTENANCE_MODE');
+    }
 
-    if (currentVersion && currentVersion !== fetchedVersion) {
+    if (currentVersion && currentVersion !== fetchedVersion.version) {
         Alert.alert(
             '請更新到最新版本',
             'Please update to the latest version of the app to continue.',

+ 3 - 1
component/registrationMultiStepForm/formComponent/formPages/loginPage.tsx

@@ -104,6 +104,7 @@ const LoginPage: React.FC<LoginPageProps> = ({ goToNextPage, goToForgetPassWordP
             // const lowerCaseUsername = username.toLowerCase();
             const isBinding = false;
             const success = await login(username, password, isBinding);
+
             if (success) {
                 if (saveAccount) {
                     await AsyncStorage.setItem('savedPhone', username);
@@ -113,7 +114,8 @@ const LoginPage: React.FC<LoginPageProps> = ({ goToNextPage, goToForgetPassWordP
                     await AsyncStorage.removeItem('savedPassword');
                 }
             } else {
-                Alert.alert('登入失敗', '請檢查您的電話號碼和密碼');
+                console.log('success', success);
+                Alert.alert('登入失敗', '請確認您已綁定電話號碼並輸入了正確的電話和密碼');
             }
         }
         setIsLoading(false);

+ 11 - 5
component/registrationMultiStepForm/formComponent/formPages/verification.tsx

@@ -63,18 +63,26 @@ const Verification: React.FC<VerificationProps> = ({ setScreen }) => {
             if (timer) clearInterval(timer);
         };
     }, [countdown]);
-    const handleSubmitOtp = () => {
+    const handleSubmitOtp = async () => {
         if (signUpFormData.phone) {
             if (canSendOtp) {
                 setCanSendOtp(false);
                 setLockPhoneInput(true);
                 setCountdown(60);
-                authenticationService.sendOtpToSignUpPhone(signUpFormData.phone);
+                try {
+                    await authenticationService.sendOtpToSignUpPhone(signUpFormData.phone);
+                    setError('');
+                } catch (error) {
+                    console.log(error);
+                    setError('發送OTP失敗,請聯絡工作人員');
+                    setCanSendOtp(true); // Reset canSendOtp if there's an error
+                    setLockPhoneInput(false); // Unlock phone input if there's an error
+                }
                 setTimeout(() => {
                     setCanSendOtp(true);
                     setLockPhoneInput(false);
                 }, 60000);
-                setError('');
+                // setError('');
             } else {
                 setError('請等待一分鐘後再重新發送。');
             }
@@ -97,7 +105,6 @@ const Verification: React.FC<VerificationProps> = ({ setScreen }) => {
         <>
             <View style={styles.container}>
                 <Text style={styles.text}>請驗證您的手機號碼</Text>
-
                 <PhoneInput
                     value={signUpFormData?.phone || ''}
                     onChangeText={(phone: any) =>
@@ -122,7 +129,6 @@ const Verification: React.FC<VerificationProps> = ({ setScreen }) => {
                     extendedStyle={{ opacity: !lockPhoneInput ? 1 : 0.5 }}
                     autoCapitalize="none"
                 /> */}
-
                 <View
                     style={{
                         display: 'flex',

+ 1 - 1
component/searchPage/searchResultComponent.tsx

@@ -241,7 +241,7 @@ const SearchResultComponent = () => {
                         provider="google"
                         style={styles.map}
                         region={region}
-                        initialRegion={region}
+                        // initialRegion={region}
                         cameraZoomRange={{
                             minCenterCoordinateDistance: 500,
                             maxCenterCoordinateDistance: 90000,

+ 30 - 0
context/AuthProvider.tsx

@@ -91,6 +91,36 @@ export default function AuthProvider({ children }: { children: ReactNode }) {
         }
     };
 
+    //this is urgent login, only for testing & debugging
+    // const login = async (username: string, password: string, isBinding: boolean) => {
+    //     try {
+    //         const loggedInUser = {
+    //             accessToken:
+    //                 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiY3VzdG9tZXIiLCJjcmVhdGVkQXQiOiIyMDI0LTA5LTAzVDA2OjM4OjU3LjI5NloiLCJ1cGRhdGVkQXQiOiIyMDI0LTEyLTAyVDE3OjUwOjQyLjI1MloiLCJpZCI6IjA2ZTRkNjU0LTliNDEtNDExMy1hZjBmLTE5OTIzYjc0YzEwZSIsImZpcnN0bmFtZSI6bnVsbCwibGFzdG5hbWUiOm51bGwsIm5pY2tuYW1lIjoiVGVzdCAyIiwiZW1haWwiOiJ0ZXN0MkBnbWFpbC5jb20iLCJwaG9uZSI6NjgxMDAxMTYsImljX2NhcmQiOiIwMDAwMDAwMDAwMDAxNDk2Iiwid2FsbGV0Ijo5NzYwLCJpY29uX3VybCI6bnVsbCwicmVtYXJrIjpudWxsLCJhZGRyZXNzIjpudWxsLCJzdGF0dXNfZmsiOiIxIiwiZ2VuZGVyIjoibWFuIiwiYmlydGhkYXkiOiIwNC8wNi8xMSIsImljX2Nhcl9pZCI6bnVsbCwiaWF0IjoxNzMzMTkyNjgzLCJleHAiOjE3MzMxOTk4ODN9.1VvQacR5SJ1JiRlnmy_m5rcrKN8wXsPTZ9_QLas8CEQ',
+    //             refreshToken:
+    //                 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiY3VzdG9tZXIiLCJjcmVhdGVkQXQiOiIyMDI0LTA5LTAzVDA2OjM4OjU3LjI5NloiLCJ1cGRhdGVkQXQiOiIyMDI0LTEyLTAyVDE3OjUwOjQyLjI1MloiLCJpZCI6IjA2ZTRkNjU0LTliNDEtNDExMy1hZjBmLTE5OTIzYjc0YzEwZSIsImZpcnN0bmFtZSI6bnVsbCwibGFzdG5hbWUiOm51bGwsIm5pY2tuYW1lIjoiVGVzdCAyIiwiZW1haWwiOiJ0ZXN0MkBnbWFpbC5jb20iLCJwaG9uZSI6NjgxMDAxMTYsImljX2NhcmQiOiIwMDAwMDAwMDAwMDAxNDk2Iiwid2FsbGV0Ijo5NzYwLCJpY29uX3VybCI6bnVsbCwicmVtYXJrIjpudWxsLCJhZGRyZXNzIjpudWxsLCJzdGF0dXNfZmsiOiIxIiwiZ2VuZGVyIjoibWFuIiwiYmlydGhkYXkiOiIwNC8wNi8xMSIsImljX2Nhcl9pZCI6bnVsbCwiaWF0IjoxNzMzMTkyMjY5LCJleHAiOjE3MzY2NDgyNjl9.OrZqQyLkHL0eojesrn3xqoxIYatanjCX-GyXTcmNoys'
+    //         };
+    //         if (loggedInUser) {
+    //             //this is only for urgent login, uncomment getItemAsync after
+    //             await SecureStore.setItemAsync('accessToken', loggedInUser.accessToken);
+    //             const token = await SecureStore.getItemAsync('accessToken');
+    //             if (token) {
+    //                 const userInfo = await getUserFromAccessToken();
+    //                 if (userInfo) {
+    //                     console.log('userInfouserInfouserInfouserInfouserInfouserInfo', userInfo);
+    //                     setUser(userInfo);
+    //                 }
+    //             }
+    //             return true;
+    //         } else {
+    //             return false;
+    //         }
+    //     } catch (error) {
+    //         console.error('Login error:', error);
+    //         return false;
+    //     }
+    // };
+
     const getUserFromAccessToken = async () => {
         const token = await SecureStore.getItemAsync('accessToken');
         try {