Implement calendar deletion with right-click context menu

Added complete calendar deletion functionality including:
- Context menu component with right-click activation on calendar items
- Backend API endpoint for calendar deletion with CalDAV DELETE method
- Frontend integration with calendar list refresh after deletion
- Fixed URL construction to prevent double /dav.php path issue
- Added proper error handling and user feedback

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Connor Johnstone
2025-08-28 21:31:58 -04:00
parent f9c87369e5
commit c454104c69
9 changed files with 341 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ use serde::Deserialize;
use std::sync::Arc;
use chrono::Datelike;
use crate::{AppState, models::{CalDAVLoginRequest, AuthResponse, ApiError, UserInfo, CalendarInfo, CreateCalendarRequest, CreateCalendarResponse}};
use crate::{AppState, models::{CalDAVLoginRequest, AuthResponse, ApiError, UserInfo, CalendarInfo, CreateCalendarRequest, CreateCalendarResponse, DeleteCalendarRequest, DeleteCalendarResponse}};
use crate::calendar::{CalDAVClient, CalendarEvent};
#[derive(Deserialize)]
@@ -292,4 +292,35 @@ pub async fn create_calendar(
success: true,
message: "Calendar created successfully".to_string(),
}))
}
pub async fn delete_calendar(
State(state): State<Arc<AppState>>,
headers: HeaderMap,
Json(request): Json<DeleteCalendarRequest>,
) -> Result<Json<DeleteCalendarResponse>, ApiError> {
println!("🗑️ Delete calendar request received: path='{}'", request.path);
// Extract and verify token
let token = extract_bearer_token(&headers)?;
let password = extract_password_header(&headers)?;
// Validate request
if request.path.trim().is_empty() {
return Err(ApiError::BadRequest("Calendar path is required".to_string()));
}
// Create CalDAV config from token and password
let config = state.auth_service.caldav_config_from_token(&token, &password)?;
let client = CalDAVClient::new(config);
// Delete the calendar
client.delete_calendar(&request.path)
.await
.map_err(|e| ApiError::Internal(format!("Failed to delete calendar: {}", e)))?;
Ok(Json(DeleteCalendarResponse {
success: true,
message: "Calendar deleted successfully".to_string(),
}))
}