Added DeleteAllEmail function
This commit is contained in:
@@ -253,3 +253,18 @@ export const getQRTips = async () => {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Function to delete all emails
|
||||||
|
export const deleteAllEmails = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiRequest({
|
||||||
|
method: 'put',
|
||||||
|
url: `${API_BASE_URL}${API_URL_GMAIL_DELETE_ALL_MESSAGES}`,
|
||||||
|
});
|
||||||
|
return response; // Assuming the response contains the message
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error deleting all emails:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -3,7 +3,7 @@ import { View, Text, StyleSheet, TouchableOpacity, Linking, Alert, Button } from
|
|||||||
import { useAuthenticator } from '@aws-amplify/ui-react-native';
|
import { useAuthenticator } from '@aws-amplify/ui-react-native';
|
||||||
import useFetchUserAttributes from '../hooks/useFetchUserAttributes';
|
import useFetchUserAttributes from '../hooks/useFetchUserAttributes';
|
||||||
import { fetchAuthSession, getCurrentUser, signInWithRedirect, signOut } from 'aws-amplify/auth';
|
import { fetchAuthSession, getCurrentUser, signInWithRedirect, signOut } from 'aws-amplify/auth';
|
||||||
import { deleteAllScannedHistories, getUserInfo } from '../api/qrCodeAPI'; // Import the API function
|
import { deleteAllEmails, deleteAllScannedHistories, getUserInfo } from '../api/qrCodeAPI'; // Import the API function
|
||||||
import { Buffer } from 'buffer';
|
import { Buffer } from 'buffer';
|
||||||
import { Ionicons } from '@expo/vector-icons';
|
import { Ionicons } from '@expo/vector-icons';
|
||||||
|
|
||||||
@@ -131,10 +131,20 @@ const SettingsScreen: React.FC = () => {
|
|||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteAllEmails = () => {
|
const handleDeleteAllEmails = async () => {
|
||||||
Alert.alert('Confirm Delete', 'Are you sure you want to delete all emails?', [
|
Alert.alert('Confirm Delete', 'Are you sure you want to delete all emails?', [
|
||||||
{ text: 'Cancel', style: 'cancel' },
|
{ text: 'Cancel', style: 'cancel' },
|
||||||
{ text: 'Delete', onPress: () => console.log('Delete all emails') }
|
{
|
||||||
|
text: 'Delete',
|
||||||
|
onPress: async () => {
|
||||||
|
try {
|
||||||
|
const response = await deleteAllEmails();
|
||||||
|
Alert.alert('Success', response.message);
|
||||||
|
} catch (error) {
|
||||||
|
Alert.alert('Error', 'Failed to delete all emails. Please try again.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -282,7 +292,7 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
deleteAllButton: {
|
deleteAllButton: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
backgroundColor: '#ff0000',
|
backgroundColor: '#ff5941',
|
||||||
borderRadius: 25,
|
borderRadius: 25,
|
||||||
paddingVertical: 10,
|
paddingVertical: 10,
|
||||||
paddingHorizontal: 20,
|
paddingHorizontal: 20,
|
||||||
|
|||||||
Reference in New Issue
Block a user