Files
kandev/apps/web/components/task/task-plan-implement.ts
T
2026-07-10 12:56:05 +01:00

30 lines
701 B
TypeScript

import type { TaskPlan } from "@/lib/types/http";
type PlanToolbarImplementArgs = {
draftContent: string;
plan: TaskPlan | null;
};
export type PlanToolbarImplementState = {
visible: boolean;
disabled: boolean;
disabledReason?: string;
};
export function getPlanToolbarImplementState({
draftContent,
plan,
}: PlanToolbarImplementArgs): PlanToolbarImplementState {
if (plan?.implementation_started_at) {
return {
visible: true,
disabled: true,
disabledReason: "This plan has already been sent for implementation.",
};
}
if (draftContent.trim() === "") {
return { visible: false, disabled: false };
}
return { visible: true, disabled: false };
}