import React, { useMemo, useState } from "react"; import { View, Text, TouchableOpacity, ScrollView } from "react-native"; import { useLocalSearchParams, router } from "expo-router"; import { useRecipientsStore } from "~/lib/stores"; import ScreenWrapper from "~/components/ui/ScreenWrapper"; import BackButton from "~/components/ui/backButton"; import { Button } from "~/components/ui/button"; import { ROUTES } from "~/lib/routes"; import { LucideUser, LucideCreditCard, LucideCalendarClock, LucideChevronRight, } from "lucide-react-native"; function getInitials(name: string) { return name .split(" ") .map((word) => word.charAt(0).toUpperCase()) .slice(0, 2) .join(""); } export default function RecipDetail() { const { recipientId } = useLocalSearchParams<{ recipientId?: string }>(); const { recipients } = useRecipientsStore(); const recipient = useMemo( () => recipients.find((r) => r.id === recipientId), [recipients, recipientId] ); const initials = recipient ? getInitials(recipient.fullName) : "?"; const lowerName = recipient?.fullName.toLowerCase() ?? ""; const isBusiness = lowerName.includes("ltd") || lowerName.includes("plc") || lowerName.includes("inc") || lowerName.includes("company"); const clientType = isBusiness ? "Business" : "Individual"; // Dummy accounts for UI-only const accounts = useMemo( () => [ { id: "acc-1", bank: "Bank of Abyssinia", number: "***1234", primary: true, }, { id: "acc-2", bank: "Dashen Bank", number: "***5678", primary: false, }, ], [] ); // Dummy schedules for UI-only const schedules = useMemo( () => [ { id: "sch-1", label: "Every Monday · 10:00" }, { id: "sch-2", label: "Monthly, 1st · 09:00" }, ], [] ); const [showManageSchedules, setShowManageSchedules] = useState(false); const handlePayNow = () => { if (!recipient) return; router.push({ pathname: ROUTES.SEND_OR_REQUEST_MONEY, params: { recipientId: recipient.id, recipientName: recipient.fullName }, }); }; const handleViewTransactions = () => { if (!recipient) return; router.push({ pathname: ROUTES.HISTORY, params: { recipientId: recipient.id, recipientName: recipient.fullName }, }); }; if (!recipient) { return ( Recipient not found. ); } return ( {/* Header */} {initials} {recipient.fullName} {clientType} {recipient.phoneNumber} {/* Accounts Section */} Linked Accounts {accounts.map((acc) => ( {acc.bank} {acc.number} {acc.primary && ( Primary )} ))} {}} > Add Account {/* Schedules Section */} Payment Schedules {schedules.map((sch) => ( {sch.label} ))} setShowManageSchedules(true)} > Manage Schedules {/* Actions */} {/* Simple placeholder bottom sheet for Manage Schedules */} {showManageSchedules && ( Manage Schedules (UI only) This is a placeholder UI. Editing schedules will be wired to backend in a later phase. )} ); }