import { Ionicons } from "@expo/vector-icons"; import { Pressable, StyleSheet, Text, View } from "react-native"; import { fonts, radii, spacing } from "@/constants/theme"; import { useAppTheme } from "@/contexts/ThemeContext"; import type { InvoiceStatus } from "@/lib/invoice-status"; type ActionItem = { key: string; title: string; subtitle?: string; icon: keyof typeof Ionicons.glyphMap; onPress: () => void; loading?: boolean; }; type InvoiceDetailActionsProps = { status: InvoiceStatus; clientEmail: string; onPaymentReminder?: () => void; paymentReminderLoading?: boolean; onUpdateStatus: () => void; updateStatusLoading?: boolean; onTrackTime: () => void; }; export function InvoiceDetailActions({ status, clientEmail, onPaymentReminder, paymentReminderLoading, onUpdateStatus, updateStatusLoading, onTrackTime, }: InvoiceDetailActionsProps) { const { colors } = useAppTheme(); const rows: ActionItem[] = []; if ((status === "sent" || status === "overdue") && onPaymentReminder) { rows.push({ key: "reminder", title: "Send payment reminder", subtitle: clientEmail ? `Nudge ${clientEmail}` : "Add a client email first", icon: "notifications-outline", onPress: onPaymentReminder, loading: paymentReminderLoading, }); } rows.push( { key: "status", title: "Update status", subtitle: "Draft, sent, or paid", icon: "swap-horizontal-outline", onPress: onUpdateStatus, loading: updateStatusLoading, }, { key: "timer", title: "Track time", subtitle: "Clock hours to this invoice", icon: "timer-outline", onPress: onTrackTime, }, ); return ( {rows.map((row, index) => ( {index > 0 ? ( ) : null} [styles.row, pressed && styles.rowPressed]} > {row.title} {row.subtitle ? ( {row.subtitle} ) : null} ))} ); } const styles = StyleSheet.create({ card: { borderWidth: 1, borderRadius: radii.lg, padding: spacing.md, gap: spacing.sm, }, list: { gap: 0, }, divider: { height: StyleSheet.hairlineWidth, marginVertical: spacing.xs, }, row: { flexDirection: "row", alignItems: "center", gap: spacing.sm, paddingVertical: spacing.sm, }, rowPressed: { opacity: 0.75, }, iconWrap: { width: 40, height: 40, borderRadius: radii.md, alignItems: "center", justifyContent: "center", }, copy: { flex: 1, gap: 2, minWidth: 0, }, title: { fontFamily: fonts.bodySemiBold, fontSize: 15, }, subtitle: { fontFamily: fonts.body, fontSize: 13, lineHeight: 18, }, });