diff --git a/package-lock.json b/package-lock.json index 5dfbb206..c5071690 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1550,52 +1550,6 @@ "tslib": "^2.4.0" } }, - "node_modules/@tanstack/match-sorter-utils": { - "version": "8.15.1", - "resolved": "https://registry.npmjs.org/@tanstack/match-sorter-utils/-/match-sorter-utils-8.15.1.tgz", - "integrity": "sha512-PnVV3d2poenUM31ZbZi/yXkBu3J7kd5k2u51CGwwNojag451AjTH9N6n41yjXz2fpLeewleyLBmNS6+HcGDlXw==", - "dependencies": { - "remove-accents": "0.5.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - } - }, - "node_modules/@tanstack/react-table": { - "version": "8.19.2", - "resolved": "https://registry.npmjs.org/@tanstack/react-table/-/react-table-8.19.2.tgz", - "integrity": "sha512-itoSIAkA/Vsg+bjY23FSemcTyPhc5/1YjYyaMsr9QSH/cdbZnQxHVWrpWn0Sp2BWN71qkzR7e5ye8WuMmwyOjg==", - "dependencies": { - "@tanstack/table-core": "8.19.2" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - }, - "peerDependencies": { - "react": ">=16.8", - "react-dom": ">=16.8" - } - }, - "node_modules/@tanstack/table-core": { - "version": "8.19.2", - "resolved": "https://registry.npmjs.org/@tanstack/table-core/-/table-core-8.19.2.tgz", - "integrity": "sha512-KpRjhgehIhbfH78ARm/GJDXGnpdw4bCg3qas6yjWSi7czJhI/J6pWln7NHtmBkGE9ZbohiiNtLqwGzKmBfixig==", - "engines": { - "node": ">=12" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/tannerlinsley" - } - }, "node_modules/@types/fingerprintjs2": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@types/fingerprintjs2/-/fingerprintjs2-2.0.0.tgz", @@ -1674,11 +1628,6 @@ "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", "dev": true }, - "node_modules/@types/stylis": { - "version": "4.2.5", - "resolved": "https://registry.npmjs.org/@types/stylis/-/stylis-4.2.5.tgz", - "integrity": "sha512-1Xve+NMN7FWjY14vLoY5tL3BVEQ/n42YLwaqJIPYhotZ9uBHt87VceMwWQpzmdEt2TNXIorIFG+YeCUUW7RInw==" - }, "node_modules/@typescript-eslint/parser": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.2.0.tgz", @@ -2389,14 +2338,6 @@ "node": ">=6" } }, - "node_modules/camelize": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz", - "integrity": "sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/caniuse-lite": { "version": "1.0.30001640", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001640.tgz", @@ -2601,24 +2542,6 @@ "semver": "bin/semver.js" } }, - "node_modules/css-color-keywords": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", - "integrity": "sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==", - "engines": { - "node": ">=4" - } - }, - "node_modules/css-to-react-native": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz", - "integrity": "sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==", - "dependencies": { - "camelize": "^1.0.0", - "css-color-keywords": "^1.0.0", - "postcss-value-parser": "^4.0.2" - } - }, "node_modules/csstype": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", @@ -5705,11 +5628,6 @@ "node": "^10 || ^12 || >=14" } }, - "node_modules/postcss-value-parser": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", - "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -5967,11 +5885,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/remove-accents": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/remove-accents/-/remove-accents-0.5.0.tgz", - "integrity": "sha512-8g3/Otx1eJaVD12e31UbJj1YzdtVvzH85HV7t+9MJYk/u3XmkOUJ5Ys9wQrf9PCPK8+xn4ymzqYCiZl6QWKn+A==" - }, "node_modules/request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", @@ -6272,11 +6185,6 @@ "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" }, - "node_modules/shallowequal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", - "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" - }, "node_modules/sharp": { "version": "0.33.4", "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.4.tgz", @@ -6664,70 +6572,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/styled-components": { - "version": "6.1.11", - "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-6.1.11.tgz", - "integrity": "sha512-Ui0jXPzbp1phYij90h12ksljKGqF8ncGx+pjrNPsSPhbUUjWT2tD1FwGo2LF6USCnbrsIhNngDfodhxbegfEOA==", - "dependencies": { - "@emotion/is-prop-valid": "1.2.2", - "@emotion/unitless": "0.8.1", - "@types/stylis": "4.2.5", - "css-to-react-native": "3.2.0", - "csstype": "3.1.3", - "postcss": "8.4.38", - "shallowequal": "1.1.0", - "stylis": "4.3.2", - "tslib": "2.6.2" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/styled-components" - }, - "peerDependencies": { - "react": ">= 16.8.0", - "react-dom": ">= 16.8.0" - } - }, - "node_modules/styled-components/node_modules/postcss": { - "version": "8.4.38", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", - "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/postcss/" - }, - { - "type": "tidelift", - "url": "https://tidelift.com/funding/github/npm/postcss" - }, - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "dependencies": { - "nanoid": "^3.3.7", - "picocolors": "^1.0.0", - "source-map-js": "^1.2.0" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/styled-components/node_modules/stylis": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.2.tgz", - "integrity": "sha512-bhtUjWd/z6ltJiQwg0dUfxEJ+W+jdqQd8TbWLWyeIJHlnsqmGLRFFd8e5mA0AZi/zx90smXRlN66YMTcaSFifg==" - }, - "node_modules/styled-components/node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" - }, "node_modules/styled-jsx": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz", diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 25a14048..3268806c 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -36,11 +36,20 @@ "SEARCHBAR_PLACEHOLDER": "Search course, topic, student, pdf etc.." }, "LEARNERS": { - "SEARCHBAR_PLACEHOLDER": "Search Learners.." }, "TEAM_LEADERS": { - "SEARCHBAR_PLACEHOLDER": "Search Team leaders.." + }, + "MASTER": { + "STATE": "State", + "SORT": "Sort", + "DISTRICT_NAMES": "District Names", + "ACTIONS": "Actions", + "DISTRICTS": "Districts", + "SEARCHBAR_PLACEHOLDER_STATE": "Search States", + "SEARCHBAR_PLACEHOLDER_DISTRICT": "Search Districts", + "SEARCHBAR_PLACEHOLDER_BLOCK": "Search Blocks", + "BLOCKS": "Blocks" } -} \ No newline at end of file +} diff --git a/public/locales/hi/common.json b/public/locales/hi/common.json index 35c55b8d..1ef5b2e4 100644 --- a/public/locales/hi/common.json +++ b/public/locales/hi/common.json @@ -12,5 +12,16 @@ "USERNAME_PASSWORD_NOT_CORRECT": "आपका यूजरनेम या पासवर्ड गलत है", "FORGOT_PASSWORD": "पासवर्ड भूल गए?", "REMEMBER_ME": "मुझे याद रखें" + }, + "MASTER": { + "STATE": "राज्य", + "SORT": "क्रमबद्ध करें", + "DISTRICT_NAMES": "जिला नाम", + "ACTIONS": "क्रियाएँ", + "DISTRICTS": "जिले", + "SEARCHBAR_PLACEHOLDER_STATE": "राज्यों को खोजें", + "SEARCHBAR_PLACEHOLDER_DISTRICT": "जिलों को खोजें", + "SEARCHBAR_PLACEHOLDER_BLOCK": "ब्लॉकों को खोजें", + "BLOCKS": "ब्लॉक" } } diff --git a/public/locales/mr/common.json b/public/locales/mr/common.json index 578dae4e..4ad6485b 100644 --- a/public/locales/mr/common.json +++ b/public/locales/mr/common.json @@ -12,6 +12,16 @@ "USERNAME_PASSWORD_NOT_CORRECT": "आपलं वापरकर्तानाव किंवा संकेतशब्द चुकीचं आहे", "FORGOT_PASSWORD": "पासवर्ड विसरलात?", "REMEMBER_ME": "मला लक्षात ठेवा" + }, + "MASTER": { + "STATE": "राज्य", + "SORT": "क्रमवारी लावा", + "DISTRICT_NAMES": "जिल्ह्यांची नावे", + "ACTIONS": "कृती", + "DISTRICTS": "जिल्हे", + "SEARCHBAR_PLACEHOLDER_STATE": "राज्य शोधा", + "SEARCHBAR_PLACEHOLDER_DISTRICT": "जिल्हे शोधा", + "SEARCHBAR_PLACEHOLDER_BLOCK": "ब्लॉक शोधा", + "BLOCKS": "ब्लॉक" } - } diff --git a/public/locales/or/common.json b/public/locales/or/common.json index e69d8ef1..b1500ab1 100644 --- a/public/locales/or/common.json +++ b/public/locales/or/common.json @@ -12,5 +12,16 @@ "USERNAME_PASSWORD_NOT_CORRECT": "ଆପଣଙ୍କ ବ୍ୟବହାରକୃତ ନାମ କିମ୍ବା ପାସ୍‌ୱାର୍ଡ ଭୁଲ ଅଛି", "FORGOT_PASSWORD": "ପାସ୍‌ୱାର୍ଡ ଭୁଲିଛନ୍ତି?", "REMEMBER_ME": "ମୋତେ ମନ ରଖ" + }, + "MASTER": { + "STATE": "ରାଜ୍ୟ", + "SORT": "ଛାଟାନ୍ତୁ", + "DISTRICT_NAMES": "ଜିଲ୍ଲା ନାମ", + "ACTIONS": "କାର୍ଯ୍ୟ", + "DISTRICTS": "ଜିଲ୍ଲା", + "SEARCHBAR_PLACEHOLDER_STATE": "ରାଜ୍ୟ ଖୋଜନ୍ତୁ", + "SEARCHBAR_PLACEHOLDER_DISTRICT": "ଜିଲ୍ଲା ଖୋଜନ୍ତୁ", + "SEARCHBAR_PLACEHOLDER_BLOCK": "ବ୍ଲକ୍ ଖୋଜନ୍ତୁ", + "BLOCKS": "ବ୍ଲକ୍" } } diff --git a/src/components/UserComponent.tsx b/src/components/UserComponent.tsx index f18b6f74..974e65c3 100644 --- a/src/components/UserComponent.tsx +++ b/src/components/UserComponent.tsx @@ -30,6 +30,7 @@ const UserComponent = ({ handleDistrictChange, handleBlockChange, handleSortChange, + showStateDropdown = true, }: any) => { const { t } = useTranslation(); @@ -42,103 +43,105 @@ const UserComponent = ({ gap: isMobile ? "0.1px" : "16px", }} > - + {showStateDropdown && ( - - + + {t("FACILITATORS.ALL_STATES")} - ))} - - - - + + - - {t("FACILITATORS.ALL_DISTRICTS")} - - {AllDistrict.map((district, index) => ( - - {district} + - - - + + - All Blocks - {AllBlocks.map((block, index) => ( - - {block} - - ))} - - + + + - + )} {userType} - { + const [selectedState, setSelectedState] = useState("All states"); + const [selectedDistrict, setSelectedDistrict] = useState("All Districts"); + const [selectedBlock, setSelectedBlock] = useState("All Blocks"); + const [selectedSort, setSelectedSort] = useState("Sort"); + const [pageOffset, setPageOffset] = useState(0); + const [pageLimit, setPageLimit] = useState(10); + const [stateData, setStateData] = useState(StateData); + const [data, setData] = useState([]); + const { t } = useTranslation(); + const [pageSize, setPageSize] = useState(""); + + const columns = [ + { + key: "blocks", + title: t("MASTER.BLOCK_NAMES"), + dataType: DataType.String, + }, + { + key: "actions", + title: t("MASTER.ACTIONS"), + dataType: DataType.String, + }, + ]; + + const handleChange = (event: SelectChangeEvent) => { + setPageSize(event.target.value); + setPageLimit(Number(event.target.value)); + }; + + const handlePaginationChange = ( + event: React.ChangeEvent, + value: number + ) => { + setPageOffset(value - 1); + }; + + const PageSizeSelectorFunction = () => ( + + ); + + const handleStateChange = (event: SelectChangeEvent) => { + const selectedState = event.target.value as string; + setSelectedState(selectedState); + const state = stateData.find((state) => state.state === selectedState); + if (state) { + setSelectedDistrict(state.districts[0]); + fetchDataForDistrict(state.districts[0]); + } else { + setSelectedDistrict("All Districts"); + } + }; + + const handleDistrictChange = (event: SelectChangeEvent) => { + const selectedDistrict = event.target.value as string; + setSelectedDistrict(selectedDistrict); + setSelectedBlock("All Blocks"); + fetchDataForDistrict(selectedDistrict); + }; + + const handleBlockChange = (event: SelectChangeEvent) => { + setSelectedBlock(event.target.value as string); + }; + + const handleSortChange = async (event: SelectChangeEvent) => { + setSelectedSort(event.target.value as string); + }; + + const fetchDataForDistrict = (district: string) => { + const newData: UserDetails[] = []; + setData(newData); + }; + + const userProps = { + userType: t("MASTER.BLOCKS"), + searchPlaceHolder: t("MASTER.SEARCHBAR_PLACEHOLDER_BLOCK"), + selectedSort: selectedSort, + handleStateChange: handleStateChange, + handleDistrictChange: handleDistrictChange, + states: stateData.map((state) => state.state), + districts: + stateData.find((state) => state.state === selectedState)?.districts || [], + blocks: + stateData.find((state) => state.state === selectedState)?.blocks || [], + selectedState: selectedState, + selectedDistrict: selectedDistrict, + showStateDropdown: false, + }; + + return ( + + + + + + States + + + + + + Districts + + + + + + state.state === selectedState) + ?.blocks.map((block) => ({ + blocks: block, + actions: "Action buttons", + })) || [] + : [] + } + limit={pageLimit} + offset={pageOffset * pageLimit} + PagesSelector={() => ( + + )} + PageSizeSelector={PageSizeSelectorFunction} + /> + + + ); +}; + +export async function getStaticProps({ locale }: any) { + return { + props: { + ...(await serverSideTranslations(locale, ["common"])), + }, + }; +} + +export default Block; diff --git a/src/pages/district.tsx b/src/pages/district.tsx new file mode 100644 index 00000000..e489de27 --- /dev/null +++ b/src/pages/district.tsx @@ -0,0 +1,173 @@ +import React, { useState } from "react"; +import KaTableComponent from "../components/KaTableComponent"; +import { DataType } from "ka-table/enums"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; +import UserComponent from "@/components/UserComponent"; +import StateData from "./dummyAPI/stateData"; +import Pagination from "@mui/material/Pagination"; +import Box from "@mui/material/Box"; +import FormControl from "@mui/material/FormControl"; +import InputLabel from "@mui/material/InputLabel"; +import MenuItem from "@mui/material/MenuItem"; +import Select, { SelectChangeEvent } from "@mui/material/Select"; +import PageSizeSelector from "@/components/PageSelector"; +import { useTranslation } from "next-i18next"; + +type UserDetails = { + userId: any; + username: any; + name: any; + role: any; + mobile: any; + centers?: any; + Programs?: any; +}; + +type StateDetails = { + state: string; + districts: string[]; +}; + +const District: React.FC = () => { + const { t } = useTranslation(); + const [selectedState, setSelectedState] = useState("All states"); + const [selectedDistrict, setSelectedDistrict] = useState("All Districts"); + const [selectedBlock, setSelectedBlock] = useState("All Blocks"); + const [selectedSort, setSelectedSort] = useState(t("MASTER.SORT")); + const [pageOffset, setPageOffset] = useState(0); + const [pageLimit, setPageLimit] = useState(10); + const [stateData, setStateData] = useState(StateData); + const [data, setData] = useState([]); + const [pageSize, setPageSize] = useState(""); + + const columns = [ + { + key: "district", + title: t("MASTER.DISTRICT_NAMES"), + dataType: DataType.String, + }, + { + key: "actions", + title: t("MASTER.ACTIONS"), + dataType: DataType.String, + }, + ]; + + const handleChange = (event: SelectChangeEvent) => { + setPageSize(event.target.value); + setPageLimit(Number(event.target.value)); + }; + + const handlePaginationChange = ( + event: React.ChangeEvent, + value: number + ) => { + setPageOffset(value - 1); + }; + + const PageSizeSelectorFunction = () => ( + + ); + + const handleStateChange = (event: SelectChangeEvent) => { + const selectedState = event.target.value as string; + setSelectedState(selectedState); + const state = stateData.find((state) => state.state === selectedState); + if (state) { + setSelectedDistrict(state.districts[0]); + fetchDataForDistrict(state.districts[0]); + } else { + setSelectedDistrict("All Districts"); + } + }; + + const handleDistrictChange = (event: SelectChangeEvent) => { + const selectedDistrict = event.target.value as string; + setSelectedDistrict(selectedDistrict); + fetchDataForDistrict(selectedDistrict); + }; + + const handleBlockChange = (event: SelectChangeEvent) => { + setSelectedBlock(event.target.value as string); + }; + + const handleSortChange = async (event: SelectChangeEvent) => { + setSelectedSort(event.target.value as string); + }; + + const fetchDataForDistrict = (district: string) => { + const newData: UserDetails[] = []; + setData(newData); + }; + + const userProps = { + userType: t("MASTER.DISTRICTS"), + searchPlaceHolder: t("MASTER.SEARCHBAR_PLACEHOLDER_DISTRICT"), + selectedSort: selectedSort, + handleStateChange: handleStateChange, + handleDistrictChange: handleDistrictChange, + states: stateData.map((state) => state.state), + districts: + stateData.find((state) => state.state === selectedState)?.districts || [], + selectedState: selectedState, + selectedDistrict: selectedDistrict, + showStateDropdown: false, + }; + + return ( + + + + + States + + + + state.state === selectedState) + .flatMap((state) => + state.districts.map((district) => ({ + district: district, + actions: "Action buttons", + })) + )} + limit={pageLimit} + offset={pageOffset * pageLimit} + PagesSelector={() => ( + + )} + PageSizeSelector={PageSizeSelectorFunction} + /> + + + ); +}; + +export async function getStaticProps({ locale }: any) { + return { + props: { + ...(await serverSideTranslations(locale, ["common"])), + }, + }; +} + +export default District; diff --git a/src/pages/dummyAPI/stateData.tsx b/src/pages/dummyAPI/stateData.tsx new file mode 100644 index 00000000..75ff80d8 --- /dev/null +++ b/src/pages/dummyAPI/stateData.tsx @@ -0,0 +1,944 @@ +const StateData = [ + { + state: "Andaman and Nicobar Islands", + districts: ["Nicobar", "North and Middle Andaman", "South Andaman"], + blocks: [], + }, + { + state: "Andhra Pradesh", + districts: [ + "Anantapur", + "Chittoor", + "East Godavari", + "Guntur", + "Krishna", + "Kurnool", + "Nellore", + "Prakasam", + "Srikakulam", + "Visakhapatnam", + "Vizianagaram", + "West Godavari", + "YSR Kadapa", + ], + blocks: [ + "Anantapur Urban", + "Anantapur Rural", + "Bathalapalli", + "Bommanahal", + "Brahmasamudram", + // Add more blocks as needed + ], + }, + { + state: "Arunachal Pradesh", + districts: [ + "Tawang", + "West Kameng", + "East Kameng", + "Papum Pare", + "Kurung Kumey", + "Kra Daadi", + "Lower Subansiri", + "Upper Subansiri", + "West Siang", + "East Siang", + "Siang", + "Upper Siang", + "Lower Siang", + "Lower Dibang Valley", + "Dibang Valley", + "Anjaw", + "Lohit", + "Namsai", + "Changlang", + "Tirap", + "Longding", + ], + blocks: [], + }, + { + state: "Assam", + districts: [ + "Baksa", + "Barpeta", + "Biswanath", + "Bongaigaon", + "Cachar", + "Charaideo", + "Chirang", + "Darrang", + "Dhemaji", + "Dhubri", + "Dibrugarh", + "Goalpara", + "Golaghat", + "Hailakandi", + "Hojai", + "Jorhat", + "Kamrup Metropolitan", + "Kamrup", + "Karbi Anglong", + "Karimganj", + "Kokrajhar", + "Lakhimpur", + "Majuli", + "Morigaon", + "Nagaon", + "Nalbari", + "Dima Hasao", + "Sivasagar", + "Sonitpur", + "South Salmara-Mankachar", + "Tinsukia", + "Udalguri", + "West Karbi Anglong", + ], + blocks: [], + }, + { + state: "Bihar", + districts: [ + "Araria", + "Arwal", + "Aurangabad", + "Banka", + "Begusarai", + "Bhagalpur", + "Bhojpur", + "Buxar", + "Darbhanga", + "East Champaran (Motihari)", + "Gaya", + "Gopalganj", + "Jamui", + "Jehanabad", + "Kaimur (Bhabua)", + "Katihar", + "Khagaria", + "Kishanganj", + "Lakhisarai", + "Madhepura", + "Madhubani", + "Munger (Monghyr)", + "Muzaffarpur", + "Nalanda", + "Nawada", + "Patna", + "Purnia (Purnea)", + "Rohtas", + "Saharsa", + "Samastipur", + "Saran", + "Sheikhpura", + "Sheohar", + "Sitamarhi", + "Siwan", + "Supaul", + "Vaishali", + "West Champaran", + ], + blocks: [], + }, + { + state: "Chandigarh", + districts: ["Chandigarh"], + blocks: [], + }, + { + state: "Chhattisgarh", + districts: [ + "Balod", + "Baloda Bazar", + "Balrampur", + "Bastar", + "Bemetara", + "Bijapur", + "Bilaspur", + "Dantewada", + "Dhamtari", + "Durg", + "Gariaband", + "Janjgir-Champa", + "Jashpur", + "Kabirdham (Kawardha)", + "Kanker (North Bastar)", + "Kondagaon", + "Korba", + "Korea (Koriya)", + "Mahasamund", + "Mungeli", + "Narayanpur", + "Raigarh", + "Raipur", + "Rajnandgaon", + "Sukma", + "Surajpur", + "Surguja", + ], + blocks: [], + }, + { + state: "Dadra and Nagar Haveli and Daman and Diu", + districts: ["Dadra and Nagar Haveli", "Daman", "Diu"], + blocks: [], + }, + { + state: "Delhi", + districts: [ + "Central Delhi", + "East Delhi", + "New Delhi", + "North Delhi", + "North East Delhi", + "North West Delhi", + "Shahdara", + "South Delhi", + "South East Delhi", + "South West Delhi", + "West Delhi", + ], + blocks: [], + }, + { + state: "Goa", + districts: ["North Goa", "South Goa"], + blocks: [], + }, + { + state: "Gujarat", + districts: [ + "Ahmedabad", + "Amreli", + "Anand", + "Aravalli", + "Banaskantha (Palanpur)", + "Bharuch", + "Bhavnagar", + "Botad", + "Chhota Udepur", + "Dahod", + "Dang", + "Devbhoomi Dwarka", + "Gandhinagar", + "Gir Somnath", + "Jamnagar", + "Junagadh", + "Kachchh", + "Kheda (Nadiad)", + "Mahisagar", + "Mehsana", + "Morbi", + "Narmada (Rajpipla)", + "Navsari", + "Panchmahal (Godhra)", + "Patan", + "Porbandar", + "Rajkot", + "Sabarkantha (Himmatnagar)", + "Surat", + "Surendranagar", + "Tapi (Vyara)", + "Vadodara", + "Valsad", + ], + blocks: [], + }, + { + state: "Haryana", + districts: [ + "Ambala", + "Bhiwani", + "Charkhi Dadri", + "Faridabad", + "Fatehabad", + "Gurugram (Gurgaon)", + "Hisar", + "Jhajjar", + "Jind", + "Kaithal", + "Karnal", + "Kurukshetra", + "Mahendragarh", + "Nuh", + "Palwal", + "Panchkula", + "Panipat", + "Rewari", + "Rohtak", + "Sirsa", + "Sonipat", + "Yamunanagar", + ], + blocks: [], + }, + { + state: "Himachal Pradesh", + districts: [ + "Bilaspur", + "Chamba", + "Hamirpur", + "Kangra", + "Kinnaur", + "Kullu", + "Lahaul and Spiti", + "Mandi", + "Shimla", + "Sirmaur (Sirmour)", + "Solan", + "Una", + ], + blocks: [], + }, + { + state: "Jammu and Kashmir", + districts: [ + "Anantnag", + "Bandipore", + "Baramulla", + "Budgam", + "Doda", + "Ganderbal", + "Jammu", + "Kathua", + "Kishtwar", + "Kulgam", + "Kupwara", + "Poonch", + "Pulwama", + "Rajouri", + "Ramban", + "Reasi", + "Samba", + "Shopian", + "Srinagar", + "Udhampur", + ], + blocks: [], + }, + { + state: "Jharkhand", + districts: [ + "Bokaro", + "Chatra", + "Deoghar", + "Dhanbad", + "Dumka", + "East Singhbhum", + "Garhwa", + "Giridih", + "Godda", + "Gumla", + "Hazaribag", + "Jamtara", + "Khunti", + "Koderma", + "Latehar", + "Lohardaga", + "Pakur", + "Palamu", + "Ramgarh", + "Ranchi", + "Sahibganj", + "Seraikela-Kharsawan", + "Simdega", + "West Singhbhum", + ], + blocks: [], + }, + { + state: "Karnataka", + districts: [ + "Bagalkot", + "Ballari (Bellary)", + "Belagavi (Belgaum)", + "Bengaluru Rural", + "Bengaluru Urban", + "Bidar", + "Chamarajanagar", + "Chikballapur", + "Chikkamagaluru (Chikmagalur)", + "Chitradurga", + "Dakshina Kannada", + "Davanagere", + "Dharwad", + "Gadag", + "Hassan", + "Haveri", + "Kalaburagi (Gulbarga)", + "Kodagu", + "Kolar", + "Koppal", + "Mandya", + "Mysuru (Mysore)", + "Raichur", + "Ramanagara", + "Shivamogga (Shimoga)", + "Tumakuru (Tumkur)", + "Udupi", + "Uttara Kannada (Karwar)", + "Vijayapura (Bijapur)", + "Yadgir", + ], + blocks: [], + }, + { + state: "Kerala", + districts: [ + "Alappuzha", + "Ernakulam", + "Idukki", + "Kannur", + "Kasaragod", + "Kollam", + "Kottayam", + "Kozhikode", + "Malappuram", + "Palakkad", + "Pathanamthitta", + "Thiruvananthapuram", + "Thrissur", + "Wayanad", + ], + blocks: [], + }, + { + state: "Ladakh", + districts: ["Kargil", "Leh"], + blocks: [], + }, + { + state: "Lakshadweep", + districts: ["Lakshadweep"], + blocks: [], + }, + { + state: "Madhya Pradesh", + districts: [ + "Agar Malwa", + "Alirajpur", + "Anuppur", + "Ashoknagar", + "Balaghat", + "Barwani", + "Betul", + "Bhind", + "Bhopal", + "Burhanpur", + "Chhatarpur", + "Chhindwara", + "Damoh", + "Datia", + "Dewas", + "Dhar", + "Dindori", + "Guna", + "Gwalior", + "Harda", + "Hoshangabad", + "Indore", + "Jabalpur", + "Jhabua", + "Katni", + "Khandwa", + "Khargone", + "Mandla", + "Mandsaur", + "Morena", + "Narsinghpur", + "Neemuch", + "Panna", + "Raisen", + "Rajgarh", + "Ratlam", + "Rewa", + "Sagar", + "Satna", + "Sehore", + "Seoni", + "Shahdol", + "Shajapur", + "Sheopur", + "Shivpuri", + "Sidhi", + "Singrauli", + "Tikamgarh", + "Ujjain", + "Umaria", + "Vidisha", + ], + blocks: [], + }, + { + state: "Maharashtra", + districts: [ + "Ahmednagar", + "Akola", + "Amravati", + "Aurangabad", + "Beed", + "Bhandara", + "Buldhana", + "Chandrapur", + "Dhule", + "Gadchiroli", + "Gondia", + "Hingoli", + "Jalgaon", + "Jalna", + "Kolhapur", + "Latur", + "Mumbai City", + "Mumbai Suburban", + "Nagpur", + "Nanded", + "Nandurbar", + "Nashik", + "Osmanabad", + "Palghar", + "Parbhani", + "Pune", + "Raigad", + "Ratnagiri", + "Sangli", + "Satara", + "Sindhudurg", + "Solapur", + "Thane", + "Wardha", + "Washim", + "Yavatmal", + ], + blocks: [ + [ + "Akola", + "Jamkhed", + "Karjat", + "Kopargaon", + "Nagar", + "Nevasa", + "Parner", + "Pathardi", + "Rahta", + "Rahuri", + "Sangamner", + "Shevgaon", + "Shrigonda", + "Shrirampur", + ], + ], + }, + { + state: "Manipur", + districts: [ + "Bishnupur", + "Chandel", + "Churachandpur", + "Imphal East", + "Imphal West", + "Jiribam", + "Kakching", + "Kamjong", + "Kangpokpi", + "Noney", + "Pherzawl", + "Senapati", + "Tamenglong", + "Tengnoupal", + "Thoubal", + "Ukhrul", + ], + blocks: [], + }, + { + state: "Meghalaya", + districts: [ + "East Garo Hills", + "East Jaintia Hills", + "East Khasi Hills", + "North Garo Hills", + "Ri Bhoi", + "South Garo Hills", + "South West Garo Hills", + "South West Khasi Hills", + "West Garo Hills", + "West Jaintia Hills", + "West Khasi Hills", + ], + blocks: [], + }, + { + state: "Mizoram", + districts: [ + "Aizawl", + "Champhai", + "Hnahthial", + "Khawzawl", + "Kolasib", + "Lawngtlai", + "Lunglei", + "Mamit", + "Saiha", + "Saitual", + "Serchhip", + ], + blocks: [], + }, + { + state: "Nagaland", + districts: [ + "Dimapur", + "Kiphire", + "Kohima", + "Longleng", + "Mokokchung", + "Mon", + "Peren", + "Phek", + "Tuensang", + "Wokha", + "Zunheboto", + ], + blocks: [], + }, + { + state: "Odisha", + districts: [ + "Angul", + "Balangir", + "Balasore", + "Bargarh", + "Bhadrak", + "Boudh", + "Cuttack", + "Deogarh", + "Dhenkanal", + "Gajapati", + "Ganjam", + "Jagatsinghpur", + "Jajpur", + "Jharsuguda", + "Kalahandi", + "Kandhamal", + "Kendrapara", + "Kendujhar (Keonjhar)", + "Khordha", + "Koraput", + "Malkangiri", + "Mayurbhanj", + "Nabarangpur", + "Nayagarh", + "Nuapada", + "Puri", + "Rayagada", + "Sambalpur", + "Subarnapur (Sonepur)", + "Sundargarh", + ], + blocks: [], + }, + { + state: "Puducherry", + districts: ["Karaikal", "Mahe", "Puducherry", "Yanam"], + blocks: [], + }, + { + state: "Punjab", + districts: [ + "Amritsar", + "Barnala", + "Bathinda", + "Faridkot", + "Fatehgarh Sahib", + "Fazilka", + "Ferozepur", + "Gurdaspur", + "Hoshiarpur", + "Jalandhar", + "Kapurthala", + "Ludhiana", + "Mansa", + "Moga", + "Muktsar", + "Pathankot", + "Patiala", + "Rupnagar", + "Sangrur", + "Shaheed Bhagat Singh Nagar (Nawanshahr)", + "Sri Muktsar Sahib", + "Tarn Taran", + ], + blocks: [], + }, + { + state: "Rajasthan", + districts: [ + "Ajmer", + "Alwar", + "Banswara", + "Baran", + "Barmer", + "Bharatpur", + "Bhilwara", + "Bikaner", + "Bundi", + "Chittorgarh", + "Churu", + "Dausa", + "Dholpur", + "Dungarpur", + "Hanumangarh", + "Jaipur", + "Jaisalmer", + "Jalore", + "Jhalawar", + "Jhunjhunu", + "Jodhpur", + "Karauli", + "Kota", + "Nagaur", + "Pali", + "Pratapgarh", + "Rajsamand", + "Sawai Madhopur", + "Sikar", + "Sirohi", + "Sri Ganganagar", + "Tonk", + "Udaipur", + ], + blocks: [], + }, + { + state: "Sikkim", + districts: ["East Sikkim", "North Sikkim", "South Sikkim", "West Sikkim"], + blocks: [], + }, + { + state: "Tamil Nadu", + districts: [ + "Ariyalur", + "Chengalpattu", + "Chennai", + "Coimbatore", + "Cuddalore", + "Dharmapuri", + "Dindigul", + "Erode", + "Kallakurichi", + "Kanchipuram", + "Kanyakumari", + "Karur", + "Krishnagiri", + "Madurai", + "Mayiladuthurai", + "Nagapattinam", + "Namakkal", + "Nilgiris", + "Perambalur", + "Pudukkottai", + "Ramanathapuram", + "Ranipet", + "Salem", + "Sivaganga", + "Tenkasi", + "Thanjavur", + "Theni", + "Thoothukudi", + "Tiruchirappalli", + "Tirunelveli", + "Tirupathur", + "Tiruppur", + "Tiruvallur", + "Tiruvannamalai", + "Tiruvarur", + "Vellore", + "Viluppuram", + "Virudhunagar", + ], + blocks: [], + }, + { + state: "Telangana", + districts: [ + "Adilabad", + "Bhadradri Kothagudem", + "Hyderabad", + "Jagtial", + "Jangaon", + "Jayashankar Bhupalpally", + "Jogulamba Gadwal", + "Kamareddy", + "Karimnagar", + "Khammam", + "Komaram Bheem Asifabad", + "Mahabubabad", + "Mahabubnagar", + "Mancherial", + "Medak", + "Medchal–Malkajgiri", + "Mulugu", + "Nagarkurnool", + "Nalgonda", + "Nirmal", + "Nizamabad", + "Peddapalli", + "Rajanna Sircilla", + "Rangareddy", + "Sangareddy", + "Siddipet", + "Suryapet", + "Vikarabad", + "Wanaparthy", + "Warangal Rural", + "Warangal Urban", + "Yadadri Bhuvanagiri", + ], + blocks: [], + }, + { + state: "Tripura", + districts: [ + "Dhalai", + "Gomati", + "Khowai", + "North Tripura", + "Sepahijala", + "South Tripura", + "Unakoti", + "West Tripura", + ], + blocks: [], + }, + { + state: "Uttar Pradesh", + districts: [ + "Agra", + "Aligarh", + "Ambedkar Nagar", + "Amethi (Chatrapati Sahuji Mahraj Nagar)", + "Amroha (J.P. Nagar)", + "Auraiya", + "Ayodhya (Faizabad)", + "Azamgarh", + "Baghpat", + "Bahraich", + "Ballia", + "Balrampur", + "Banda", + "Barabanki", + "Bareilly", + "Basti", + "Bhadohi", + "Bijnor", + "Budaun", + "Bulandshahr", + "Chandauli", + "Chitrakoot", + "Deoria", + "Etah", + "Etawah", + "Farrukhabad", + "Fatehpur", + "Firozabad", + "Gautam Buddha Nagar", + "Ghaziabad", + "Ghazipur", + "Gonda", + "Gorakhpur", + "Hamirpur", + "Hapur (Panchsheel Nagar)", + "Hardoi", + "Hathras", + "Jalaun", + "Jaunpur", + "Jhansi", + "Kannauj", + "Kanpur Dehat", + "Kanpur Nagar", + "Kasganj", + "Kaushambi", + "Kushinagar (Padrauna)", + "Lakhimpur - Kheri", + "Lalitpur", + "Lucknow", + "Maharajganj", + "Mahoba", + "Mainpuri", + "Mathura", + "Mau", + "Meerut", + "Mirzapur", + "Moradabad", + "Muzaffarnagar", + "Pilibhit", + "Pratapgarh", + "Prayagraj (Allahabad)", + "Rae Bareli", + "Rampur", + "Saharanpur", + "Sambhal (Bhim Nagar)", + "Sant Kabir Nagar", + "Shahjahanpur", + "Shamli", + "Shrawasti", + "Siddharthnagar", + "Sitapur", + "Sonbhadra", + "Sultanpur", + "Unnao", + "Varanasi", + ], + blocks: [], + }, + { + state: "Uttarakhand", + districts: [ + "Almora", + "Bageshwar", + "Chamoli", + "Champawat", + "Dehradun", + "Haridwar", + "Nainital", + "Pauri Garhwal", + "Pithoragarh", + "Rudraprayag", + "Tehri Garhwal", + "Udham Singh Nagar", + "Uttarkashi", + ], + blocks: [], + }, + { + state: "West Bengal", + districts: [ + "Alipurduar", + "Bankura", + "Birbhum", + "Cooch Behar", + "Dakshin Dinajpur (South Dinajpur)", + "Darjeeling", + "Hooghly", + "Howrah", + "Jalpaiguri", + "Jhargram", + "Kalimpong", + "Kolkata", + "Malda", + "Murshidabad", + "Nadia", + "North 24 Parganas", + "Paschim Medinipur (West Medinipur)", + "Paschim (West) Burdwan (Bardhaman)", + "Purba Burdwan (Bardhaman)", + "Purba Medinipur (East Medinipur)", + "Purulia", + "South 24 Parganas", + "Uttar Dinajpur (North Dinajpur)", + ], + blocks: [], + }, +]; + +export default StateData; diff --git a/src/pages/state.tsx b/src/pages/state.tsx new file mode 100644 index 00000000..4ec651e6 --- /dev/null +++ b/src/pages/state.tsx @@ -0,0 +1,102 @@ +import React, { useState } from "react"; +import KaTableComponent from "../components/KaTableComponent"; +import { DataType } from "ka-table/enums"; +import { serverSideTranslations } from "next-i18next/serverSideTranslations"; +import UserComponent from "@/components/UserComponent"; +import StateData from "./dummyAPI/stateData"; +import Pagination from "@mui/material/Pagination"; +import { SelectChangeEvent } from "@mui/material/Select"; +import PageSizeSelector from "@/components/PageSelector"; +import { useTranslation } from "next-i18next"; + +type StateDetails = { + state: string; + districts: DistrictDetails[]; +}; + +type DistrictDetails = { + district: string; + blocks: BlockDetails[]; +}; + +type BlockDetails = { + block: string; +}; + +const State: React.FC = () => { + const { t } = useTranslation(); + const [selectedState, setSelectedState] = useState("All states"); + const [pageOffset, setPageOffset] = useState(0); + const [pageLimit, setPageLimit] = useState(10); + const [stateData, setStateData] = useState(StateData); + const [selectedSort, setSelectedSort] = useState(t("MASTER.SORT")); + const [pageSize, setPageSize] = useState(""); + + const columns = [ + { + key: "state", + title: t("MASTER.STATE"), + dataType: DataType.String, + }, + ]; + + const handleChange = (event: SelectChangeEvent) => { + setPageSize(event.target.value); + setPageLimit(Number(event.target.value)); + }; + + const handlePaginationChange = ( + event: React.ChangeEvent, + value: number + ) => { + setPageOffset(value - 1); + }; + + const handleStateChange = (event: SelectChangeEvent) => { + setSelectedState(event.target.value as string); + }; + + const userProps = { + userType: t("MASTER.STATE"), + searchPlaceHolder: t("MASTER.SEARCHBAR_PLACEHOLDER_STATE"), + selectedState: selectedState, + selectedSort: selectedSort, + handleStateChange: handleStateChange, + states: stateData.map((stateDetail) => stateDetail.state), + showStateDropdown: false, + }; + + return ( + + ({ + state: stateDetail.state, + }))} + limit={pageLimit} + offset={pageOffset * pageLimit} + PagesSelector={() => ( + + )} + PageSizeSelector={() => ( + + )} + /> + + ); +}; + +export async function getStaticProps({ locale }: any) { + return { + props: { + ...(await serverSideTranslations(locale, ["common"])), + }, + }; +} + +export default State;