Skip to content

Commit

Permalink
Merge pull request #40 from rahulg1254/admin-master
Browse files Browse the repository at this point in the history
Issue #222912 feat: Added lowercase to state, district andblock dropdown & map issue resolved in district component
  • Loading branch information
itsvick authored Jul 19, 2024
2 parents f598f21 + b553772 commit 39e4a92
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/pages/block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const staticDistrictData = [
{ value: "D2", label: "Mumbai" },
];

const staticBlockData = [{ label: "Hinjewadi" }, { label: "Kothrud" }];
const staticBlockData = [{ label: "Hinjewadi" }, { label: "Baner" }];

const Block: React.FC = () => {
const { t } = useTranslation();
Expand Down Expand Up @@ -154,7 +154,11 @@ const Block: React.FC = () => {
>
{stateData.map((stateDetail) => (
<MenuItem key={stateDetail.value} value={stateDetail.value}>
{stateDetail.label}
{stateDetail.label
?.toLocaleLowerCase()
.charAt(0)
.toUpperCase() +
stateDetail.label?.toLocaleLowerCase().slice(1)}
</MenuItem>
))}
</Select>
Expand Down
28 changes: 19 additions & 9 deletions src/pages/district.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ const District: React.FC = () => {
);

const handleChange = (event: SelectChangeEvent<number>) => {
setPageSize(Number(event.target.value));
setPageLimit(Number(event.target.value));
const value = Number(event.target.value);
setPageSize(value);
setPageLimit(value);
};

const handlePaginationChange = (
Expand All @@ -82,7 +83,7 @@ const District: React.FC = () => {
setSelectedState(selectedState);
try {
const data = await getDistrictList(selectedState);
setDistrictData(data.result);
setDistrictData(data.result || []);
setSelectedDistrict(data.result[0]?.label || "-");
} catch (error) {
console.error("Error fetching district data", error);
Expand Down Expand Up @@ -117,11 +118,11 @@ const District: React.FC = () => {
const fetchStateData = async () => {
try {
const data = await getStateList();
setStateData(data.result);
setStateData(data.result || []);
const initialSelectedState = data.result[0]?.value || "";
setSelectedState(initialSelectedState);
const districtData = await getDistrictList(initialSelectedState);
setDistrictData(districtData.result);
setDistrictData(districtData.result || []);
setSelectedDistrict(districtData.result[0]?.label || "-");
} catch (error) {
console.error("Error fetching state data", error);
Expand Down Expand Up @@ -155,8 +156,8 @@ const District: React.FC = () => {
selectedSort,
handleStateChange,
handleSortChange,
states: stateData.map((state) => state.label),
districts: districtData.map((district) => district.label),
states: stateData.map((state) => state.label) || [],
districts: districtData.map((district) => district.label) || [],
selectedState,
selectedDistrict,
showStateDropdown: false,
Expand All @@ -179,7 +180,11 @@ const District: React.FC = () => {
>
{stateData.map((stateDetail) => (
<MenuItem key={stateDetail.value} value={stateDetail.value}>
{stateDetail.label}
{stateDetail.label
?.toLocaleLowerCase()
.charAt(0)
.toUpperCase() +
stateDetail.label?.toLocaleLowerCase().slice(1)}
</MenuItem>
))}
</Select>
Expand All @@ -188,7 +193,12 @@ const District: React.FC = () => {
<KaTableComponent
columns={columns}
data={sortedDistricts.map((districtDetail) => ({
label: districtDetail.label,
label:
districtDetail.label
?.toLocaleLowerCase()
.charAt(0)
.toUpperCase() +
districtDetail.label?.toLocaleLowerCase().slice(1),
actions: "Action buttons",
}))}
limit={pageLimit}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ const State: React.FC = () => {
<KaTableComponent
columns={columns}
data={stateData.map((stateDetail) => ({
label: stateDetail.label,
label:
stateDetail.label?.toLocaleLowerCase().charAt(0).toUpperCase() +
stateDetail.label?.toLocaleLowerCase().slice(1),
}))}
limit={pageLimit}
offset={pageOffset}
Expand Down

0 comments on commit 39e4a92

Please sign in to comment.