diff --git a/src/application/dtos/trash_dto.rs b/src/application/dtos/trash_dto.rs index 98760637..19b5e1c6 100755 --- a/src/application/dtos/trash_dto.rs +++ b/src/application/dtos/trash_dto.rs @@ -11,6 +11,12 @@ pub struct TrashedItemDto { pub original_path: String, pub trashed_at: DateTime, pub days_until_deletion: i64, + /// Human-readable category (e.g., "Image", "Folder", "Document") + pub category: String, + /// FontAwesome icon class for the file type + pub icon_class: String, + /// Special CSS class for icon styling (e.g., "image-icon", "pdf-icon") + pub icon_special_class: String, } /// Request to move an item to trash diff --git a/src/application/services/trash_service.rs b/src/application/services/trash_service.rs index c3323e23..91fae81b 100755 --- a/src/application/services/trash_service.rs +++ b/src/application/services/trash_service.rs @@ -2,6 +2,9 @@ use std::sync::Arc; use tracing::{debug, error, info, instrument, warn}; use uuid::Uuid; +use crate::application::dtos::display_helpers::{ + category_for, icon_class_for, icon_special_class_for, +}; use crate::application::dtos::trash_dto::TrashedItemDto; use crate::application::ports::storage_ports::{FileReadPort, FileWritePort}; use crate::application::ports::trash_ports::TrashUseCase; @@ -72,6 +75,23 @@ impl TrashService { // Calculate days_until_deletion before moving item fields let days_until_deletion = item.days_until_deletion(); + // Determine display fields based on item type + let (category, icon_class, icon_special_class) = match item.item_type() { + TrashedItemType::Folder => ( + "Folder".to_string(), + "fas fa-folder".to_string(), + "folder-icon".to_string(), + ), + TrashedItemType::File => { + let name = item.name(); + // Use empty MIME type to leverage extension fallback + let category = category_for(name, "").to_string(); + let icon_class = icon_class_for(name, "").to_string(); + let icon_special_class = icon_special_class_for(name, "").to_string(); + (category, icon_class, icon_special_class) + } + }; + TrashedItemDto { id: item.id().to_string(), original_id: item.original_id().to_string(), @@ -83,6 +103,9 @@ impl TrashService { original_path: item.original_path().to_string(), trashed_at: item.trashed_at(), days_until_deletion, + category, + icon_class, + icon_special_class, } } diff --git a/src/application/services/trash_service_test.rs b/src/application/services/trash_service_test.rs index 860a0881..9c3516ae 100755 --- a/src/application/services/trash_service_test.rs +++ b/src/application/services/trash_service_test.rs @@ -62,11 +62,32 @@ where FoR: FolderRepository, { async fn get_trash_items(&self, user_id: Uuid) -> Result> { + use crate::application::dtos::display_helpers::{ + category_for, icon_class_for, icon_special_class_for, + }; + let items = self.trash_repository.get_trash_items(&user_id).await?; Ok(items .into_iter() .map(|item| { let days_until_deletion = item.days_until_deletion(); + + // Determine display fields based on item type + let (category, icon_class, icon_special_class) = match item.item_type() { + TrashedItemType::Folder => ( + "Folder".to_string(), + "fas fa-folder".to_string(), + "folder-icon".to_string(), + ), + TrashedItemType::File => { + let name = item.name(); + let category = category_for(name, "").to_string(); + let icon_class = icon_class_for(name, "").to_string(); + let icon_special_class = icon_special_class_for(name, "").to_string(); + (category, icon_class, icon_special_class) + } + }; + TrashedItemDto { id: item.id().to_string(), original_id: item.original_id().to_string(), @@ -78,6 +99,9 @@ where original_path: item.original_path().to_string(), trashed_at: item.trashed_at(), days_until_deletion, + category, + icon_class, + icon_special_class, } }) .collect())