import { getDatabase, ref, remove } from "firebase/database";
// Function to reject (delete) a point of interest (POI)
/**
* The function `rejectPOI` removes a Point of Interest (POI) entry from the database based on its type
* and ID, displaying success or error alerts accordingly.
* @param poiType - poiType is a string that represents the type of point of interest (POI) being
* rejected and deleted from the database.
* @param poiId - The `poiId` parameter represents the unique identifier of the Point of Interest (POI)
* that you want to reject and delete from the database.
*/
export async function rejectPOI(poiType, poiId) {
const database = getDatabase();
try {
// Remove the POI entry from the database
await remove(ref(database, `newsuggestions/${poiType}/${poiId}`));
alert(
`The ${poiType} suggestion has been rejected and deleted successfully!`
);
} catch (error) {
alert(`Error rejecting and deleting the ${poiType} suggestion: ${error}`);
throw error;
}
}