-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
201 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React from "react"; | ||
import { ActivityIndicator } from "react-native"; | ||
import { | ||
AnimatedImage, | ||
Avatar, | ||
BorderRadiuses, | ||
Card, | ||
Text, | ||
View, | ||
} from "react-native-ui-lib"; | ||
import { Link } from "expo-router"; | ||
import { api } from "@/utils/api"; | ||
import colors from "@/utils/colors"; | ||
import rupiahFormatter from "@/utils/rupiahFormatter"; | ||
import { FlashList } from "@shopify/flash-list"; | ||
|
||
export default function OrdersScreen() { | ||
const { data, refetch, isFetching } = api.order.getOrders.useQuery(); | ||
|
||
const getStatus = (status: string) => { | ||
switch (status) { | ||
case "pending": | ||
return "Menunggu pembayaran"; | ||
case "accepted": | ||
return "Diproses"; | ||
case "cancelled": | ||
return "Dibatalkan"; | ||
default: | ||
return "Menunggu konfirmasi"; | ||
} | ||
}; | ||
|
||
return ( | ||
<View bg-white br50 flex padding-s4 className="rounded-b-none"> | ||
<FlashList | ||
data={data} | ||
numColumns={1} | ||
estimatedItemSize={200} | ||
onRefresh={() => refetch()} | ||
refreshing={isFetching} | ||
ListEmptyComponent={ | ||
<Text text70BO center marginT-s6> | ||
Tidak ada pembelian | ||
</Text> | ||
} | ||
renderItem={({ item }) => { | ||
return ( | ||
<Link | ||
asChild | ||
href={{ | ||
pathname: "/(app)/order/[orderId]", | ||
params: { | ||
orderId: item.id, | ||
}, | ||
}} | ||
> | ||
<Card | ||
padding-s4 | ||
borderRadius={BorderRadiuses.br40} | ||
className="border-primary mb-4 space-y-4 border" | ||
> | ||
<View className="border-primary border-b pb-4"> | ||
<View row spread centerV> | ||
<View row className="space-x-2"> | ||
<Avatar | ||
source={{ | ||
uri: item.users?.imageUrl, | ||
}} | ||
animate | ||
name={item.users?.name} | ||
useAutoColors | ||
size={36} | ||
/> | ||
<View> | ||
<Text text80>{item.users?.name}</Text> | ||
<Text text90R>{item.users.major}</Text> | ||
</View> | ||
</View> | ||
<View bg-secondary {...{ "bg-red30": item.status === "cancelled" }} padding-s1 br20> | ||
<Text text100BO white> | ||
{getStatus(item.status)} | ||
</Text> | ||
</View> | ||
</View> | ||
</View> | ||
<View row centerV className="space-x-4"> | ||
<AnimatedImage | ||
source={{ uri: item.products.image }} | ||
height={100} | ||
aspectRatio={1} | ||
borderRadius={BorderRadiuses.br60} | ||
loader={<ActivityIndicator color={colors.secondary} />} | ||
// style={{ flex: 1 }} | ||
/> | ||
<View> | ||
<Text text70 primary> | ||
{item.products.name} | ||
</Text> | ||
<Text text80 primary> | ||
{rupiahFormatter(item.products.price)} | ||
</Text> | ||
</View> | ||
</View> | ||
</Card> | ||
</Link> | ||
); | ||
}} | ||
/> | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.