Skip to content

Commit

Permalink
fix: ORV2-1371 Enable Search bar in Permit list (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnan-aot authored Dec 19, 2023
1 parent ca83008 commit 3738abd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { useQuery } from "@tanstack/react-query";
import { useCallback, useContext, useEffect, useState } from "react";

import {
MRT_GlobalFilterTextField,
MRT_PaginationState,
MRT_Row,
MRT_TableInstance,
MaterialReactTable,
useMaterialReactTable,
} from "material-react-table";
Expand Down Expand Up @@ -55,7 +57,6 @@ export const BasePermitList = ({
...defaultTableOptions,
columns: PermitsColumnDefinition,
data: data?.items ?? [],
enableTopToolbar: false,
enableRowSelection: false,
initialState: {
...defaultTableInitialStateOptions,
Expand All @@ -69,6 +70,20 @@ export const BasePermitList = ({
isLoading: isInitialLoading || isLoading,
pagination,
},
renderTopToolbar: useCallback(
({ table }: { table: MRT_TableInstance<Permit> }) => (
<Box
sx={{
display: "flex",
padding: "1.25em 0em",
backgroundColor: "white",
}}
>
<MRT_GlobalFilterTextField table={table} />
</Box>
),
[],
),
autoResetPageIndex: false,
manualPagination: true,
rowCount: data?.meta?.totalItems ?? 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { MRT_ColumnDef } from "material-react-table";
import { viewPermitPdf } from "../../helpers/permitPDFHelper";
import { Permit } from "../../types/permit";
import { PermitChip } from "./PermitChip";
import { dateTimeStringSortingFn, formatCellValuetoDatetime } from "../../../../common/constants/defaultTableOptions";
import {
dateTimeStringSortingFn,
formatCellValuetoDatetime,
} from "../../../../common/constants/defaultTableOptions";

/**
* The column definition for Permits.
Expand All @@ -16,15 +19,15 @@ export const PermitsColumnDefinition: MRT_ColumnDef<Permit>[] = [
sortingFn: "alphanumeric",
size: 500,
accessorFn: (row) => row.permitNumber,
Cell: (props: { cell: any; row: any }) => {
Cell: (props: { row: any; renderedCellValue: any }) => {
return (
<>
<Link
component="button"
variant="body2"
onClick={() => viewPermitPdf(props.row.original.permitId)}
>
{props.cell.getValue()}
{props.renderedCellValue}
</Link>
<PermitChip permitStatus={props.row.original.permitStatus} />
</>
Expand Down

0 comments on commit 3738abd

Please sign in to comment.