Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/tekdi/shiksha-admin into co…
Browse files Browse the repository at this point in the history
…hort_list
  • Loading branch information
upendraTekdi committed Jul 30, 2024
2 parents 04d760e + b0b3c30 commit 987d933
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,16 +1,12 @@
// 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 { format } from "date-fns";
import { DataKey, DateFormat } from "@/utils/app.constant";
import { useTranslation } from "react-i18next";

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

Expand All @@ -46,9 +43,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 @@ -79,6 +78,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 Down Expand Up @@ -111,10 +117,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 @@ -127,6 +131,9 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
},
},
}}
noData={{
text: t("COURSE_PLANNER.DATA_NOT_FOUND"),
}}
/>
</div>
</Paper>
Expand Down
Loading

0 comments on commit 987d933

Please sign in to comment.