Skip to content

Commit

Permalink
resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulg1254 committed Jul 29, 2024
1 parent 56e43b0 commit 8276c48
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 32 deletions.
9 changes: 3 additions & 6 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 Down Expand Up @@ -49,6 +45,7 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
pagination = true,
}) => {
const [selectedRowIds, setSelectedRowIds] = useState<number[]>([]);
const { t } = useTranslation();

const handleCheckboxChange = (rowId: number) => {
setSelectedRowIds((prevSelected) =>
Expand Down Expand Up @@ -122,7 +119,7 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
},
}}
noData={{
text: "No Data Found",
text: t("COURSE_PLANNER.DATA_NOT_FOUND"),
}}
/>
</div>
Expand Down
14 changes: 6 additions & 8 deletions src/pages/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
getDistrictsForState,
getBlocksForDistricts,
} from "@/services/MasterDataService";
import formatLabel from "@/utils/formatLabel";
import CustomModal from "@/components/CustomModal";
import { transformLabel } from "@/utils/Helper";

type StateDetail = {
value: string;
Expand Down Expand Up @@ -138,11 +138,9 @@ const Block: React.FC = () => {
[]
);

const handleEdit = useCallback((rowData: any) => {
}, []);
const handleEdit = useCallback((rowData: any) => {}, []);

const handleDelete = useCallback((rowData: any) => {
}, []);
const handleDelete = useCallback((rowData: any) => {}, []);

const handleConfirmDelete = useCallback(() => {
setConfirmationModalOpen(false);
Expand Down Expand Up @@ -226,7 +224,7 @@ const Block: React.FC = () => {
>
{stateData.map((stateDetail) => (
<MenuItem key={stateDetail.value} value={stateDetail.value}>
{formatLabel(stateDetail.label)}
{transformLabel(stateDetail.label)}
</MenuItem>
))}
</Select>
Expand All @@ -252,7 +250,7 @@ const Block: React.FC = () => {
key={districtDetail.value}
value={districtDetail.value}
>
{formatLabel(districtDetail.label)}
{transformLabel(districtDetail.label)}
</MenuItem>
))}
</Select>
Expand All @@ -267,7 +265,7 @@ const Block: React.FC = () => {
<KaTableComponent
columns={columns}
data={blockData.map((block) => ({
block: formatLabel(block.label),
block: transformLabel(block.label),
actions: "Action buttons",
}))}
limit={pageLimit}
Expand Down
8 changes: 4 additions & 4 deletions src/pages/district.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
getStateBlockDistrictList,
getDistrictsForState,
} from "@/services/MasterDataService";
import formatLabel from "@/utils/formatLabel";
import { transformLabel } from "@/utils/Helper";

type StateDetail = {
value: string;
Expand Down Expand Up @@ -233,7 +233,7 @@ const District: React.FC = () => {
>
{stateData.map((state) => (
<MenuItem key={state.value} value={state.value}>
{formatLabel(state.label)}
{transformLabel(state.label)}
</MenuItem>
))}
</Select>
Expand All @@ -242,7 +242,7 @@ const District: React.FC = () => {
<KaTableComponent
columns={columns}
data={sortedDistricts.map((districtDetail) => ({
label: formatLabel(districtDetail.label),
label: transformLabel(districtDetail.label),
actions: "Action buttons",
}))}
limit={pageLimit}
Expand All @@ -261,7 +261,7 @@ const District: React.FC = () => {
extraActions={[]}
onEdit={handleEdit}
onDelete={handleDelete}
noData={!!(sortedDistricts.length === 0 ? "No Data Found" : "")}
noData={districtData.length === 0}
/>
</HeaderComponent>
</React.Fragment>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SortDirection } from "ka-table/enums";
import Loader from "@/components/Loader";
import { Box } from "@mui/material";
import CustomModal from "@/components/CustomModal";
import { transformLabel } from "@/utils/Helper";

type StateDetail = {
label: string;
Expand Down Expand Up @@ -170,9 +171,7 @@ const State: React.FC = () => {
<KaTableComponent
columns={columns}
data={stateData.map((stateDetail) => ({
label:
stateDetail.label?.toLocaleLowerCase().charAt(0).toUpperCase() +
stateDetail.label?.toLocaleLowerCase().slice(1),
label: transformLabel(stateDetail.label),
}))}
limit={pageLimit}
offset={pageOffset}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const generateUUID = () => {
label: string;
}

const transformLabel = (label: string): string => {
export const transformLabel = (label: string): string => {
return label
.toLowerCase() // Convert to lowercase to standardize
.replace(/_/g, ' ') // Replace underscores with spaces
Expand Down
10 changes: 0 additions & 10 deletions src/utils/formatLabel.ts

This file was deleted.

0 comments on commit 8276c48

Please sign in to comment.