This repository was archived by the owner on May 5, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,10 @@ import Modal from 'react-native-modal';
16
16
17
17
import Loading from '@/components/Loading' ;
18
18
import { addGift } from '@/features/gifts/giftSlice' ;
19
- import { fetchRecipients } from '@/features/recipients/recipientService' ;
19
+ import {
20
+ fetchRecipients ,
21
+ updateRecipient ,
22
+ } from '@/features/recipients/recipientService' ;
20
23
import { useAppDispatch , useAppSelector } from '@/redux/hooks' ;
21
24
import { uploadGiftThumbnail } from '@/services/uploadImage' ;
22
25
import { formatPrice } from '@/utils/priceUtils' ;
@@ -134,8 +137,14 @@ const AddGiftScreen = () => {
134
137
} ;
135
138
136
139
await dispatch ( addGift ( giftData ) ) . unwrap ( ) ;
137
- alert ( 'Gift added successfully!' ) ;
138
140
141
+ const selectedRecipient = recipients . find ( ( r ) => r . id === recipient ) ;
142
+ if ( selectedRecipient ) {
143
+ const updatedSpent = selectedRecipient . spent + parseFloat ( price ) ;
144
+ await updateRecipient ( recipient ! , { spent : updatedSpent } ) ;
145
+ }
146
+
147
+ alert ( 'Gift added successfully!' ) ;
139
148
router . push ( '/(gifts)' ) ;
140
149
} catch ( error ) {
141
150
console . error ( 'Error saving gift:' , error ) ;
You can’t perform that action at this time.
0 commit comments