Browse Source

committing for 1.3.3

Ian Fung 10 months ago
parent
commit
8f140677b7

+ 2 - 2
android/app/build.gradle

@@ -114,8 +114,8 @@ android {
         applicationId 'hk.com.crazycharge'
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
-        versionCode 29
-        versionName "1.3.2"
+        versionCode 30
+        versionName "1.3.3"
     }
     signingConfigs {
         debug {

+ 1 - 1
android/app/src/main/res/values/strings.xml

@@ -2,5 +2,5 @@
   <string name="app_name">Crazycharge</string>
   <string name="expo_splash_screen_resize_mode" translatable="false">contain</string>
   <string name="expo_splash_screen_status_bar_translucent" translatable="false">false</string>
-  <string name="expo_runtime_version">1.3.2</string>
+  <string name="expo_runtime_version">1.3.3</string>
 </resources>

+ 3 - 3
app.json

@@ -2,7 +2,7 @@
     "expo": {
         "name": "Crazycharge",
         "slug": "template",
-        "version": "1.3.2",
+        "version": "1.3.3",
         "orientation": "portrait",
         "icon": "./assets/cc_Logo.png",
         "userInterfaceStyle": "light",
@@ -50,7 +50,7 @@
                 "android.permission.ACCESS_FINE_LOCATION"
             ],
             "package": "hk.com.crazycharge",
-            "versionCode": 29,
+            "versionCode": 30,
             "googleServicesFile": "./google-services.json",
             "config": {
                 "googleMaps": {
@@ -96,7 +96,7 @@
                 "projectId": "536e7cff-9f65-4894-ad9f-e4ef8de57e4e"
             }
         },
-        "runtimeVersion": "1.3.2",
+        "runtimeVersion": "1.3.3",
         "updates": {
             "url": "https://u.expo.dev/536e7cff-9f65-4894-ad9f-e4ef8de57e4e"
         }

+ 1 - 1
app/(auth)/(tabs)/(home)/totalPayment.tsx

@@ -537,10 +537,10 @@ const TotalPayment = () => {
                 <View style={{ marginTop: 25 }}>
                     <Pressable
                         onPress={() => {
-                            cleanupData();
                             if (router.canGoBack()) {
                                 router.back();
                             } else {
+                                cleanupData();
                                 router.replace('/scanQrPage');
                             }
                         }}

+ 24 - 10
component/accountPages/paymentRecordPageComponent.tsx

@@ -28,7 +28,7 @@ const TransactionRow: React.FC<TransactionRecordItem> = ({
         <Text className="flex-[0.2] text-sm text-right ">
             {actual_total_power !== '-' ? Number(actual_total_power).toFixed(1) : actual_total_power}
         </Text>
-        <Text className="flex-[0.2] text-sm text-right">{current_price ? `$${current_price}` : '-'}</Text>
+        <Text className="flex-[0.2] text-sm text-right">{current_price ? `${current_price}` : '-'}</Text>
         <Text className="flex-[0.2] text-sm text-right">${amount}</Text>
     </View>
 );
@@ -102,7 +102,9 @@ const PaymentRecordPageComponent = () => {
                         (item: any) =>
                             item.type !== 'wallet' ||
                             item.goods_name === 'Penalty' ||
-                            (item.goods_name === 'Walk In' && Number(item.actual_total_power) >= 1) // Keep Walk In items only if power >= 1
+                            item.goods_name === 'manual_refund' ||
+                            item.goods_name === 'manual_deduction' ||
+                            (item.goods_name === 'Walk In' && Number(item.actual_total_power) >= 1)
                     )
                     .map((item: any) => {
                         let description;
@@ -123,32 +125,44 @@ const PaymentRecordPageComponent = () => {
                                 case 'manual_refund':
                                     description = '系統退款';
                                     break;
+                                case 'manual_deduction':
+                                    description = '系統扣款';
+                                    break;
                                 default:
                                     description = '充電';
                             }
                         } else if (item.type === 'qfpay') {
                             description = '錢包增值';
                         }
+
                         return {
                             date: convertToHKTime(item.createdAt).hkDate,
                             description: description,
                             amount:
-                                item.type === 'qfpay'
-                                    ? item.amount
-                                    : item.goods_name === 'Penalty'
+                                item.type === 'qfpay' ||
+                                item.goods_name === 'Penalty' ||
+                                item.goods_name === 'manual_refund' ||
+                                item.goods_name === 'manual_deduction'
                                     ? item.amount
                                     : item.current_price && item.actual_total_power
                                     ? (item.current_price * item.actual_total_power).toFixed(1)
                                     : '-',
                             actual_total_power:
-                                item.actual_total_power !== undefined &&
-                                item.actual_total_power !== null &&
-                                item.actual_total_power !== '' &&
-                                !isNaN(Number(item.actual_total_power))
+                                item.goods_name === 'manual_refund' || item.goods_name === 'manual_deduction'
+                                    ? '-'
+                                    : item.actual_total_power !== undefined &&
+                                      item.actual_total_power !== null &&
+                                      item.actual_total_power !== '' &&
+                                      !isNaN(Number(item.actual_total_power))
                                     ? item.actual_total_power
                                     : '-',
                             current_price:
-                                item.type === 'qfpay' || item.goods_name === 'Penalty' ? '-' : item.current_price
+                                item.type === 'qfpay' ||
+                                item.goods_name === 'Penalty' ||
+                                item.goods_name === 'manual_refund' ||
+                                item.goods_name === 'manual_deduction'
+                                    ? '-'
+                                    : item.current_price
                         };
                     });
                 setTransactionRecord(formattedData.slice(0, 10));

+ 3 - 1
component/chargingPage/noChargingOngoingPageComponent.tsx

@@ -149,7 +149,9 @@ const NoChargingOngoingPageComponent = () => {
                             chargeStationName: item.stationName,
                             availableConnectors: item.availableConnectors,
                             // imageSource: imageSource
-                            imageSource: item.image
+                            imageSource: item.image,
+                            stationLng: item.stationLng,
+                            stationLat: item.stationLat
                         }
                     });
                 }}

+ 0 - 1
component/global/bookingTabViewComponent.tsx

@@ -124,7 +124,6 @@ const BookingTabViewComponentInner: React.FC<BookingTabViewComponentProps> = ({
     }
 
     const tabItems = processReservations(data.reservations, data.stations, true);
-    console.log('tabItem', tabItems);
 
     const completedReservationTabItems = processReservations(data.reservations, data.stations, false);
     console.log('completedReservationTabItems', completedReservationTabItems);

+ 2 - 2
component/global/notificationTabViewComponent.tsx

@@ -51,7 +51,7 @@ const NotificationRow = ({
         >
             <View className="flex flex-row justify-between">
                 <Text className="font-[500] text-base">{promotionObj.title}</Text>
-                <Text>{formatToChineseDateTime(promotionObj.updatedAt)}</Text>
+                <Text>{formatToChineseDateTime(promotionObj.createdAt)}</Text>
             </View>
             <View>
                 <Text numberOfLines={2} ellipsizeMode="tail" className="text-sm">
@@ -207,7 +207,7 @@ const SecondRoute = ({ promotions, loading }: { promotions: TabItem[]; loading:
                                 promotions
                                     .sort(
                                         (a: any, b: any) =>
-                                            new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
+                                            new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
                                     )
                                     .slice(0, 30)
                                     .map((promotionObj: any, index: any) => (

+ 7 - 17
component/global/tabView.tsx

@@ -91,13 +91,7 @@ const TabViewComponent: React.FC<TabViewComponentProps> = ({
             ) : (
                 <FlashList
                     nestedScrollEnabled={true}
-                    data={tabItems.filter(
-                        (item) =>
-                            item.actual_fee &&
-                            item.actual_total_power &&
-                            item.actual_fee !== 0 &&
-                            item.actual_total_power !== 0
-                    )}
+                    data={tabItems.filter((item) => item.actual_total_power && item.actual_total_power !== 0)}
                     renderItem={({ item }) => <TabItem item={item} currentLocation={currentLocation} />}
                     estimatedItemSize={10}
                 />
@@ -112,11 +106,7 @@ const TabViewComponent: React.FC<TabViewComponentProps> = ({
                     <FlashList
                         nestedScrollEnabled={true}
                         data={completedReservationTabItems.filter(
-                            (item) =>
-                                item.actual_fee &&
-                                item.actual_total_power &&
-                                item.actual_fee > 1 &&
-                                item.actual_total_power > 1
+                            (item) => item.actual_total_power && item.actual_total_power > 1
                         )}
                         renderItem={({ item }) => <TabItem item={item} currentLocation={currentLocation} />}
                         estimatedItemSize={20}
@@ -367,11 +357,11 @@ const TabItem = ({ item, currentLocation }: { item: TabItem; currentLocation: Lo
                                 color: '#222222'
                             }}
                         >
-                            付金額:{' '}
-                            {item.actual_fee
-                                ? item.actual_fee % 1 === 0
-                                    ? `$${item.actual_fee}`
-                                    : `$${item.actual_fee.toFixed(1)}`
+                            付金額:{' '}
+                            {item.total_fee !== undefined && item.total_fee !== null
+                                ? item.total_fee % 1 === 0
+                                    ? `$${item.total_fee}`
+                                    : `$${item.total_fee.toFixed(1)}`
                                 : ''}
                         </Text>
                     </View>

+ 6 - 5
component/resultDetailPage/resultDetailPageComponent.tsx

@@ -104,6 +104,8 @@ const ResultDetailPageComponent = () => {
     const chargeStationAddress = params.chargeStationAddress as string;
     const availableConnectorsFromParams = params.availableConnectors;
     const imageSource = params.imageSource;
+    const stationLng = params.stationLng as string;
+    const stationLat = params.stationLat as string;
     const [isLoading, setIsLoading] = useState(true);
     // const chargeStationLat = params.chargeStationLat as string;
     // const chargeStationLng = params.chargeStationLng as string;
@@ -258,10 +260,9 @@ const ResultDetailPageComponent = () => {
     //     }
     // };
 
-    const handleNavigationPress = () => {
-        console.log('starting navigation press in resultDetail', coordinates);
-        if (coordinates) {
-            const { StationLat, StationLng } = coordinates;
+    const handleNavigationPress = (StationLat: string, StationLng: string) => {
+        console.log('starting navigation press in resultDetail', StationLat, StationLng);
+        if (StationLat && StationLng) {
             const label = encodeURIComponent(chargeStationName);
 
             const googleMapsUrl = `https://www.google.com/maps/search/?api=1&query=${StationLat},${StationLng}`;
@@ -375,7 +376,7 @@ const ResultDetailPageComponent = () => {
                                     <Text className="text-base ">路線</Text>
                                 </View>
                             }
-                            onPress={handleNavigationPress}
+                            onPress={() => handleNavigationPress(stationLat, stationLng)}
                             extendedStyle={{
                                 backgroundColor: '#E3F2F8',
                                 borderRadius: 61,

+ 49 - 5
component/searchPage/searchResultComponent.tsx

@@ -33,6 +33,38 @@ interface TabItem {
     lng: number;
 }
 
+const dummyTabItems: TabItem[] = [
+    {
+        imgURL: require('../../assets/dummyStationPicture.png'),
+        date: '今天',
+        time: '16:30',
+        chargeStationName: '觀塘偉業街充電站',
+        chargeStationAddress: '九龍觀塘偉業街143號地下',
+        distance: '400米',
+        latitude: 22.31337,
+        longitude: 114.21823
+    },
+    {
+        imgURL: require('../../assets/dummyStationPicture5.jpeg'),
+        date: '3月15',
+        time: '17:45',
+        chargeStationName: '香港沙頭角農莊',
+        chargeStationAddress: '香港沙頭角農莊停車場',
+        distance: '680米',
+        latitude: 22.53898,
+        longitude: 114.21319
+    },
+    {
+        imgURL: require('../../assets/dummyStationPicture4.jpeg'),
+        date: '3月15',
+        time: '17:45',
+        chargeStationName: '黃竹坑香葉道充電站',
+        chargeStationAddress: '黃竹坑香葉道44號地下',
+        distance: '680米',
+        latitude: 22.24839,
+        longitude: 114.16303
+    }
+];
 const SearchResultComponent = () => {
     const [region, setRegion] = useState<Region>({
         latitude: 22.302711, // Default to Hong Kong coordinates
@@ -47,9 +79,10 @@ const SearchResultComponent = () => {
     const snapPoints = useMemo(() => ['25%', '65%'], []);
     const mapRef = useRef<MapView>(null);
     const params = useLocalSearchParams();
-    const [filteredItems, setFilteredItems] = useState<TabItem[]>([]);
+
     const [isLoading, setIsLoading] = useState(true);
 
+    const [filteredItems, setFilteredItems] = useState<TabItem[]>([]);
     useEffect(() => {
         if (params.latitude && params.longitude) {
             setRegion({
@@ -83,7 +116,16 @@ const SearchResultComponent = () => {
             mapRef.current.animateToRegion(region, 1000);
         }
     }, [region]);
-
+    useEffect(() => {
+        if (searchInput === '') {
+            setFilteredItems([]);
+        } else {
+            const filteredData = dummyTabItems.filter((item) =>
+                item.chargeStationName.includes(searchInput.toLocaleUpperCase())
+            );
+            setFilteredItems(filteredData);
+        }
+    }, [searchInput]);
     if (errorMsg) {
         return (
             <View className="flex-1 justify-center items-center ">
@@ -140,8 +182,9 @@ const SearchResultComponent = () => {
                         lat: station.StationLat,
                         date: '今天',
                         stationID: station.StationID,
+
                         // imgURL: stationImages[station.StationID] || require('../../assets/dummyStationPicture.png'),
-                        imgURL: station.image,
+                        imgURL: station.image
                         // distance: distance !== null ? formatDistance(distance) : 'N/A'
                     };
                 })
@@ -157,6 +200,7 @@ const SearchResultComponent = () => {
         }
     }, [currentLocation]);
 
+    console.log('tabItems', tabItems);
     const formatDistance = (distanceInMeters: number): string => {
         if (distanceInMeters < 1000) {
             return `${Math.round(distanceInMeters)}米`;
@@ -296,8 +340,8 @@ const SearchResultComponent = () => {
                                                                 chargeStationAddress: item.chargeStationAddress,
                                                                 chargeStationID: item.stationID,
                                                                 chargeStationName: item.chargeStationName,
-                                                                // chargeStationLat: item.lat,
-                                                                // chargeStationLng: item.lng
+                                                                stationLat: item.lat,
+                                                                stationLng: item.lng
                                                             }
                                                         });
                                                     }}

+ 4 - 4
ios/Crazycharge.xcodeproj/project.pbxproj

@@ -370,11 +370,11 @@
 				);
 				OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
 				PRODUCT_BUNDLE_IDENTIFIER = hk.com.crazycharge;
-				PRODUCT_NAME = Crazycharge;
+				PRODUCT_NAME = "Crazycharge";
 				SWIFT_OBJC_BRIDGING_HEADER = "Crazycharge/Crazycharge-Bridging-Header.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = 1;
+				TARGETED_DEVICE_FAMILY = "1";
 				VERSIONING_SYSTEM = "apple-generic";
 			};
 			name = Debug;
@@ -398,10 +398,10 @@
 				);
 				OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
 				PRODUCT_BUNDLE_IDENTIFIER = hk.com.crazycharge;
-				PRODUCT_NAME = Crazycharge;
+				PRODUCT_NAME = "Crazycharge";
 				SWIFT_OBJC_BRIDGING_HEADER = "Crazycharge/Crazycharge-Bridging-Header.h";
 				SWIFT_VERSION = 5.0;
-				TARGETED_DEVICE_FAMILY = 1;
+				TARGETED_DEVICE_FAMILY = "1";
 				VERSIONING_SYSTEM = "apple-generic";
 			};
 			name = Release;

+ 1 - 1
ios/Crazycharge/Info.plist

@@ -21,7 +21,7 @@
     <key>CFBundlePackageType</key>
     <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
     <key>CFBundleShortVersionString</key>
-    <string>1.3.2</string>
+    <string>1.3.3</string>
     <key>CFBundleSignature</key>
     <string>????</string>
     <key>CFBundleURLTypes</key>

+ 1 - 1
ios/Crazycharge/Supporting/Expo.plist

@@ -9,7 +9,7 @@
     <key>EXUpdatesLaunchWaitMs</key>
     <integer>0</integer>
     <key>EXUpdatesRuntimeVersion</key>
-    <string>1.3.2</string>
+    <string>1.3.3</string>
     <key>EXUpdatesURL</key>
     <string>https://u.expo.dev/536e7cff-9f65-4894-ad9f-e4ef8de57e4e</string>
   </dict>

+ 4 - 1
service/chargeStationService.tsx

@@ -241,6 +241,7 @@ class ChargeStationService {
                 return response.data.data.map((station: any) => {
                     // const snapshotData = JSON.parse(station.snapshot);
                     const snapshotData = station.snapshot;
+                    
                     const availableConnectors = station.Equipments.reduce((count: number, equipment: any) => {
                         return (
                             count +
@@ -253,7 +254,9 @@ class ChargeStationService {
                         stationName: snapshotData.StationName,
                         availableConnectors: availableConnectors,
                         address: snapshotData.Address,
-                        image: station.image
+                        image: station.image,
+                        stationLng: snapshotData.StationLng,
+                        stationLat: snapshotData.StationLat
                     };
                 });
             }

+ 2 - 2
util/lib.tsx

@@ -38,7 +38,7 @@ export const convertToHKTime = (utcDateTimeString) => {
 export function formatToChineseDateTime(dateString: string): string {
     const date = new Date(dateString);
     // Add 8 hours for HK timezone
-    date.setHours(date.getHours() + 8);
+    date.setHours(date.getHours());
 
     const year = date.getFullYear();
     const month = date.getMonth() + 1;
@@ -49,7 +49,7 @@ export function formatToChineseDateTime(dateString: string): string {
     // Pad minutes with leading zero if needed
     const paddedMinutes = minutes.toString().padStart(2, '0');
 
-    return `${year}年${month}月${day}日  ${hours}:${paddedMinutes}`;
+    return `${month}月${day}日  ${hours}:${paddedMinutes}`;
 }
 // Example usage:
 // const utcDateString = "2024-08-22T09:00:00.000Z";