'use server';
import { revalidatePath } from 'next/cache';
import { resolve } from '../../lib/server-container.js';
export async function updateApplication(id, fields) {
    if (!id?.trim()) {
        return { error: 'Application ID is required' };
    }
    try {
        const useCase = resolve('UpdateApplicationUseCase');
        await useCase.execute(id, fields);
        // Refresh server components that read the application — the
        // application page itself, and the dashboard graph data.
        revalidatePath(`/application/${id}`);
        revalidatePath('/');
        return {};
    }
    catch (error) {
        const message = error instanceof Error ? error.message : 'Failed to update application';
        return { error: message };
    }
}
