Skip to content

Commit

Permalink
Merge pull request #145 from upendraTekdi/admin_uk
Browse files Browse the repository at this point in the history
Task #223476: add active members and archieved member on list , bydefault active selected
  • Loading branch information
itsvick authored Aug 20, 2024
2 parents b9d1339 + 67c796b commit 74846fa
Show file tree
Hide file tree
Showing 10 changed files with 233 additions and 65 deletions.
4 changes: 3 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@
"CENTER_DELETE_SUCCESSFULLY": "Center has been Successfully Deleted",
"CENTER_CREATED_SUCCESSFULLY": "Center Created Successfully",
"SEARCHBAR_PLACEHOLDER": "Search Center..",
"CENTER_UPDATE_FAILED": "Something went wrong while updating center"
"CENTER_UPDATE_FAILED": "Something went wrong while updating center",
"ARCHIVED_MEMBERS": "Archived Members:",
"ACTIVE_MEMBERS": "Active Members"
},
"FORM": {
"FULL_NAME": "Full Name",
Expand Down
8 changes: 4 additions & 4 deletions src/components/AddNewCenters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "@/components/GeneratedSchemas";
import SimpleModal from "@/components/SimpleModal";
import { getFormRead } from "@/services/CreateUserService";
import { CohortTypes } from "@/utils/app.constant";
import { CohortTypes, FormContextType } from "@/utils/app.constant";
import { useLocationState } from "@/utils/useLocationState";
import { Box, Button, Typography } from "@mui/material";
import { IChangeEvent } from "@rjsf/core";
Expand Down Expand Up @@ -53,6 +53,7 @@ const AddNewCenters: React.FC<AddLearnerModalProps> = ({
React.useState<boolean>(false);

const { t } = useTranslation();
const roleType = FormContextType.ADMIN_CENTER;
const {
states,
districts,
Expand All @@ -76,8 +77,7 @@ const AddNewCenters: React.FC<AddLearnerModalProps> = ({
selectedStateCode,
selectedBlockCode,
dynamicFormForBlock,
stateDefaultValue
} = useLocationState(open, onClose);
} = useLocationState(open, onClose, roleType);
const setSubmittedButtonStatus = useSubmittedButtonStore(
(state: any) => state.setSubmittedButtonStatus
);
Expand Down Expand Up @@ -123,6 +123,7 @@ const AddNewCenters: React.FC<AddLearnerModalProps> = ({
) => {
const formData = data?.formData;
console.log("selectedBlockCohortId", selectedBlockCohortId);

if (selectedBlockCohortId) {
const parentId = selectedBlockCohortId;
const cohortDetails: CohortDetails = {
Expand Down Expand Up @@ -249,7 +250,6 @@ const AddNewCenters: React.FC<AddLearnerModalProps> = ({
height: "40px",
marginLeft: "10px",
}}

onClick={onClose}
>
{t("COMMON.CANCEL")}
Expand Down
28 changes: 26 additions & 2 deletions src/components/KaTableComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { firstLetterInUpperCase } from "@/utils/Helper";
import { DataKey, DateFormat, Status } from "@/utils/app.constant";
import { Checkbox, Chip, Paper, Theme, useMediaQuery } from "@mui/material";
import {
Checkbox,
Chip,
Paper,
Theme,
Typography,
useMediaQuery,
} from "@mui/material";
import { format } from "date-fns";
import { ITableProps, Table } from "ka-table";
import { PagingPosition, SortDirection, SortingMode } from "ka-table/enums";
Expand Down Expand Up @@ -81,7 +88,8 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
{...tableProps}
childComponents={{
pagingSizes: {
content: (props) =>!isMobile? (<PageSizeSelector {...props} />): (<></>),
content: (props) =>
!isMobile ? <PageSizeSelector {...props} /> : <></>,
},

sortIcon: {
Expand Down Expand Up @@ -120,6 +128,22 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
return <UserNameCell userId={props.rowData?.createdBy} />;
} else if (props.column.key === DataKey.UPDATED_BY) {
return <UserNameCell userId={props?.rowData?.updatedBy} />;
} else if (props.column.key === DataKey.ACTIVE_MEMBER) {
return (
<Typography color={"green"}>
{props.rowData?.totalActiveMembers
? props.rowData?.totalActiveMembers
: "-"}
</Typography>
);
} else if (props.column.key === DataKey.ARCHIVED_MEMBERS) {
return (
<Typography color={"error"}>
{props.rowData?.totalArchivedMembers
? props.rowData?.totalArchivedMembers
: "-"}
</Typography>
);
}
if (props.column.key === DataKey.STATUS) {
if (props.rowData?.status === Status.ARCHIVED) {
Expand Down
24 changes: 15 additions & 9 deletions src/data/tableColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,21 @@ export const getTLTableColumns = (t: any, isMobile: boolean) => {

export const getCenterTableData = (t: any, isMobile: boolean) => {
const configs: ColumnConfig[] = [
{ key: "name", titleKey: "TABLE_TITLE.NAME", width: 95 },
{ key: "status", titleKey: "TABLE_TITLE.STATUS", width: 95},
{ key: "updatedBy", titleKey: "TABLE_TITLE.UPDATED_BY", width: 95 },
{ key: "createdBy", titleKey: "TABLE_TITLE.CREATED_BY", width: 95 },
{ key: "createdAt", titleKey: "TABLE_TITLE.CREATED_DATE", width: 95 },
{ key: "updatedAt", titleKey: "TABLE_TITLE.UPDATED_DATE", width: 95 },
{ key: "customFieldValues", titleKey: "FORM.TYPE_OF_COHORT", width: 95 },
{ key: "actions", titleKey: "TABLE_TITLE.ACTIONS", width: 125 , isSortable: false}

{ key: "name", titleKey: "TABLE_TITLE.NAME", width: 130 },
{ key: "customFieldValues", titleKey: "TABLE_TITLE.TYPE", width: 130 },
{ key: "status", titleKey: "TABLE_TITLE.STATUS", width: 130 },
{ key: "updatedBy", titleKey: "TABLE_TITLE.UPDATED_BY", width: 130 },
{ key: "createdBy", titleKey: "TABLE_TITLE.CREATED_BY", width: 130 },
{ key: "createdAt", titleKey: "TABLE_TITLE.CREATED_DATE", width: 130 },
{ key: "updatedAt", titleKey: "TABLE_TITLE.UPDATED_DATE", width: 130 },

{ key: "totalActiveMembers", titleKey: "Active Members", width: 130 },
{
key: "totalArchivedMembers",
titleKey: "Archived Members",
width: 130,
},
{ key: "actions", titleKey: "TABLE_TITLE.ACTIONS", width: 125 },
];

return generateColumns(t, configs, isMobile);
Expand Down
Loading

0 comments on commit 74846fa

Please sign in to comment.