Skip to content

Commit

Permalink
Merge pull request #62 from rahulg1254/admin-master
Browse files Browse the repository at this point in the history
Task #223615 feat: Integrated show district api and no found data added in ka-table, added in utils
  • Loading branch information
itsvick authored Jul 29, 2024
2 parents 9524276 + 8276c48 commit b0b3c30
Show file tree
Hide file tree
Showing 7 changed files with 421 additions and 385 deletions.
2 changes: 0 additions & 2 deletions src/components/HeaderComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import { useTheme } from "@mui/material/styles";
import { useTranslation } from "next-i18next";
import { useEffect, useState } from "react";
import {
getBlockList,
getDistrictList,
getStateBlockDistrictList,
} from "../services/MasterDataService";
import AreaSelection from "./AreaSelection";
Expand Down
25 changes: 16 additions & 9 deletions src/components/KaTableComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// components/KaTableComponent.tsx

import React, { useState } from "react";
import { ITableProps, Table } from "ka-table";
import { SortingMode, PagingPosition } from "ka-table/enums";
import { Paper, Checkbox } from "@mui/material";
import "ka-table/style.css";
import { IPagingProps } from "ka-table/props";
import { updatePageIndex, updatePageSize } from "ka-table/actionCreators";
import ActionCell from "./ActionCell";
import ActionIcon from "./ActionIcon";
import { useTranslation } from "react-i18next";

interface KaTableComponentProps {
columns: ITableProps["columns"];
Expand All @@ -28,6 +24,7 @@ interface KaTableComponentProps {
}[];
paginationEnable?: boolean;
showIcons?: boolean;
noData?: any;
pagination?: boolean;
}

Expand All @@ -44,9 +41,11 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
onDelete,
showIcons,
pageSizes,
noData,
pagination = true,
}) => {
const [selectedRowIds, setSelectedRowIds] = useState<number[]>([]);
const { t } = useTranslation();

const handleCheckboxChange = (rowId: number) => {
setSelectedRowIds((prevSelected) =>
Expand Down Expand Up @@ -77,6 +76,13 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
<div className="ka-table-wrapper">
<Table
{...tableProps}
paging={{
enabled: paginationEnable,
pageIndex: offset,
pageSize: limit,
pageSizes: pageSizes,
position: PagingPosition.Bottom,
}}
childComponents={{
pagingSizes: {
content: (props) => <PageSizeSelector {...props} />,
Expand All @@ -98,10 +104,8 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
if (props.column.key === "selection-cell") {
return (
<Checkbox
checked={selectedRowIds.includes(props.rowData.userId)}
onChange={() =>
handleCheckboxChange(props.rowData.userId)
}
checked={selectedRowIds.includes(props.rowData.id)}
onChange={() => handleCheckboxChange(props.rowData.id)}
/>
);
}
Expand All @@ -114,6 +118,9 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
},
},
}}
noData={{
text: t("COURSE_PLANNER.DATA_NOT_FOUND"),
}}
/>
</div>
</Paper>
Expand Down
Loading

0 comments on commit b0b3c30

Please sign in to comment.