diff --git a/package.json b/package.json
index f146707..3e16775 100644
--- a/package.json
+++ b/package.json
@@ -12,6 +12,7 @@
"dependencies": {
"@gorhom/bottom-sheet": "^4.6.1",
"@hookform/resolvers": "^3.3.2",
+ "@react-native-async-storage/async-storage": "1.18.2",
"@react-native-community/netinfo": "9.3.10",
"@shopify/flash-list": "^1.6.4",
"@tanstack/react-query": "^5.22.2",
diff --git a/src/app/(protected)/(tabs)/index.tsx b/src/app/(protected)/(tabs)/index.tsx
index bc0050b..bac3502 100644
--- a/src/app/(protected)/(tabs)/index.tsx
+++ b/src/app/(protected)/(tabs)/index.tsx
@@ -12,7 +12,7 @@ import {
import { useJob } from '@/contexts/JobContext'
import { SafeAreaView } from 'react-native-safe-area-context'
-import { StyleSheet } from 'react-native'
+import { Dimensions, StyleSheet } from 'react-native'
import { AntDesign } from '@expo/vector-icons'
import { MaterialIcons } from '@expo/vector-icons'
import { useDriverInfo } from '@/hooks/useDriverInfo'
@@ -54,37 +54,15 @@ export default function Home() {
วินหมายเลข {driverInfo.info.no}
- {driveRequest?.id ? (
- router.push('/drive-request')}>
-
- กำลังดำเนินการ
-
-
-
-
-
-
-
- ) : (
-
- {isOnline ? 'กำลังรับงาน' : 'เริ่มรับงาน'}
-
-
- )}
-
+
+ {isOnline ? 'กำลังรับงาน' : 'เริ่มรับงาน'}
+
+
+ {driveRequest?.id && (
+
+ router.push('/drive-request')}>
+
+ กำลังดำเนินการ
+
+
+
+
+
+
+
+
+ )}
)
}
diff --git a/src/app/(protected)/drive-request/index.tsx b/src/app/(protected)/drive-request/index.tsx
index 43b4697..4282c62 100644
--- a/src/app/(protected)/drive-request/index.tsx
+++ b/src/app/(protected)/drive-request/index.tsx
@@ -44,7 +44,7 @@ export default function DriveRequestDetail() {
}
return (
-
+ <>
(
@@ -56,102 +56,109 @@ export default function DriveRequestDetail() {
),
}}
/>
-
- ข้อมูลเส้นทาง
+
-
+
+ ข้อมูลเส้นทาง
+
+
-
-
-
+
+
+
-
- ข้อมูลการโดยสาร
-
-
- รหัสเรียกรถ
- {driveRequest.id}
-
-
- วันที่
- {moment(driveRequest.createdAt).format('DD/MM/YYYY HH:mm')}
-
-
-
-
- ค่าโดยสารตามอัตรา
- {commonUtil.formatCurrency(driveRequest.priceByDistance)}
-
-
- ค่าเรียกรับบริการ
- {commonUtil.formatCurrency(driveRequest.serviceCharge)}
-
-
- ทั้งหมด
- {commonUtil.formatCurrency(driveRequest.total)}
-
-
-
+
+ ข้อมูลการโดยสาร
+
+
+ รหัสเรียกรถ
+ {driveRequest.id}
+
+
+ วันที่
+ {moment(driveRequest.createdAt).format('DD/MM/YYYY HH:mm')}
+
+
+
+
+ ค่าโดยสารตามอัตรา
+ {commonUtil.formatCurrency(driveRequest.priceByDistance)}
+
+
+ ค่าเรียกรับบริการ
+ {commonUtil.formatCurrency(driveRequest.serviceCharge)}
+
+
+ ทั้งหมด
+ {commonUtil.formatCurrency(driveRequest.total)}
+
+
+
-
- ข้อมูลผู้โดยสาร
-
-
-
- {driveRequest.user.firstName} {driveRequest.user.lastName}
-
-
-
- {commonUtil.formatPhoneNumber(driveRequest.user.phoneNumber)}
+
+ ข้อมูลผู้โดยสาร
+
+
+
+ {driveRequest.user.firstName} {driveRequest.user.lastName}
+
+
+
+ {commonUtil.formatPhoneNumber(driveRequest.user.phoneNumber)}
+
+
+
+
+ {newMessageReceived && (
+
+ )}
+
-
-
-
+
+
+
+ {driveRequest.status === DriveRequestSessionStatus.ON_GOING && (
+
+ )}
+ {driveRequest.status === DriveRequestSessionStatus.ARRIVED && (
+
-
- {driveRequest.status === DriveRequestSessionStatus.ON_GOING && (
- updateDriveRequestStatus(DriveRequestSessionStatus.ARRIVED)}
- />
- )}
- {driveRequest.status === DriveRequestSessionStatus.ARRIVED && (
- updateDriveRequestStatus(DriveRequestSessionStatus.PICKED_UP)}
- />
- )}
- {driveRequest.status === DriveRequestSessionStatus.PICKED_UP && (
-
- )}
-
+
+ >
)
}
diff --git a/src/components/drive-request/DriveRequestStatusChip.tsx b/src/components/drive-request/DriveRequestStatusChip.tsx
index c833ab7..e772793 100644
--- a/src/components/drive-request/DriveRequestStatusChip.tsx
+++ b/src/components/drive-request/DriveRequestStatusChip.tsx
@@ -38,7 +38,12 @@ export default function DriveRequestStatusChip({ status }: Props) {
const badgeStyles = getBadgeStyle(status)
return (
-
+
{driveRequestStatusText[status]}
diff --git a/src/utils/common.ts b/src/utils/common.ts
index 468bd80..4237db4 100644
--- a/src/utils/common.ts
+++ b/src/utils/common.ts
@@ -12,6 +12,13 @@ class CommonUtil {
formatPhoneNumber(value: string) {
return value.replace(/\+66/g, '0')
}
+
+ getDistanceText(distance: number) {
+ if (distance < 1000) {
+ return `${Math.floor(distance)} เมตร`
+ }
+ return `${Math.round(distance / 1000)} กม.`
+ }
}
export const commonUtil = new CommonUtil()
diff --git a/yarn.lock b/yarn.lock
index e80f089..563c2b9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1773,6 +1773,13 @@
"@babel/runtime" "^7.13.10"
"@radix-ui/react-compose-refs" "1.0.0"
+"@react-native-async-storage/async-storage@1.18.2":
+ version "1.18.2"
+ resolved "https://registry.yarnpkg.com/@react-native-async-storage/async-storage/-/async-storage-1.18.2.tgz#ec8fd487a0b6c9500b43ece4b8779d1561f12e91"
+ integrity sha512-dM8AfdoeIxlh+zqgr0o5+vCTPQ0Ru1mrPzONZMsr7ufp5h+6WgNxQNza7t0r5qQ6b04AJqTlBNixTWZxqP649Q==
+ dependencies:
+ merge-options "^3.0.4"
+
"@react-native-community/cli-clean@11.3.10":
version "11.3.10"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-11.3.10.tgz#70d14dd998ce8ad532266b36a0e5cafe22d300ac"
@@ -4787,6 +4794,11 @@ is-path-inside@^3.0.2:
resolved "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz"
integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==
+is-plain-obj@^2.1.0:
+ version "2.1.0"
+ resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287"
+ integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==
+
is-plain-object@^2.0.4:
version "2.0.4"
resolved "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz"
@@ -5370,6 +5382,13 @@ memory-cache@~0.2.0:
resolved "https://registry.npmjs.org/memory-cache/-/memory-cache-0.2.0.tgz"
integrity sha512-OcjA+jzjOYzKmKS6IQVALHLVz+rNTMPoJvCztFaZxwG14wtAW7VRZjwTQu06vKCYOxh4jVnik7ya0SXTB0W+xA==
+merge-options@^3.0.4:
+ version "3.0.4"
+ resolved "https://registry.yarnpkg.com/merge-options/-/merge-options-3.0.4.tgz#84709c2aa2a4b24c1981f66c179fe5565cc6dbb7"
+ integrity sha512-2Sug1+knBjkaMsMgf1ctR1Ujx+Ayku4EdJN4Z+C2+JzoeF7A3OZ9KM2GY0CpQS51NR61LTurMJrRKPhSs3ZRTQ==
+ dependencies:
+ is-plain-obj "^2.1.0"
+
merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz"