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';
1616
1717import Loading from '@/components/Loading' ;
1818import { addGift } from '@/features/gifts/giftSlice' ;
19- import { fetchRecipients } from '@/features/recipients/recipientService' ;
19+ import {
20+ fetchRecipients ,
21+ updateRecipient ,
22+ } from '@/features/recipients/recipientService' ;
2023import { useAppDispatch , useAppSelector } from '@/redux/hooks' ;
2124import { uploadGiftThumbnail } from '@/services/uploadImage' ;
2225import { formatPrice } from '@/utils/priceUtils' ;
@@ -134,8 +137,14 @@ const AddGiftScreen = () => {
134137 } ;
135138
136139 await dispatch ( addGift ( giftData ) ) . unwrap ( ) ;
137- alert ( 'Gift added successfully!' ) ;
138140
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!' ) ;
139148 router . push ( '/(gifts)' ) ;
140149 } catch ( error ) {
141150 console . error ( 'Error saving gift:' , error ) ;
You can’t perform that action at this time.
0 commit comments