Skip to content

Commit

Permalink
Task #223474: Add type of Cohort , remove pagination upon less cohort…
Browse files Browse the repository at this point in the history
…,add new center to new center,remote/ regular type of cohort,center yo centers
  • Loading branch information
upendraTekdi committed Aug 6, 2024
1 parent 5b616f7 commit 19b2a0f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
7 changes: 4 additions & 3 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"DASHBOARD": "Dashboard",
"MANAGE_USERS": "Manage Users",
"COURSE_PLANNER": "Course Planner",
"CENTER": "Center",
"CENTER": "Centers",
"FACILITATORS": "Facilitators",
"LEARNERS": "Learners",
"TEAM_LEADERS": "Team Leaders",
Expand Down Expand Up @@ -176,7 +176,7 @@
"RENAME": "Rename",
"CENTER_RENAMED": "Center Renamed Successfully!",
"SEND_REQUEST": "Send Request",
"SURE_DELETE_CENTER": "Are you sure you want to Delete Center ?",
"SURE_DELETE_CENTER": "Are you sure you want to Delete Center?",
"CENTER_UPDATE_SUCCESSFULLY": "Center has been Successfully Updated",
"CENTER_DELETE_SUCCESSFULLY": "Center has been Successfully Deleted",
"CENTER_CREATED_SUCCESSFULLY": "Center Created Successfully",
Expand Down Expand Up @@ -245,7 +245,7 @@
"DESIGNATION": "Designation",
"REGULAR": "Regular",
"REMOTE": "Remote",
"NOTE_THIS_WILL_BE_CENTER_NAME": "Note : This Will Be Center Name",
"NOTE_THIS_WILL_BE_CENTER_NAME": "Note : This will be center name",
"STATE": "State",
"DISTRICT": "District",
"BLOCK": "Block",
Expand All @@ -254,6 +254,7 @@
"NAME": "Name",
"MOBILE_NUMBER": "Mobile Number",
"CENTER": "Center"

},
"FORM_ERROR_MESSAGES": {
"INVALID_INPUT": "Invalid Input.",
Expand Down
7 changes: 7 additions & 0 deletions src/data/tableColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ export const getCenterTableData = (t: any, isMobile: any) => {
width: isMobile ? 95 : "",
},

{
key: "customFieldValues",
title: t("FORM.TYPE_OF_COHORT"),
dataType: DataType.String,
sortDirection: SortDirection.Ascend,
width: isMobile ? 95 : "",
},
{
key: "actions",
title: t("TABLE_TITLE.ACTIONS"),
Expand Down
37 changes: 33 additions & 4 deletions src/pages/centers.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ChangeEvent, useState, useEffect } from "react";
import React, { ChangeEvent, useState, useEffect, useCallback } from "react";
import KaTableComponent from "../components/KaTableComponent";
import { DataType, SortDirection } from "ka-table/enums";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
Expand All @@ -25,15 +25,26 @@ import { showToastMessage } from "@/components/Toastify";
import AddNewCenters from "@/components/AddNewCenters";
import { getCenterTableData } from "@/data/tableColumns";
import { Theme } from "@mui/system";
import { debounce, firstLetterInUpperCase } from "@/utils/Helper";

type cohortFilterDetails = {
type?: string;
status?: any;
states?: string;
districts?: string;
blocks?: string;
name?:string
};

interface centerData {
name?: string;
status?: string;
updatedBy?: string;
createdBy?: string;
createdAt?: string;
updatedAt?: string;
customFieldValues?: string;
}
interface CohortDetails {
name?: string;
type?: string;
Expand Down Expand Up @@ -79,6 +90,7 @@ const Center: React.FC = () => {
const [selectedDistrictCode, setSelectedDistrictCode] = useState("");
const [selectedBlockCode, setSelectedBlockCode] = useState("");
const [formdata, setFormData] = useState<any>();
const [totalCount,setTotalCound] = useState<number>(0)
const handleCloseAddLearnerModal = () => {
setOpenAddNewCohort(false);
};
Expand Down Expand Up @@ -111,9 +123,26 @@ const Center: React.FC = () => {
const resp = await getCohortList(data);
if (resp) {
const result = resp?.results?.cohortDetails;
setCohortData(result);
const resultData:centerData[] = []
result?.forEach((item:any)=>{
const cohortType = item?.customFields?.map((field:any) => firstLetterInUpperCase(field?.value))
const requiredData = {
name:item?.name,
status:item?.status,
updatedBy: item?.updatedBy,
createdBy: item?.createdBy,
createdAt: item?.createdAt,
updatedAt: item?.updatedAt,
customFieldValues:cohortType || ""
}
resultData?.push(requiredData)
})
setCohortData(resultData);
const totalCount = resp?.count;
if (totalCount >= 15) {
setTotalCound(totalCount)
if (totalCount >= 20) {
setPageSizeArray([5, 10, 15,20]);
}else if (totalCount >= 15) {
setPageSizeArray([5, 10, 15]);
} else if (totalCount >= 10) {
setPageSizeArray([5, 10]);
Expand Down Expand Up @@ -504,7 +533,7 @@ const Center: React.FC = () => {
data={cohortData}
limit={pageLimit}
offset={pageOffset}
paginationEnable={true}
paginationEnable={totalCount > 5 }
PagesSelector={PagesSelector}
PageSizeSelector={PageSizeSelectorFunction}
pageSizes={pageSizeArray}
Expand Down

0 comments on commit 19b2a0f

Please sign in to comment.