'use server';
import { resolve } from '../../lib/server-container.js';
export async function logTimeEntry(workItemId, durationMinutes, note) {
    try {
        const useCase = resolve('LogTimeEntryUseCase');
        const result = await useCase.execute(workItemId, durationMinutes, note);
        if (!result.ok)
            return { error: result.error };
        return { timeEntry: result.timeEntry };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to log time entry';
        return { error: message };
    }
}
export async function listTimeEntries(workItemId) {
    try {
        const useCase = resolve('ListTimeEntriesUseCase');
        const result = await useCase.execute(workItemId);
        return { timeEntries: result.timeEntries, totalMinutes: result.totalMinutes };
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to list time entries';
        return { error: message };
    }
}
export async function deleteTimeEntry(id) {
    try {
        const useCase = resolve('DeleteTimeEntryUseCase');
        const result = await useCase.execute(id);
        if (!result.ok)
            return { error: result.error };
        return {};
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to delete time entry';
        return { error: message };
    }
}
