import {Category} from "@/models/category";
import {CategoryType} from "@/models/enums";
import {User} from "@/models/user";

async function fetchCategories(spaceId: number) {
    let categories : Category[] = []
    for (let i = 0; i < 10; i++) {
        categories.push({
            id: i,
            type: Math.floor(Math.random() * 2) === 0 ? CategoryType.INCOME : CategoryType.EXPENSE,
            name: `Category ${i}`,
            description: `Description of Category ${i}`,
            icon: "😇",
            createdBy: {
                id: i,
                username: `username_${i}`,
                firstName: `firstName ${i}`,
            } as User,
            createdAt: new Date(),
        } as Category)
    }
    return categories;
}

async function fetchCategory(spaceId: number, categoryId: number): Promise<Category> {
   return  {
        id: 1,
            type: Math.floor(Math.random() * 2) === 0 ? CategoryType.INCOME : CategoryType.EXPENSE,
        name: `Category ${1}`,
        description: `Description of Category ${1}`,
        icon: "😇",
        createdBy: {
        id: 1,
            username: `username_${1}`,
            firstName: `firstName ${1}`,
    } as User,
        createdAt: new Date(),
    } as Category
}

export const categoriesService  = {
    fetchCategories, fetchCategory
}