diff --git a/app/(tabs)/payments.tsx b/app/(tabs)/payments.tsx index 54c5e89..5d3c927 100644 --- a/app/(tabs)/payments.tsx +++ b/app/(tabs)/payments.tsx @@ -460,6 +460,7 @@ export default function PaymentsTabScreen() { : paymentHistory.slice(0, 3) ).map((payment) => ( (null); const [isLoading, setIsLoading] = useState(true); - useLayoutEffect(() => { - navigation.setOptions({ - headerStyle: { - backgroundColor: "#F3F5F8", - }, - headerTitle: "Transaction Detail", - headerTitleStyle: { - fontSize: 18, - fontWeight: "600", - color: "#111827", - }, - headerLeft: () => ( - router.back()} - style={styles.backButton} - > - - - ), - }); - }, [navigation, router]); - useEffect(() => { fetchTransactionDetail(); }, [paymentId]); @@ -86,7 +65,7 @@ export default function TransactionDetailScreen() { try { setIsLoading(true); const response = await api.get( - `${BASE_URL}/api/v1/payment-history?id=${paymentId}` + `${BASE_URL}/api/v1/payment-history?page_number=1&page_size=10&id=${paymentId}` ); const result: TransactionResponse = response.data; @@ -140,12 +119,9 @@ export default function TransactionDetailScreen() { const getStatusText = (status: string) => { switch (status.toLowerCase()) { - case "success": - case "completed": case "confirmed": return "Payment successful"; case "failure": - case "failed": return "Payment failed"; case "pending": return "Payment pending"; @@ -154,86 +130,73 @@ export default function TransactionDetailScreen() { } }; - if (isLoading) { - return ( - + return ( + <> +
+ {isLoading ? ( - - ); - } - - if (!transactionData) { - return ( - + ) : !transactionData ? ( Transaction not found - - ); - } + ) : ( + + + + {getStatusIcon(transactionData.status)} + + + {formatCurrency(transactionData.amount)} + - return ( - - - {/* Status Icon */} - - {getStatusIcon(transactionData.status)} + + {getStatusText(transactionData.status)} + + + {formatDateTime(transactionData.transaction_date)} + + + + + Transaction Details + + + + + + + + + + + + + + - - {/* Amount */} - - {formatCurrency(transactionData.amount)} - - - {/* Status Text */} - - {getStatusText(transactionData.status)} - - - {/* Date Time */} - - {formatDateTime(transactionData.transaction_date)} - - - {/* Transaction Details Card */} - - Transaction Details - - - - - - - - - - - - - - - + )} + ); } @@ -253,9 +216,15 @@ const DetailRow = ({ ); const styles = StyleSheet.create({ + divider: { + height: 1, + width: "100%", + backgroundColor: "#E5E9F0", + }, container: { flex: 1, backgroundColor: "#F3F5F8", + paddingHorizontal: 16, }, loadingContainer: { flex: 1, @@ -272,9 +241,9 @@ const styles = StyleSheet.create({ color: "#6B7280", }, content: { - flex: 1, padding: 16, alignItems: "center", + backgroundColor: "#FCFCFC", }, backButton: { paddingLeft: 16, @@ -351,7 +320,6 @@ const styles = StyleSheet.create({ justifyContent: "space-between", alignItems: "flex-start", paddingVertical: 8, - borderBottomWidth: 1, borderBottomColor: "#E5E9F0", }, detailRowLast: { @@ -367,6 +335,6 @@ const styles = StyleSheet.create({ fontWeight: "600", color: "#252A34", flex: 1, - textAlign: "right", + textAlign: "left", }, }); diff --git a/components/Payments/PaymentHistoryCard.tsx b/components/Payments/PaymentHistoryCard.tsx index af57a17..354999d 100644 --- a/components/Payments/PaymentHistoryCard.tsx +++ b/components/Payments/PaymentHistoryCard.tsx @@ -1,4 +1,5 @@ -import { Text, View } from "react-native"; +import { useRouter } from "expo-router"; +import { Text, TouchableOpacity, View } from "react-native"; interface PaymentHistoryCardProps { date: string; @@ -6,9 +7,11 @@ interface PaymentHistoryCardProps { time: string; method: string; status: string; + id: number; } export default ({ + id, date, amount, time, @@ -16,6 +19,16 @@ export default ({ status, }: PaymentHistoryCardProps) => { //failure, confirmed, pending + + const router = useRouter(); + + const handlePress = () => { + router.push({ + pathname: "/payments/TransactionDetails", + params: { paymentId: id }, + }); + }; + console.log(status, "payment Status"); const getStatusStyle = (status: string) => { switch (status.toLowerCase()) { @@ -45,7 +58,8 @@ export default ({ const statusStyle = getStatusStyle(status); return ( - + // + {date} {amount} @@ -67,7 +81,8 @@ export default ({ )} - + + // ); }; @@ -83,6 +98,15 @@ const styles = StyleSheet.create({ paddingHorizontal: 12, flexDirection: "column", gap: "12", + + shadowColor: "#000", + shadowOffset: { + width: 0, + height: 1, + }, + shadowOpacity: 0.05, + shadowRadius: 2, + elevation: 1, }, paymentCardTop: { height: 20,