/*
 * Book's Story — free and open-source Material You eBook reader.
 * Copyright (C) 2024-2026 Acclorite
 * SPDX-License-Identifier: GPL-3.0-only
 */

package org.dueattendant149.bookshelf.domain.use_case.category

import org.dueattendant149.bookshelf.core.log.logI
import org.dueattendant149.bookshelf.domain.model.library.Category
import org.dueattendant149.bookshelf.domain.repository.CategoryRepository
import javax.inject.Inject

private const val TAG = "DeleteCategory"

class DeleteCategoryUseCase @Inject constructor(
    private val categoryRepository: CategoryRepository
) {

    suspend operator fun invoke(category: Category) {
        logI(TAG, "Deleting category [${category.id}].")

        categoryRepository.deleteCategory(category).fold(
            onSuccess = {
                logI(TAG, "Successfully deleted category [${category.id}].")
            },
            onFailure = {
                logI(TAG, "Could not delete category [${category.id}] with error: ${it.message}")
            }
        )
    }
}