64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import React from 'react';
|
|
import { View, Text, TouchableOpacity } from 'react-native';
|
|
import Icon from 'react-native-vector-icons/Ionicons';
|
|
import { useTheme } from '@theme';
|
|
import { getStyles } from './customerDetailHeader.styles';
|
|
import { CustomerDetailHeaderProps } from './customerDetailHeader.props';
|
|
import { getInitials, formatDate } from '@utils';
|
|
|
|
export const CustomerDetailHeader: React.FC<CustomerDetailHeaderProps> = ({
|
|
company,
|
|
fullname,
|
|
active,
|
|
datecreated,
|
|
email,
|
|
phonenumber,
|
|
website,
|
|
onEmailPress,
|
|
onPhonePress,
|
|
onWebsitePress,
|
|
}) => {
|
|
const { theme: colors } = useTheme();
|
|
const styles = getStyles(colors);
|
|
|
|
const displayName = company || fullname || 'Customer';
|
|
const initials = getInitials(displayName);
|
|
|
|
return (
|
|
<View style={styles.card}>
|
|
{/* Top Row: Avatar + Info + Active Badge */}
|
|
<View style={styles.topRow}>
|
|
<View style={styles.avatarCircle}>
|
|
<Text style={styles.avatarInitial}>{initials}</Text>
|
|
</View>
|
|
|
|
<View style={styles.info}>
|
|
<Text style={styles.name} numberOfLines={1}>{displayName}</Text>
|
|
{fullname && company ? (
|
|
<Text style={styles.company} numberOfLines={1}>{fullname}</Text>
|
|
) : null}
|
|
{datecreated ? (
|
|
<Text style={styles.dateText} numberOfLines={1}>
|
|
Added {formatDate(datecreated)}
|
|
</Text>
|
|
) : null}
|
|
</View>
|
|
|
|
<View
|
|
style={[
|
|
styles.statusBadge,
|
|
active === '1' ? styles.activeBadge : styles.inactiveBadge,
|
|
]}>
|
|
<Text
|
|
style={[
|
|
styles.statusText,
|
|
active === '1' ? styles.activeText : styles.inactiveText,
|
|
]}>
|
|
{active === '1' ? 'Active' : 'Inactive'}
|
|
</Text>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
);
|
|
};
|