Inbox/Search Screen

Approach to render Inbox and Search screen content based on config passed via MDMS data.

Overview

This page provides the approach details for -

  • rendering the Inbox screen or Search screen based on the config

  • calling the API dynamically based on API details passed via config

Common Components Used

InboxSearchComposer

This is a container component for inbox and search screens. It consists of 4 children components which can be rendered conditionally.

This component is used to render titles and links in the inbox.

SearchComponent

This component is used to render search or filter forms with ‘clear’ and ‘search’ buttons.

Results table

This component is used to render a table with searched results.

RenderFormFields

This component is used to render form fields passed in the 'fields' parameter in the config

Hooks Used

To fetch inbox details, ‘useCustomAPIHook’ is used which takes all the API details like URL, query params, body, config etc. from config (defined in MDMS).

Sample MDMS Data For Inbox

Configure Screens - Steps

  1. Create config based on the sections that need to be displayed on the screen. The basic structure for Inbox and Search screens is given below.

  1. Based on the flag given for each section its visibility is controlled. If the ‘show’ flag is true, then the section is visible, else it is hidden.

  2. Add API details in the top section, this API will be called via useCustomAPIHook and return the data. This consists of the below details.

  3. Add search form config which can be used in both inbox/search screen. It consists of UIconfig containing label info, styling info, default form values, and fields which need to be rendered in the form. Refer below

  4. Add Links config consists of link info, logo to be shown and title. Refer below

  5. Add Filter form config which is similar to the search form. Refer below

  6. Add Table (Search result) config consists of labels, column data and related jsonpaths to access the data passed. Refer below

  7. To add any customisations on query params, request body, table columns or to add any custom validations in forms, related code can be added in the UICustomisations file as below

  8. Once the above config is defined, created an index file/ Component in the pages folder. Fetch the config from MDMS and pass it to the inboxSearchComposer component as below

Limitations

  • This approach is followed only in Inbox and Search screens currently.

  • Only one API can be called dynamically based on given configurations.

Usage

To use the latest Inbox search composer it has to be imported from the React components or Utilities

React components

package

Utilities:

package

 import { InboxSearchComposer } from "@egovernments/digit-ui-module-utilities";
or 
 import { InboxSearchComposer } from "@egovernments/digit-ui-module-utilities";


    <React.Fragment>
      <Header className="works-header-search">{t(updatedConfig?.label)}</Header>
      <div className="inbox-search-wrapper">
        <InboxSearchComposer configs={updatedConfig}></InboxSearchComposer>
      </div>
    </React.Fragment>

All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.