Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit de1b8a9

Browse files
committed
update: component gift card
1 parent b71d831 commit de1b8a9

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/components/utils/GiftCard.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { Ionicons } from '@expo/vector-icons';
21
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';
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

79
interface GiftCardProps extends GiftIdea {
810
onEdit?: () => void;
9-
onDelete?: () => void;
1011
}
1112

1213
export 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

Comments
 (0)