import { Avatar, Fab, Checkbox, Text } from 'components'; import { Container, Row, TouchableHighlight, TouchableWithoutFeedback } from 'components/layout'; import { MyProfileFragment } from 'expo-schema'; import { useProfile } from 'hooks'; import { Add, Close } from 'icons'; import { FC, useCallback } from 'react'; export const PreferredEmail: FC = ({ handleUpdate }) => { const { profile } = useProfile(); const isPreferred = useCallback( (email: string) => { return email === profile?.preferredEmail; }, [profile?.preferredEmail] ); const getColor = useCallback( (email: string) => { return email === profile?.preferredEmail ? 'title' : 'body'; }, [profile?.preferredEmail] ); const handleChangeEmail = useCallback( (email: string) => { handleUpdate({ preferredEmail: email } as MyProfileFragment); }, [handleUpdate] ); return ( {profile?.emails.map(({ email }) => { return ( handleChangeEmail(email)}> handleChangeEmail(email)} shapeVariant="circle" isActive={isPreferred(email)} sizeVariant="2-extra-small" colorVariant="success" /> {email} } /> ); })} } /> Add New Email ); }; type PreferredEmailProps = { handleUpdate: (profile: MyProfileFragment) => void; };