...
Code Block |
---|
import React ,{useState, useEffect}from "react"; import { format } from "date-fns"; import { Link } from "react-router-dom"; import { Loader } from "@egovernments/digit-ui-react-components"; import ApplicationTable from "./ApplicationTable"; import EventLink from "./EventLink"; import axios from 'axios'; import Search from "./Search"; import DropdownUlb from "./DropdownUlb"; import Filter from "./Filter"; const DesktopInbox = ({ isLoading, t, onSearch, parentRoute, title, iconName, links, globalSearch, searchFields, searchParams, onFilterChange, pageSizeLimit, totalRecords, currentPage, onNextPage, onPrevPage, onPageSizeChange }) => { const [data, setData] = useState([]); useEffect(() => { (async () => { const result = await axios("https://62f0e3e5e2bca93cd23f2ada.mockapi.io/birth"); setData(result.data); console.log("gooo" ,result.data); })(); }, []); const columns = React.useMemo(() => { return [ { Header: t("Baby's First Name"), accessor: "babyFirstName", Cell: ({ row }) => { return ( <div> <span className="link"> <Link to={`details/${row.original.id}`}>{row.original["babyFirstName"]}</Link> </span> </div> ); }, }, { Header: "Baby's Last Name", accessor: "babyLastName" }, { Header: "City", accessor: "permanentCity" }, { Header: "Hospital Name", accessor: "hospitalName" }, ] }) let result; if (isLoading) { result = <Loader /> } else if (data?.length > 0) { result = <ApplicationTable t={t} data={data} columns={columns} globalSearch={globalSearch} onSearch={searchParams} pageSizeLimit={pageSizeLimit} totalRecords={totalRecords} currentPage={currentPage} onNextPage={onNextPage} onPrevPage={onPrevPage} onPageSizeChange={onPageSizeChange} getCellProps={(cellInfo) => { return { style: { minWidth: cellInfo.column.Header === t("ES_INBOX_APPLICATION_NO") ? "240px" : "", padding: "20px 18px", fontSize: "16px", }, }; }} /> } return ( <div className="inbox-container"> <div className="filters-container"> <EventLink title={"Birth-registration"} icon={iconName} links={links} /> <div> <Filter onFilterChange={onFilterChange} searchParams={searchParams} /> </div> </div> <div style={{ flex: 1 }}> <Search t={t} onSearch={onSearch} type="desktop" searchFields={searchFields} isInboxPage={true} searchParams={searchParams} /> <div className="result" style={{ marginLeft: "24px", flex: 1 }}> {result} </div> </div> </div> ) } export default DesktopInbox; |
ApplicationTable:-
In ApplicationTable we are importing the Table where it’s already present in our digit-UI-react-components. so we reusing this component. In Table, we are passing the data, column, global search , onSearch, filter, pagination, pagesize limit, total record, current page, Next page, PreviousPage, pagesizechange.
Code Block |
---|
import React from "react"; import { Table } from "@egovernments/digit-ui-react-components"; const ApplicationTable = ({ t, data, columns, globalSearch, onSearch, getCellProps, pageSizeLimit, totalRecords, currentPage, onNextPage, onPrevPage, onPageSizeChange, }) => { return ( <Table t={t} data={data} columns={columns} onSearch={onSearch} globalSearch={globalSearch} manualGlobalFilter={true} manualPagination={true} pageSizeLimit={pageSizeLimit} getCellProps={getCellProps} totalRecords={totalRecords} currentPage={currentPage} onNextPage={onNextPage} onPrevPage={onPrevPage} onPageSizeChange={onPageSizeChange} /> ) } export default ApplicationTable; |
Event Link: -
In Event Link, we are creating the create Birth-register module small card and adding the create link there.
Code Block |
---|
import React from "react"; import { Card, DocumentIcon, EventCalendar } from "@egovernments/digit-ui-react-components"; import { useTranslation } from "react-i18next"; import { Link } from "react-router-dom"; const EventLink = ({ title = "Birth", links, icon = 'calender' }) => { const { t } = useTranslation(); const GetLogo = () => ( <div className="header" style={{ justifyContent: "flex-start" }}> <span className="logo" style={{ backgroundColor: "#fff" }}> {icon === "calender" ? <EventCalendar /> : icon === "survey" ? 'surveyIcon' : <DocumentIcon />} </span> {" "} <span className="text">{t(title)}</span> </div> ); return ( <Card className="employeeCard filter inboxLinks"> <div className="complaint-links-container"> {GetLogo()} <div className="body"> {links.map(({ link, text, hyperlink = false, accessTo = [] }, index) => { return ( <span className="link" key={index}> <Link to={"citizen/br/birth"}>{"create"}</Link> </span> ); })} </div> </div> </Card> ) }; export default EventLink; |
...
Code Block |
---|
import { PrivateRoute } from "@egovernments/digit-ui-react-components"; import React from "react"; import { useTranslation } from "react-i18next"; import { Link, Switch, useLocation , Route } from "react-router-dom"; import Inbox from "./Inbox/Inbox"; import ResponseEmployee from "./ResponseEmployee"; const EmployeeApp = ({ path, url, userType ,tenants, parentRoute }) => { const { t } = useTranslation(); const BRManageApplication = Digit?.ComponentRegistryService?.getComponent("BRManageApplication"); const RegisterDetails = Digit?.ComponentRegistryService?.getComponent("RegisterDetails"); const Inbox = Digit?.ComponentRegistryService?.getComponent("Inbox"); const ResponseEmployee = Digit?.ComponentRegistryService?.getComponent("ResponseEmployee"); return ( <Switch> <React.Fragment> <div className="ground-container"> <PrivateRoute path={`${path}/responseemp`} component={() => <ResponseEmployee/>} /> <PrivateRoute path={`${path}/inbox`} component={props => <Inbox {...props} tenants={tenants} parentRoute={parentRoute} />} /> {/* <PrivateRoute path={`${path}/details`} component={() => <RegisterDetails />} /> */} <PrivateRoute path={`${path}/myapplication`} component={() => <BRManageApplication />} /> <PrivateRoute path={`${path}/details/:id`} component={(props) => <RegisterDetails {...props} />} /> </div> </React.Fragment> </Switch> ); }; export default EmployeeApp; |
Register Details:-
On Index Page, we are able to see the table in table Baby’s First name is accessible we can click on which information we need to see in detail. for the details page we are creating the Register Details Page.
Code Block |
---|
import { Header, ActionBar, SubmitBar, ExternalLinkIcon, Menu, GenericFileIcon, LinkButton } from '@egovernments/digit-ui-react-components';
import React, { useState , useEffect } from 'react'
import { useTranslation } from 'react-i18next';
import { openDocumentLink, openUploadedDocument } from '../../utils';
import axios from 'axios';
import { useParams } from "react-router-dom";
const RegisterDetails = ({ location, match, history, }) => {
const params = useParams();
const [data, setData] = useState([]);
useEffect(() => {
(async () => {
const result = await axios(`https://62f0e3e5e2bca93cd23f2ada.mockapi.io/birth/${params.id}`);
setData(result.data);
console.log("gooo" ,result.data);
})();
}, [params.id]);
let isMobile = window.Digit.Utils.browser.isMobile();
const { t } = useTranslation();
const [displayMenu, setDisplayMenu] = React.useState(false);
const [showModal, setShowModal] = useState(false);
function onActionSelect(action) {
// setSelectedAction(action);
history.push(`/digit-ui/employee/br/responseemp`)
}
return (
<div>
{/* {showModal ? <Confirmation
t={t}
heading={'CONFIRM_DELETE_DOC'}
docName={details?.name}
closeModal={() => setShowModal(!showModal)}
actionCancelLabel={'CS_COMMON_CANCEL'}
actionCancelOnSubmit={onModalCancel}
actionSaveLabel={'ES_COMMON_Y_DEL'}
actionSaveOnSubmit={onModalSubmit}
/>
: null} */}
<Header>{t(`Birth-Registration Details`)}</Header>
<div className="notice_and_circular_main gap-ten">
<div className="documentDetails_wrapper">
{/* <div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('ULB')}:`}</p> <p>{data?.tenantId}</p> </div> */}
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Babys First NAME')}:`}</p> <p>{data?.babyFirstName}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Babys Last NAME')}:`}</p> <p>{t(data?.babyLastName)}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Father NAME')}:`}</p> <p>{t(data?.fatherName)}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Mother NAME')}:`}</p> <p>{t(data?.motherName)}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Doctor NAME')}:`}</p> <p>{t(data?.doctorName)}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Hospital NAME')}:`}</p> <p>{t(data?.hospitalName)}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Applicant MobileNumber')}:`}</p> <p>{t(data?.applicantMobileNumber)}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Correspondence Address')}:`}</p> <p>{t(data?.correspondenceAddress)}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Correspondence City')}:`}</p> <p>{t(data?.correspondenceCity)}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Permanent Address')}:`}</p> <p>{t(data?.permanentAddress)}</p> </div>
<div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('Place Of Birth')}:`}</p> <p>{t(data?.placeOfBirth)}</p> </div>
{/* <div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('DCOUMENT_DESCRIPTION')}:`}</p> <p className="documentDetails__description">{details?.description?.length ? details?.description : 'NA'}</p> </div> */}
{/* <div className="documentDetails_row_items"><p className="documentDetails_title">{`${t('ES_COMMON_LINK_LABEL')}:`}</p>
{details?.documentLink ? <LinkButton
label={
<div className="link" onClick={() => openDocumentLink(details?.documentLink, details?.name)}>
<p>{t(`CE_DOCUMENT_OPEN_LINK`)}</p>
</div>
}
/> : 'NA'}
</div> */}
</div>
</div>
<ActionBar>
{displayMenu ? (
<Menu
localeKeyPrefix={"BR"}
options={['Approve', 'Reject']}
t={t}
onSelect={onActionSelect}
/>
) : null}
<SubmitBar label={t("ES_COMMON_TAKE_ACTION")} onSubmit={() => setDisplayMenu(!displayMenu)} />
</ActionBar>
{showModal &&
<Modal
headerBarMain={<Heading label={t('ES_EVENT_DELETE_POPUP_HEADER')} />}
headerBarEnd={<CloseBtn onClick={() => setShowModal(false)} />}
actionCancelLabel={t("CS_COMMON_CANCEL")}
actionCancelOnSubmit={() => setShowModal(false)}
actionSaveLabel={t('APPROVE')}
actionSaveOnSubmit={handleDelete}
>
<Card style={{ boxShadow: "none" }}>
<CardText>{t(`REJECT`)}</CardText>
</Card>
</Modal>
}
</div>
)
}
export default RegisterDetails;
|
Module.js:-
Code Block |
---|
import { CitizenHomeCard, PTIcon } from "@egovernments/digit-ui-react-components"; import React, { useEffect } from "react"; import { useTranslation } from "react-i18next"; import { useRouteMatch } from "react-router-dom"; import CitizenApp from "./pages/citizen"; import Create from "./pages/citizen/create/index"; import EmployeeApp from "./pages/employee"; import BrSelectName from "./pagecomponents/BrSelectName"; import BRSelectPhoneNumber from "./pagecomponents/BrSelectPhoneNumber"; import BRSelectGender from "./pagecomponents/BRSelectGender"; import BRSelectEmailId from "./pagecomponents/SelectEmailId"; import BRSelectPincode from "./pagecomponents/BRSelectPincode"; import BrSelectAddress from "./pagecomponents/BrSelectAddress"; import SelectCorrespondenceAddress from "./pagecomponents/SelectCorrespondenceAddress"; import SelectDocuments from "./pagecomponents/SelectDocuments"; import BRCard from "./components/config/BRCard"; import BRManageApplication from "./pages/employee/BRManageApplication"; import RegisterDetails from "./pages/employee/RegisterDetails"; import Response from "./pages/citizen/create/Response"; import Inbox from "./pages/employee/Inbox/Inbox"; import DesktopInbox from "./pages/employee/Inbox/DesktopInbox"; import ResponseEmployee from "./pages/employee/ResponseEmployee"; const componentsToRegister = { ResponseEmployee, DesktopInbox, Inbox, Response, RegisterDetails, BRManageApplication, BRCard, SelectDocuments, SelectCorrespondenceAddress, BrSelectAddress, BRSelectPincode, BRSelectEmailId, BRSelectGender, BRSelectPhoneNumber, BrSelectName, BRCreate : Create, }; export const BRModule = ({ stateCode, userType, tenants }) => { const { path, url } = useRouteMatch(); const moduleCode = "BR"; const language = Digit.StoreData.getCurrentLanguage(); const { isLoading, data: store } = Digit.Services.useStore({ stateCode, moduleCode, language }); if (userType === "citizen") { return <CitizenApp path={path} stateCode={stateCode} />; } return <EmployeeApp path={path} stateCode={stateCode} />; }; export const BRLinks = ({ matchPath, userType }) => { const { t } = useTranslation(); const links = [ { link: `${matchPath}/birth`, i18nKey: t("Create BirthRegistration"), }, ]; return <CitizenHomeCard header={t("BirthRegistration")} links={links} Icon={() => <PTIcon className="fill-path-primary-main" />} />; }; export const initBRComponents = () => { Object.entries(componentsToRegister).forEach(([key, value]) => { Digit.ComponentRegistryService.setComponent(key, value); }); }; |
...