Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ORV2-2846: CV Client and Staff Applying for Motive-Fuel Permits #1791

Merged
merged 16 commits into from
Feb 10, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Show licensed GVW input for motive fuel permits, fix bug with using o…
…ut-of-sync special auth data for policy engine
zgong-gov committed Jan 28, 2025
commit c5fdb1027163b2ca3e7354272e880f5f08c371e8
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import {
} from "../../../../../common/types/common";

export const gvwLimit = (permitType: PermitType) => {
if (permitType === PERMIT_TYPES.STOS) {
if (permitType === PERMIT_TYPES.STOS || permitType === PERMIT_TYPES.MFP) {
return 63500;
}

Original file line number Diff line number Diff line change
@@ -26,8 +26,9 @@ export const getEligibleVehicleSubtypes = (
// result in an empty map returned.
const subtypesMap = policyEngine.getPermittableVehicleTypes(
permitType,
getDefaultRequiredVal('-', selectedCommodity),
getDefaultRequiredVal("-", selectedCommodity),
);

return new Set(
[
...getDefaultRequiredVal(
Original file line number Diff line number Diff line change
@@ -155,7 +155,6 @@ export const useApplicationFormContext = () => {
} = usePermitVehicles({
policyEngine,
permitType,
isLcvDesignated,
vehicleFormData,
allVehiclesFromInventory,
selectedLOAs: currentSelectedLOAs,
3 changes: 0 additions & 3 deletions frontend/src/features/permits/hooks/usePermitVehicles.ts
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@ export const usePermitVehicles = (
data: {
policyEngine: Policy;
permitType: PermitType;
isLcvDesignated: boolean;
vehicleFormData: PermitVehicleDetails;
allVehiclesFromInventory: (PowerUnit | Trailer)[];
selectedLOAs: PermitLOA[];
@@ -32,7 +31,6 @@ export const usePermitVehicles = (
const {
policyEngine,
permitType,
isLcvDesignated,
vehicleFormData,
allVehiclesFromInventory,
selectedLOAs,
@@ -51,7 +49,6 @@ export const usePermitVehicles = (
}, [
policyEngine,
permitType,
isLcvDesignated,
selectedCommodity,
]);

Original file line number Diff line number Diff line change
@@ -73,7 +73,9 @@ export const VehicleDetails = ({
onSetVehicle: (vehicleDetails: PermitVehicleDetails) => void;
onClearVehicle: (saveVehicle: boolean) => void;
}) => {
const powerUnitsOnly = permitType === PERMIT_TYPES.STOS;
const hideVehicleType = permitType === PERMIT_TYPES.STOS;
const disableVehicleType = permitType === PERMIT_TYPES.MFP;
const showGVW = permitType === PERMIT_TYPES.STOS || permitType === PERMIT_TYPES.MFP;
const vehicleType = vehicleFormData.vehicleType;

// Choose vehicle based on either Unit Number or Plate
@@ -96,7 +98,7 @@ export const VehicleDetails = ({
)
: undefined;

return Boolean(existingVehicle);
return disableVehicleType || Boolean(existingVehicle);
};

const disableVehicleTypeSelect = shouldDisableVehicleTypeSelect();
@@ -294,7 +296,7 @@ export const VehicleDetails = ({
disabled={isSelectedLOAVehicle}
/>

{!powerUnitsOnly ? (
{!hideVehicleType ? (
<CustomFormComponent
className="vehicle-details__input"
type="select"
@@ -348,7 +350,7 @@ export const VehicleDetails = ({
disabled={isSelectedLOAVehicle}
/>

{powerUnitsOnly ? (
{showGVW ? (
<CustomFormComponent
className="vehicle-details__input"
type="input"
11 changes: 6 additions & 5 deletions frontend/src/features/policy/hooks/usePolicyEngine.ts
Original file line number Diff line number Diff line change
@@ -18,12 +18,13 @@ export const usePolicyEngine = (specialAuthorizations?: SpecialAuthorizationData
if (isNull(policyConfiguration)) return null;
if (!policyConfiguration) return undefined;

return new Policy(policyConfiguration.policy);
}, [policyConfiguration]);
const policy = new Policy(policyConfiguration.policy);
if (specialAuthorizations) {
policy?.setSpecialAuthorizations(specialAuthorizations);
}

if (specialAuthorizations) {
policyEngine?.setSpecialAuthorizations(specialAuthorizations);
}
return policy;
}, [policyConfiguration, specialAuthorizations]);

return policyEngine;
};