import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
import { hasPreparationChanges } from '@/lib/requisition-history';
import type { WorkContextState } from '@/types/work-context';
import { Head, router, useForm, usePage } from '@inertiajs/react';
import {
FormErrors,
Panel,
PageTitle,
controlClass,
} from '@/components/procurement';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { money } from '@/types/procurement';
type Policy = {
id: number;
created_by: number;
revision: number;
status: string;
mode: string;
scope: string;
currency: string;
ceiling_minor: number;
includes_tax: boolean;
valid_from: string;
valid_until: string;
reason: string;
};
type Review = {
id: number;
investment_policy_id: number;
reviewed_by: number;
decision: string;
reason: string;
};
function useInvestmentIdentity() {
const { auth, workContext, canManage, organizationAccess } =
usePage().props;
const context = workContext as WorkContextState | null | undefined;
const access = organizationAccess as { permissions?: string[] } | null;
return `investment:${auth.user?.tenant_id}:${auth.user?.id}:${context?.active ?? 'legacy'}:${canManage === true}:${[...(access?.permissions ?? [])].sort().join(',')}`;
}
function Proposal({ previousId }: { previousId: number }) {
const identity = `${useInvestmentIdentity()}:proposal:${previousId}`;
return (