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

Commit ca0d7f1

Browse files
Merge pull request #6 from fptqnk17/feature/integration
Feature/integration
2 parents d010b5b + a770469 commit ca0d7f1

File tree

14 files changed

+1145
-670
lines changed

14 files changed

+1145
-670
lines changed

src/app/(gifts)/detail-gift.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,16 @@ const DetailGiftScreen = () => {
3838

3939
useEffect(() => {
4040
const fetchRecipientName = async () => {
41-
const name = await findRecipientById(Number(recipient));
42-
setRecipientName(name);
41+
try {
42+
const recipientData = await findRecipientById(Number(recipient));
43+
if (recipientData) {
44+
setRecipientName(recipientData.name);
45+
} else {
46+
console.error('Recipient not found');
47+
}
48+
} catch (error) {
49+
console.error('Failed to fetch recipient name:', error);
50+
}
4351
};
4452

4553
fetchRecipientName();

src/app/(gifts)/edit-gift.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ const EditGiftScreen = () => {
7878
if (recipientData) {
7979
setRecipientName(recipientData.name);
8080
} else {
81-
const fetchedRecipientName = await findRecipientById(
82-
Number(recipient),
83-
);
84-
setRecipientName(fetchedRecipientName);
81+
const fetchedRecipient = await findRecipientById(Number(recipient));
82+
if (fetchedRecipient) {
83+
setRecipientName(fetchedRecipient.name);
84+
} else {
85+
console.error('Recipient not found');
86+
}
8587
}
8688
} catch (error) {
8789
console.error('Failed to fetch recipient name:', error);

src/app/(gifts)/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ const HomeScreen = () => {
204204

205205
<ScrollView style={styles.scrollView}>
206206
{filteredGifts.map((gift) => {
207-
if (!gift || !gift.id) {
207+
if (!gift || !gift.id || typeof gift !== 'object') {
208208
console.error('Invalid gift data:', gift);
209209
return null;
210210
}
@@ -213,12 +213,12 @@ const HomeScreen = () => {
213213
<GiftCard
214214
key={gift.id}
215215
id={gift.id}
216-
image={gift.image}
217-
title={gift.title}
218-
description={gift.description}
219-
price={gift.price}
220-
recipient={gift.recipient}
221-
selectedDate={gift.selectedDate}
216+
image={gift.image || ''}
217+
title={gift.title || ''}
218+
description={gift.description || ''}
219+
price={gift.price || 0}
220+
recipient={gift.recipient || ''}
221+
selectedDate={gift.selectedDate || ''}
222222
/>
223223
);
224224
})}

0 commit comments

Comments
 (0)