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-2848 - FE: Staff Edit Application in the Queue #1717

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
da8363c
feat: ORV2-2857 - Update DDL model of Receipt and Transaction
praju-aot Oct 21, 2024
ec7f9e5
Formatting
praju-aot Oct 23, 2024
c3ffe59
Refund to multiple payment methods
praju-aot Nov 7, 2024
f0dd2d8
Update DB version
praju-aot Nov 7, 2024
4d185c1
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 7, 2024
5fcae06
Receipt document generation
praju-aot Nov 7, 2024
86c02a3
Template changes and code review changes
praju-aot Nov 8, 2024
7a3146b
Update void endpoint to process refunds to multiple payment methods
praju-aot Nov 8, 2024
cdc8d3a
Code review Comments
praju-aot Nov 8, 2024
1cd396e
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 8, 2024
d2b5c29
Updated the version from 47 to 48
praju-aot Nov 8, 2024
1e7116a
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 8, 2024
9b8920d
Code merge conflicts
praju-aot Nov 13, 2024
14a7f0f
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 13, 2024
34cf1d1
Merge conflicts
praju-aot Nov 26, 2024
dad1677
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Nov 26, 2024
d857fde
Resolve code merge conflicts
praju-aot Dec 4, 2024
578e9ea
Code conflict review
praju-aot Dec 4, 2024
f7cd2d7
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Dec 4, 2024
78d73f5
Code merge conflicts
praju-aot Dec 5, 2024
85a1e57
remove need for ReviewApplicationInQueue and ApplicationInQueueReview…
glen-aot Dec 17, 2024
684a4cf
Merge remote-tracking branch 'origin/main'
glen-aot Dec 17, 2024
64ee0ef
Resolve code conflicts with main
praju-aot Dec 17, 2024
8d89736
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Dec 17, 2024
7c0a0b3
Pass claimant back to the FE
praju-aot Dec 17, 2024
039cb6e
create UnavailableApplicationModal
glen-aot Dec 18, 2024
90ff834
restore ApplicationInQueueReview component
glen-aot Dec 18, 2024
d0dd37b
explore claimed application error state
glen-aot Dec 23, 2024
d1feb4d
Resolve code conflict
praju-aot Jan 8, 2025
11e4e66
Merge remote-tracking branch 'origin/main' into ORV2-2857-be-refund-t…
praju-aot Jan 8, 2025
1bbf95b
Merge remote-tracking branch 'origin/ORV2-2857-be-refund-to-multiple-…
praju-aot Jan 8, 2025
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
5 changes: 4 additions & 1 deletion frontend/src/features/permits/ApplicationSteps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { ErrorBoundary } from "react-error-boundary";

import { ApplicationStepPage } from "./components/dashboard/ApplicationStepPage";
import { ErrorFallback } from "../../common/pages/ErrorFallback";
import { ApplicationStep, ApplicationStepContext } from "../../routes/constants";
import {
ApplicationStep,
ApplicationStepContext,
} from "../../routes/constants";

export const ApplicationSteps = React.memo(
({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import "../../../../common/components/dashboard/Dashboard.scss";
import { Banner } from "../../../../common/components/dashboard/components/banner/Banner";
import { ApplicationForm } from "../../pages/Application/ApplicationForm";
import { ApplicationContext } from "../../context/ApplicationContext";
import { ApplicationReview } from "../../pages/Application/ApplicationReview";
import { getCompanyIdFromSession } from "../../../../common/apiManager/httpRequestHandler";
import { Loading } from "../../../../common/pages/Loading";
import { ApplicationInQueueReview } from "../../../queue/components/ApplicationInQueueReview";
import { useApplicationForStepsQuery } from "../../hooks/hooks";
import { PERMIT_STATUSES } from "../../types/PermitStatus";
import {
Expand All @@ -25,12 +23,12 @@ import {
} from "../../types/PermitType";

import {
APPLICATION_STEP_CONTEXTS,
APPLICATION_STEPS,
ApplicationStep,
ApplicationStepContext,
ERROR_ROUTES,
} from "../../../../routes/constants";
import { ApplicationReview } from "../../pages/Application/ApplicationReview";

const displayHeaderText = (stepKey: ApplicationStep) => {
switch (stepKey) {
Expand Down Expand Up @@ -121,19 +119,19 @@ export const ApplicationStepPage = ({

const renderApplicationStep = () => {
if (applicationStep === APPLICATION_STEPS.REVIEW) {
return applicationStepContext === APPLICATION_STEP_CONTEXTS.QUEUE ? (
<ApplicationInQueueReview
return (
<ApplicationReview
applicationData={contextData.applicationData}
applicationStepContext={applicationStepContext}
/>
) : (
<ApplicationReview companyId={companyId} />
);
}

return (
<ApplicationForm
permitType={applicationPermitType}
companyId={companyId}
applicationStepContext={applicationStepContext}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
import { FormProvider } from "react-hook-form";
import { Navigate, useNavigate } from "react-router-dom";
import { useContext, useMemo, useState } from "react";
import { useContext, useEffect, useMemo, useState } from "react";
import dayjs from "dayjs";
import { isAxiosError } from "axios";

Expand Down Expand Up @@ -46,7 +47,10 @@ import {

import {
APPLICATIONS_ROUTES,
APPLICATION_QUEUE_ROUTES,
APPLICATION_STEPS,
APPLICATION_STEP_CONTEXTS,
ApplicationStepContext,
ERROR_ROUTES,
} from "../../../../routes/constants";

Expand All @@ -59,9 +63,11 @@ const FEATURE = "application";
export const ApplicationForm = ({
permitType,
companyId,
applicationStepContext,
}: {
permitType: PermitType;
companyId: number;
applicationStepContext: ApplicationStepContext;
}) => {
// Context to hold all of the application data related to the application
const applicationContext = useContext(ApplicationContext);
Expand Down Expand Up @@ -125,7 +131,8 @@ export const ApplicationForm = ({
applicationContext?.applicationData?.updatedDateTime,
);

const { mutateAsync: saveApplication } = useSaveApplicationMutation();
const { mutateAsync: saveApplication, error: saveApplicationError } =
useSaveApplicationMutation();
const snackBar = useContext(SnackBarContext);

// Show leave application dialog
Expand Down Expand Up @@ -198,13 +205,17 @@ export const ApplicationForm = ({
const vehicleData = serializePermitVehicleDetails(
data.permitData.vehicleDetails,
);
// TODO show UnavailableApplicationModal here
const savedVehicleDetails = await handleSaveVehicle(vehicleData);

// Save application before continuing
await onSaveApplication(
(permitId) => navigate(APPLICATIONS_ROUTES.REVIEW(permitId)),
savedVehicleDetails,
);
await onSaveApplication((permitId) => {
return navigate(
applicationStepContext === APPLICATION_STEP_CONTEXTS.QUEUE
? APPLICATION_QUEUE_ROUTES.REVIEW(companyId, permitId)
: APPLICATIONS_ROUTES.REVIEW(permitId),
);
}, savedVehicleDetails);
};

const onSaveSuccess = (savedApplication: Application, status: number) => {
Expand Down Expand Up @@ -242,7 +253,7 @@ export const ApplicationForm = ({
},
},
};

// TODO show UnavailableApplicationModal here
await saveApplication(
{
data: applicationToBeSaved,
Expand Down Expand Up @@ -350,6 +361,23 @@ export const ApplicationForm = ({
if (isUndefined(policyEngine)) return <Loading />;
if (isNull(policyEngine)) return <Navigate to={ERROR_ROUTES.UNEXPECTED} />;

// TODO we will need to handle errors when attempting to save an application which has been claimed by another user
// once the BE is updated to handle this
const [currentClaimant, setCurrentClaimant] = useState<string>("");

// const saveApplicationErrorStatus = saveApplicationError?.response?.status;

useEffect(() => {
console.log({ saveApplicationError });
// if (saveApplicationErrorStatus === 422) {
// setCurrentClaimant(
// saveApplicationError.response.data.error[0].additionalInfo
// .currentClaimant,
// );
// setShowUnavailableApplicationModal(true);
// }
}, [saveApplicationError]);

return (
<div className="application-form">
<ApplicationBreadcrumb applicationStep={APPLICATION_STEPS.DETAILS} />
Expand Down
Loading
Loading