Commit 3d36ff1c authored by pramod.nichelabs's avatar pramod.nichelabs

auction delete functionality added

parent 5f01fe02
......@@ -6,6 +6,7 @@ import { AppContainer } from '../container/container';
import themeColors from '../assets/colors';
import { AuctionBottomTab } from '../Navigations/AuctionBottomTab';
import { MaterialIcons } from '@expo/vector-icons';
import Toast from 'react-native-root-toast';
const UserAuctionListScreen = ({navigation}) => {
const [auctions, setAuctions] = useState([]);
......@@ -19,6 +20,35 @@ const UserAuctionListScreen = ({navigation}) => {
})
}, [])
const handleDelete = (auctionId) => {
const url = "http://127.0.0.1:8085/auctions/" + auctionId
axios.delete(url)
.then( async function (response) {
if (response.data.message === 'Deleted!!') {
const successMsg = Toast.show('Your auction has been deleted successfully', {
duration: Toast.durations.LONG,
});
setTimeout(function hideToast() {
Toast.hide(successMsg);
}, 1000);
navigation.navigate('AuctionHomeScreen');
} else {
const errMsg = Toast.show('Auction Deletion Failed', {
duration: Toast.durations.LONG,
});
setTimeout(function hideToast() {
Toast.hide(errMsg);
}, 1000);
}
}).catch(function (error) {
const errMsg = Toast.show('Auction Deletion Failed', {
duration: Toast.durations.LONG,
});
setTimeout(function hideToast() {
Toast.hide(errMsg);
}, 1000);
})
}
return (
<View style={styles.container}>
<AppContainer>
......@@ -36,7 +66,7 @@ const UserAuctionListScreen = ({navigation}) => {
navigation.navigate("AuctionDetailScreen", {
auctionObject: auction})
}
onDelete={() => console.log('delete')}/>
onDelete={() => handleDelete(auction._id)}/>
)
})}
</ScrollView>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment