import {Target} from "@/models/targets";
import {TargetType} from "@/models/enums";
import {User} from "@/models/user";

async function fetchTargets(spaceId: number): Promise<Target[]> {
    const targets = [];
    for (var i = 0; i < 10; i++) {
        const rand = Math.floor(Math.random() * 5);
        const now = new Date();
        const amount = Math.floor(Math.random() * 100000);
        now.setDate(Math.floor(Math.random() * 30))
        targets.push({
            id: i,
            type: rand == 1 ? TargetType.AUTO : rand == 2 ? TargetType.LEISURE : rand == 3 ? TargetType.VACATION : rand == 4 ? TargetType.GOODS : TargetType.OTHER,
            name: `Target ${i}`,
            description: `Target ${i} description`,
            amount: amount,
            currentAmount: Math.floor(Math.random() * amount),
            date: now,
            components: [],
            transactions: [],
            createdBy: {} as User,
            createdAt: new Date(),
            updatedBy: {} as User,
            updatedAt: new Date(),
        } as Target)
    }
    return targets;
}

export const targetService = {
    fetchTargets
};