mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 09:58:12 +00:00
enhance contract management features
- Update ContractActionsToolbar to streamline contract generation and signing processes. - Introduce getStaffRowAction for improved action handling in contract list rows. - Implement auto-generation of contracts upon final approval in useContracts hook. - Refactor BookingDetailPage to remove unnecessary container type property. - Add action buttons in ContractRequestsPage for better user interaction. - Simplify container types configuration in resources. - Remove unused properties from booking types. - Introduce ContractViewPage for staff and customer contract signing. - Enhance NewContractPage to validate document uploads before proceeding. - Improve StepDocuments to ensure required documents are uploaded.
This commit is contained in:
@@ -99,7 +99,6 @@ export interface BookingContainerView {
|
||||
containerType?: {
|
||||
label?: string;
|
||||
sizeFt?: number;
|
||||
isReefer?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -62,23 +62,22 @@ export function ContractActionsToolbar({
|
||||
}
|
||||
|
||||
const canAccept = status === "SUBMITTED";
|
||||
const canGenerate = ["APPROVED", "APPROVED_PENDING_SIGNATURE"].includes(
|
||||
status,
|
||||
);
|
||||
const canSign = ["CONTRACT_READY", "SIGNED_CUSTOMER"].includes(status);
|
||||
// The contract is generated automatically when the final approval lands. We
|
||||
// only surface a manual "Generate" fallback if that auto-generation failed —
|
||||
// i.e. the contract is approved but no document was produced yet.
|
||||
const needsManualGenerate =
|
||||
["APPROVED", "APPROVED_PENDING_SIGNATURE"].includes(status) &&
|
||||
!contract.contractGeneratedAt;
|
||||
// Signing now happens on the contract VIEW page (staff must open and read the
|
||||
// generated contract before signing) — no sign button in this toolbar.
|
||||
const canViewContract =
|
||||
["CONTRACT_READY", "SIGNED_CUSTOMER"].includes(status) &&
|
||||
Boolean(contract.contractGeneratedAt);
|
||||
const canCreateBooking =
|
||||
status === "CLEARANCE_READY_FOR_BOOKING" &&
|
||||
contract.customsClearingEnabled &&
|
||||
canCreateContractBooking(user);
|
||||
|
||||
const signStaff = () =>
|
||||
mutations.signContract.mutate({
|
||||
role: "STAFF",
|
||||
signatureImageBase64: "",
|
||||
signerDisplayName:
|
||||
user?.name?.en || user?.username || user?.email || "Staff",
|
||||
});
|
||||
|
||||
return (
|
||||
<SectionCard icon={Zap} title="Staff actions">
|
||||
<Stack gap="sm">
|
||||
@@ -117,27 +116,29 @@ export function ContractActionsToolbar({
|
||||
</>
|
||||
)}
|
||||
|
||||
{canGenerate && (
|
||||
{needsManualGenerate && (
|
||||
<Button
|
||||
fullWidth
|
||||
color="edr-green"
|
||||
variant="light"
|
||||
color="orange"
|
||||
leftSection={<Sparkles size={16} />}
|
||||
loading={mutations.generateContract.isPending}
|
||||
onClick={() => mutations.generateContract.mutate()}
|
||||
>
|
||||
Generate contract
|
||||
Re-generate contract
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{canSign && (
|
||||
{canViewContract && (
|
||||
<Button
|
||||
fullWidth
|
||||
color="edr-green"
|
||||
leftSection={<FileSignature size={16} />}
|
||||
loading={mutations.signContract.isPending}
|
||||
onClick={signStaff}
|
||||
onClick={() =>
|
||||
navigate(`/dashboard/contract-requests/${contract.id}/view`)
|
||||
}
|
||||
>
|
||||
Sign as staff
|
||||
View & sign contract
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -155,8 +156,8 @@ export function ContractActionsToolbar({
|
||||
)}
|
||||
|
||||
{!canAccept &&
|
||||
!canGenerate &&
|
||||
!canSign &&
|
||||
!needsManualGenerate &&
|
||||
!canViewContract &&
|
||||
!canCreateBooking && (
|
||||
<Text size="sm" c="dimmed">
|
||||
No staff actions available for this status. Monitor until the
|
||||
|
||||
Reference in New Issue
Block a user