resource-portal / frontend /src /planner /allocationActions.ts
Gowrisankar
Add Runn-style allocation menu actions and multi-select.
eed056f
import { format } from "date-fns";
import type { AllocationDragDraft } from "../components/projects/AllocationCreatePopover";
import type { Allocation } from "../types";
export function draftFromAllocation(allocation: Allocation): Pick<
AllocationDragDraft,
"person_id" | "start_date" | "end_date" | "allocation_pct" | "note"
> {
return {
person_id: allocation.person_id,
start_date: allocation.start_date,
end_date: allocation.end_date,
allocation_pct: allocation.allocation_pct,
note: allocation.note ?? undefined,
};
}
/** Extend assignment through the last visible planner day. */
export function endDateThroughVisibleRange(dayDates: Date[], startDate: string): string {
if (dayDates.length === 0) return startDate;
const last = format(dayDates[dayDates.length - 1], "yyyy-MM-dd");
return last >= startDate ? last : startDate;
}