Complete frontend migration to shared VEvent model
- Update frontend to use shared calendar-models library - Add display methods to VEvent for UI compatibility - Remove duplicate VEvent definitions in frontend - Fix JSON field name mismatch (dtstart/dtend vs start/end) - Create CalendarEvent type alias for backward compatibility - Resolve "missing field start" parsing error 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -5,10 +5,11 @@ use wasm_bindgen_futures::JsFuture;
|
||||
use web_sys::{Request, RequestInit, RequestMode, Response};
|
||||
use std::collections::HashMap;
|
||||
|
||||
// Import RFC 5545 compliant VEvent
|
||||
use crate::models::ical::VEvent;
|
||||
// Import RFC 5545 compliant VEvent from shared library
|
||||
use calendar_models::VEvent;
|
||||
|
||||
// Create type alias for smooth transition
|
||||
// Create type alias for backward compatibility
|
||||
pub type CalendarEvent = VEvent;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct EventReminder {
|
||||
@@ -44,56 +45,7 @@ pub struct CalendarInfo {
|
||||
pub color: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct CalendarEvent {
|
||||
pub uid: String,
|
||||
pub summary: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub start: DateTime<Utc>,
|
||||
pub end: Option<DateTime<Utc>>,
|
||||
pub location: Option<String>,
|
||||
pub status: EventStatus,
|
||||
pub class: EventClass,
|
||||
pub priority: Option<u8>,
|
||||
pub organizer: Option<String>,
|
||||
pub attendees: Vec<String>,
|
||||
pub categories: Vec<String>,
|
||||
pub created: Option<DateTime<Utc>>,
|
||||
pub last_modified: Option<DateTime<Utc>>,
|
||||
pub recurrence_rule: Option<String>,
|
||||
pub exception_dates: Vec<DateTime<Utc>>,
|
||||
pub all_day: bool,
|
||||
pub reminders: Vec<EventReminder>,
|
||||
pub etag: Option<String>,
|
||||
pub href: Option<String>,
|
||||
pub calendar_path: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub enum EventStatus {
|
||||
Tentative,
|
||||
Confirmed,
|
||||
Cancelled,
|
||||
}
|
||||
|
||||
impl Default for EventStatus {
|
||||
fn default() -> Self {
|
||||
EventStatus::Confirmed
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub enum EventClass {
|
||||
Public,
|
||||
Private,
|
||||
Confidential,
|
||||
}
|
||||
|
||||
impl Default for EventClass {
|
||||
fn default() -> Self {
|
||||
EventClass::Public
|
||||
}
|
||||
}
|
||||
// CalendarEvent, EventStatus, and EventClass are now imported from shared library
|
||||
|
||||
// ==================== V2 API MODELS ====================
|
||||
|
||||
@@ -228,15 +180,8 @@ impl CalendarService {
|
||||
year: i32,
|
||||
month: u32
|
||||
) -> Result<Vec<VEvent>, String> {
|
||||
// Fetch CalendarEvents first
|
||||
let calendar_events = self.fetch_events_for_month(token, password, year, month).await?;
|
||||
|
||||
// Convert to VEvent
|
||||
let vevents = calendar_events.into_iter()
|
||||
.map(|event| VEvent::from_calendar_event(&event))
|
||||
.collect();
|
||||
|
||||
Ok(vevents)
|
||||
// Since CalendarEvent is now a type alias for VEvent, just call the main method
|
||||
self.fetch_events_for_month(token, password, year, month).await
|
||||
}
|
||||
|
||||
pub async fn fetch_events_for_month(
|
||||
|
||||
Reference in New Issue
Block a user