Skip to content

Commit

Permalink
fixed data, issue was duble insert map
Browse files Browse the repository at this point in the history
  • Loading branch information
Satora1 committed Oct 4, 2024
1 parent 203be0c commit 3557814
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 105 deletions.
234 changes: 132 additions & 102 deletions app/(root)/(tabs)/home.tsx
Original file line number Diff line number Diff line change
@@ -1,115 +1,145 @@
import RideCard from '@/components/RideCard'
import { useUser } from '@clerk/clerk-expo'
import { FlatList } from 'react-native'
import { FlatList, View, Text, Image, ActivityIndicator } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'
const recentRides = [
[
{
"ride_id": "1",
"origin_address": "Kathmandu, Nepal",
"destination_address": "Pokhara, Nepal",
"origin_latitude": "27.717245",
"origin_longitude": "85.323961",
"destination_latitude": "28.209583",
"destination_longitude": "83.985567",
"ride_time": 391,
"fare_price": "19500.00",
"payment_status": "paid",
"driver_id": 2,
"user_id": "1",
"created_at": "2024-08-12 05:19:20.620007",
"driver": {
"driver_id": "2",
"first_name": "David",
"last_name": "Brown",
"profile_image_url": "https://ucarecdn.com/6ea6d83d-ef1a-483f-9106-837a3a5b3f67/-/preview/1000x666/",
"car_image_url": "https://ucarecdn.com/a3872f80-c094-409c-82f8-c9ff38429327/-/preview/930x932/",
"car_seats": 5,
"rating": "4.60"
}
},
{
"ride_id": "2",
"origin_address": "Jalkot, MH",
"destination_address": "Pune, Maharashtra, India",
"origin_latitude": "18.609116",
"origin_longitude": "77.165873",
"destination_latitude": "18.520430",
"destination_longitude": "73.856744",
"ride_time": 491,
"fare_price": "24500.00",
"payment_status": "paid",
"driver_id": 1,
"user_id": "1",
"created_at": "2024-08-12 06:12:17.683046",
"driver": {
"driver_id": "1",
"first_name": "James",
"last_name": "Wilson",
"profile_image_url": "https://ucarecdn.com/dae59f69-2c1f-48c3-a883-017bcf0f9950/-/preview/1000x666/",
"car_image_url": "https://ucarecdn.com/a2dc52b2-8bf7-4e49-9a36-3ffb5229ed02/-/preview/465x466/",
"car_seats": 4,
"rating": "4.80"
}
},
{
"ride_id": "3",
"origin_address": "Zagreb, Croatia",
"destination_address": "Rijeka, Croatia",
"origin_latitude": "45.815011",
"origin_longitude": "15.981919",
"destination_latitude": "45.327063",
"destination_longitude": "14.442176",
"ride_time": 124,
"fare_price": "6200.00",
"payment_status": "paid",
"driver_id": 1,
"user_id": "1",
"created_at": "2024-08-12 08:49:01.809053",
"driver": {
"driver_id": "1",
"first_name": "James",
"last_name": "Wilson",
"profile_image_url": "https://ucarecdn.com/dae59f69-2c1f-48c3-a883-017bcf0f9950/-/preview/1000x666/",
"car_image_url": "https://ucarecdn.com/a2dc52b2-8bf7-4e49-9a36-3ffb5229ed02/-/preview/465x466/",
"car_seats": 4,
"rating": "4.80"
}
},
{
"ride_id": "4",
"origin_address": "Okayama, Japan",
"destination_address": "Osaka, Japan",
"origin_latitude": "34.655531",
"origin_longitude": "133.919795",
"destination_latitude": "34.693725",
"destination_longitude": "135.502254",
"ride_time": 159,
"fare_price": "7900.00",
"payment_status": "paid",
"driver_id": 3,
"user_id": "1",
"created_at": "2024-08-12 18:43:54.297838",
"driver": {
"driver_id": "3",
"first_name": "Michael",
"last_name": "Johnson",
"profile_image_url": "https://ucarecdn.com/0330d85c-232e-4c30-bd04-e5e4d0e3d688/-/preview/826x822/",
"car_image_url": "https://ucarecdn.com/289764fb-55b6-4427-b1d1-f655987b4a14/-/preview/930x932/",
"car_seats": 4,
"rating": "4.70"
import { icons, images } from "@/constants";

export default function Page() {
const recentRides = [
[
{
"ride_id": "1",
"origin_address": "Kathmandu, Nepal",
"destination_address": "Pokhara, Nepal",
"origin_latitude": "27.717245",
"origin_longitude": "85.323961",
"destination_latitude": "28.209583",
"destination_longitude": "83.985567",
"ride_time": 391,
"fare_price": "19500.00",
"payment_status": "paid",
"driver_id": 2,
"user_id": "1",
"created_at": "2024-08-12 05:19:20.620007",
"driver": {
"driver_id": "2",
"first_name": "David",
"last_name": "Brown",
"profile_image_url": "https://ucarecdn.com/6ea6d83d-ef1a-483f-9106-837a3a5b3f67/-/preview/1000x666/",
"car_image_url": "https://ucarecdn.com/a3872f80-c094-409c-82f8-c9ff38429327/-/preview/930x932/",
"car_seats": 5,
"rating": "4.60"
}
},
{
"ride_id": "2",
"origin_address": "Jalkot, MH",
"destination_address": "Pune, Maharashtra, India",
"origin_latitude": "18.609116",
"origin_longitude": "77.165873",
"destination_latitude": "18.520430",
"destination_longitude": "73.856744",
"ride_time": 491,
"fare_price": "24500.00",
"payment_status": "paid",
"driver_id": 1,
"user_id": "1",
"created_at": "2024-08-12 06:12:17.683046",
"driver": {
"driver_id": "1",
"first_name": "James",
"last_name": "Wilson",
"profile_image_url": "https://ucarecdn.com/dae59f69-2c1f-48c3-a883-017bcf0f9950/-/preview/1000x666/",
"car_image_url": "https://ucarecdn.com/a2dc52b2-8bf7-4e49-9a36-3ffb5229ed02/-/preview/465x466/",
"car_seats": 4,
"rating": "4.80"
}
},
{
"ride_id": "3",
"origin_address": "Zagreb, Croatia",
"destination_address": "Rijeka, Croatia",
"origin_latitude": "45.815011",
"origin_longitude": "15.981919",
"destination_latitude": "45.327063",
"destination_longitude": "14.442176",
"ride_time": 124,
"fare_price": "6200.00",
"payment_status": "paid",
"driver_id": 1,
"user_id": "1",
"created_at": "2024-08-12 08:49:01.809053",
"driver": {
"driver_id": "1",
"first_name": "James",
"last_name": "Wilson",
"profile_image_url": "https://ucarecdn.com/dae59f69-2c1f-48c3-a883-017bcf0f9950/-/preview/1000x666/",
"car_image_url": "https://ucarecdn.com/a2dc52b2-8bf7-4e49-9a36-3ffb5229ed02/-/preview/465x466/",
"car_seats": 4,
"rating": "4.80"
}
},
{
"ride_id": "4",
"origin_address": "Okayama, Japan",
"destination_address": "Osaka, Japan",
"origin_latitude": "34.655531",
"origin_longitude": "133.919795",
"destination_latitude": "34.693725",
"destination_longitude": "135.502254",
"ride_time": 159,
"fare_price": "7900.00",
"payment_status": "paid",
"driver_id": 3,
"user_id": "1",
"created_at": "2024-08-12 18:43:54.297838",
"driver": {
"driver_id": "3",
"first_name": "Michael",
"last_name": "Johnson",
"profile_image_url": "https://ucarecdn.com/0330d85c-232e-4c30-bd04-e5e4d0e3d688/-/preview/826x822/",
"car_image_url": "https://ucarecdn.com/289764fb-55b6-4427-b1d1-f655987b4a14/-/preview/930x932/",
"car_seats": 4,
"rating": "4.70"
}
}
}
]
]
]
export default function Page() {
const { user } = useUser()

const loading = false
console.log(recentRides)
return (
<SafeAreaView className='bg-general-500'>
<FlatList
data={recentRides?.slice(0, 5)}
data={recentRides[0]?.slice(0, 5)}
// data={[]}
renderItem={({ item }) => <RideCard ride={item} />}
className='px-5'
keyboardShouldPersistTaps="handled"
contentContainerStyle={{
paddingBottom: 100,
}}
ListEmptyComponent={() => (
<View className='flex flex-col items-center justify-center'>
{!loading ? (<>
<Image source={images.noResult} className='w-40 h-40'
alt='No recent rides found'
resizeMode='contain'
/>
<Text className='text-sm'>No recent Rides found</Text>
</>) : (
<ActivityIndicator size="small" color="#000"/> )}
</View>
)}
ListHeaderComponent={()=>(
<>
<View className='flex flex-row items-center justify-between my-5'>
<Text className='text-2xl'>
Welcome {user?.firstName || user?.emailAddresses[0].emailAddress}
</Text>
</View>
</>
)}
/>
</SafeAreaView>
)
Expand Down
6 changes: 3 additions & 3 deletions components/RideCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { icons } from "@/constants";
import { formatDate, formatTime } from "@/lib/utils";
import { Ride } from "@/types/type";

const RideCard = ({ ride }: { ride: Ride }) => {
const RideCard = ({ ride }: { ride: Ride }) => {
return (
<View className="flex flex-row items-center justify-center bg-white rounded-lg shadow-sm shadow-neutral-300 mb-3">
<View className="flex flex-col items-start justify-center p-3">
Expand Down Expand Up @@ -48,7 +48,7 @@ const RideCard = ({ ride }: { ride: Ride }) => {
Driver
</Text>
<Text className="text-md font-JakartaBold">
{ride.driver.first_name} {ride.driver.last_name}
{ride.driver?.first_name} {ride.driver?.last_name}
</Text>
</View>

Expand All @@ -57,7 +57,7 @@ const RideCard = ({ ride }: { ride: Ride }) => {
Car Seats
</Text>
<Text className="text-md font-JakartaBold">
{ride.driver.car_seats}
{ride.driver?.car_seats}
</Text>
</View>

Expand Down

0 comments on commit 3557814

Please sign in to comment.