1
- import { Ionicons } from '@expo/vector-icons' ;
2
1
import { 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' ;
4
4
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' ;
6
8
7
9
interface GiftCardProps extends GiftIdea {
8
10
onEdit ?: ( ) => void ;
9
- onDelete ?: ( ) => void ;
10
11
}
11
12
12
13
export default function GiftCard ( {
@@ -19,6 +20,18 @@ export default function GiftCard({
19
20
selectedDate,
20
21
} : GiftCardProps ) {
21
22
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 ) ;
22
35
23
36
const handlePress = ( ) => {
24
37
router . push ( {
@@ -32,10 +45,10 @@ export default function GiftCard({
32
45
< Image source = { { uri : image } } style = { styles . image } />
33
46
< View style = { styles . content } >
34
47
< 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...' }
38
50
</ Text >
51
+ < Text style = { styles . date } > Happening on { formattedDate } </ Text >
39
52
</ View >
40
53
</ Pressable >
41
54
) ;
@@ -70,11 +83,6 @@ const styles = StyleSheet.create({
70
83
fontWeight : '600' ,
71
84
color : '#333333' ,
72
85
} ,
73
- description : {
74
- fontSize : 14 ,
75
- color : '#666666' ,
76
- marginTop : 4 ,
77
- } ,
78
86
recipient : {
79
87
fontSize : 14 ,
80
88
color : '#666666' ,
@@ -85,12 +93,4 @@ const styles = StyleSheet.create({
85
93
color : '#666666' ,
86
94
marginTop : 4 ,
87
95
} ,
88
- actions : {
89
- flexDirection : 'column' ,
90
- alignItems : 'center' ,
91
- justifyContent : 'space-evenly' ,
92
- } ,
93
- actionButton : {
94
- marginVertical : 8 ,
95
- } ,
96
96
} ) ;
0 commit comments