1- import { Ionicons } from '@expo/vector-icons' ;
21import { useRouter } from 'expo-router' ;
3- import { Alert , Image , Pressable , StyleSheet , Text , View } from 'react-native' ;
2+ import { useEffect , useState } from 'react' ;
3+ import { Image , Pressable , StyleSheet , Text , View } from 'react-native' ;
44
5- import { GiftIdea } from '@/models/GiftIdea' ;
5+ import { GiftIdea } from '@/features/gifts/types' ;
6+ import { findRecipientById } from '@/features/recipients/recipientService' ;
7+ import { formatDate } from '@/utils/dateUtils' ;
68
79interface GiftCardProps extends GiftIdea {
810 onEdit ?: ( ) => void ;
9- onDelete ?: ( ) => void ;
1011}
1112
1213export default function GiftCard ( {
@@ -19,6 +20,18 @@ export default function GiftCard({
1920 selectedDate,
2021} : GiftCardProps ) {
2122 const router = useRouter ( ) ;
23+ const [ recipientName , setRecipientName ] = useState < string | null > ( null ) ;
24+
25+ useEffect ( ( ) => {
26+ const fetchRecipientName = async ( ) => {
27+ const name = await findRecipientById ( Number ( recipient ) ) ;
28+ setRecipientName ( name ) ;
29+ } ;
30+
31+ fetchRecipientName ( ) ;
32+ } , [ recipient ] ) ;
33+
34+ const formattedDate = formatDate ( selectedDate ) ;
2235
2336 const handlePress = ( ) => {
2437 router . push ( {
@@ -32,10 +45,10 @@ export default function GiftCard({
3245 < Image source = { { uri : image } } style = { styles . image } />
3346 < View style = { styles . content } >
3447 < Text style = { styles . title } > { title } </ Text >
35- < Text style = { styles . recipient } > for { recipient } </ Text >
36- < Text style = { styles . date } >
37- Happening on { new Date ( selectedDate ) . toLocaleDateString ( ) }
48+ < Text style = { styles . recipient } >
49+ for { recipientName || 'Loading...' }
3850 </ Text >
51+ < Text style = { styles . date } > Happening on { formattedDate } </ Text >
3952 </ View >
4053 </ Pressable >
4154 ) ;
@@ -70,11 +83,6 @@ const styles = StyleSheet.create({
7083 fontWeight : '600' ,
7184 color : '#333333' ,
7285 } ,
73- description : {
74- fontSize : 14 ,
75- color : '#666666' ,
76- marginTop : 4 ,
77- } ,
7886 recipient : {
7987 fontSize : 14 ,
8088 color : '#666666' ,
@@ -85,12 +93,4 @@ const styles = StyleSheet.create({
8593 color : '#666666' ,
8694 marginTop : 4 ,
8795 } ,
88- actions : {
89- flexDirection : 'column' ,
90- alignItems : 'center' ,
91- justifyContent : 'space-evenly' ,
92- } ,
93- actionButton : {
94- marginVertical : 8 ,
95- } ,
9696} ) ;
0 commit comments