/
ViewProperty.js
72 lines (66 loc) · 2.67 KB
/
ViewProperty.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { Header, ActionBar, SubmitBar } from "@egovernments/digit-ui-react-components";
import React, {useEffect} from "react";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import { useLocation, Link } from "react-router-dom";
import ApplicationDetails from "../../../../templates/ApplicationDetails";
/**
* Page which renders a
* Generic property screen using property id and tenant id
*
* @author jagankumar-egov
*
* @example
* for employee
* digit-ui/employee/commonpt/view-property?propertyId={propertyId}&tenantId={tenantId}
*
* for citizen
* digit-ui/citizen/commonpt/view-property?propertyId={propertyId}&tenantId={tenantId}
*
* @returns {Screen} Property Details screen
*/
const ViewProperty = () => {
const { t } = useTranslation();
const { propertyId, tenantId, redirectToUrl } = Digit.Hooks.useQueryParams();
const { isLoading, data: applicationDetails } = Digit.Hooks.pt.useGenericViewProperty(t, tenantId, propertyId, {});
const { state } = useLocation();
const history = useHistory();
let workflowDetails = {};
const onSubmit = () => {
const scrollConst = redirectToUrl?.includes("employee/tl") ? 1600 : 300;
setTimeout(() => window.scrollTo(0, scrollConst), 400);
return history.push(`${redirectToUrl}?propertyId=${propertyId}&tenantId=${applicationDetails?.tenantId || tenantId}${state?.data?.applicationDetails?.applicationStatus === "PENDING_FOR_FIELD_INSPECTION" ? `&applicationNumber=${state?.data?.applicationDetails?.applicationNo}&service=${state?.data?.applicationDetails?.applicationData?.serviceType}`:``}`, { ...state });
};
useEffect(() => {
if(sessionStorage.getItem("isCreateEnabledEmployee") === "true")
{
sessionStorage.removeItem("isCreateEnabledEmployee");
history.replace("/digit-ui/employee");
}
else
sessionStorage.removeItem("isCreateEnabledEmployee");
})
return (
<div>
<div>
<Header>{t("PT_PROPERTY_INFO_HEADER")}</Header>
</div>
<ApplicationDetails
applicationDetails={applicationDetails}
isLoading={isLoading}
isDataLoading={isLoading}
workflowDetails={workflowDetails}
applicationData={applicationDetails?.applicationData}
moduleCode="PT"
/>
{window.location.href.includes("redirectToUrl") && applicationDetails?.applicationData?.status !== "INACTIVE" && (
<ActionBar style={{ display: "flex", justifyContent: "flex-end", alignItems: "baseline" }}>
<div>
<SubmitBar label={t("PT_ADD_PROPERTY_TO_APP")} onSubmit={() => onSubmit()} />
</div>
</ActionBar>
)}
</div>
);
};
export default ViewProperty;