Skip to content

Commit

Permalink
Merge pull request #14 from chaitanyakole/bug_fixes2
Browse files Browse the repository at this point in the history
Changes in Update cohort, and other
  • Loading branch information
sudeeppr1998 authored Dec 26, 2024
2 parents e7221f4 + c3f8e6c commit 3c78bdc
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/components/PageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Select, { SelectChangeEvent } from "@mui/material/Select";
import { useTranslation } from "next-i18next";
import React from "react";


export interface IPageSelectorProps {
handleChange: (event: SelectChangeEvent) => void;
pageSize: number;
Expand All @@ -26,7 +25,9 @@ const PageSizeSelector = ({ handleChange, pageSize, options }: any) => {

return (
<FormControl sx={{ m: 1, minWidth: 120 }}>
<InputLabel id="page-size-selector-label">{t("COMMON.PAGE_SIZE")}</InputLabel>
<InputLabel id="page-size-selector-label">
{t("COMMON.PAGE_SIZE")}
</InputLabel>
<Select
labelId="page-size-selector-label"
id="page-size-selector"
Expand Down
34 changes: 34 additions & 0 deletions src/pages/cohortUpdateSchema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"type": "object",
"required": ["name", "status", "type"],
"properties": {
"name": {
"title": "Cohort Name",
"type": "string",
"fieldId": null,
"validation": [],
"description": "Enter the cohort name."
},
"type": {
"title": "Type",
"type": "string",
"default": "cohort",
"fieldId": null,
"validation": [],
"description": "Indicates the type of user or entity."
},

"status": {
"title": "Status",
"type": "string",
"oneOf": [
{ "const": "active", "title": "Active" },
{ "const": "inactive", "title": "Inactive" },
{ "const": "archived", "title": "Archived" }
],
"default": "active",
"validation": [],
"description": "The current status of the cohort, this field is read-only."
}
}
}
10 changes: 6 additions & 4 deletions src/pages/cohorts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import cohortSchema from "./cohortSchema.json";
import AddIcon from "@mui/icons-material/Add";
import userJsonSchema from "./userSchema.json";
import cohortASchema from "./cohortAdminSchema.json";
import updateCohortSchema from "./cohortUpdateSchema.json";

type cohortFilterDetails = {
type?: string;
Expand Down Expand Up @@ -112,6 +113,7 @@ const Center: React.FC = () => {
const [userId, setUserId] = useState("");
const [adminRole, setAdminRole] = useState<boolean>();
const [schema] = React.useState(cohortSchema);
const [cohortUpdateSchema] = React.useState(updateCohortSchema);
const [userSchema, setUserSchema] = React.useState(userJsonSchema);
const [openAddNewCohort, setOpenAddNewCohort] =
React.useState<boolean>(false);
Expand Down Expand Up @@ -1402,9 +1404,9 @@ const Center: React.FC = () => {
showFooter={false}
modalTitle={t("COHORTS.UPDATE_COHORT")}
>
{schema && uiSchema && (
{cohortUpdateSchema && uiSchema && (
<DynamicForm
schema={schema}
schema={cohortUpdateSchema}
uiSchema={uiSchema}
onSubmit={handleUpdateAction}
onChange={handleChangeForm}
Expand All @@ -1419,14 +1421,14 @@ const Center: React.FC = () => {
style={{
display: "flex",
justifyContent: "right", // Centers the button horizontally
marginTop: "20px", // Adjust margin as needed
marginTop: "20px",
}}
gap={2}
>
<Button
variant="outlined"
type="submit"
form="update-center-form" // Add this line
form="update-center-form"
sx={{
fontSize: "14px",
fontWeight: "500",
Expand Down
25 changes: 14 additions & 11 deletions src/pages/tenant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,21 @@ const Tenant: React.FC = () => {

setCohortData(resultData);
const totalCount = resp.length;

// setTotalCount(totalCount); // Set the total count

setPagination(totalCount > 10);
setPageSizeArray(
totalCount > 15
? [5, 10, 15]
: totalCount > 10
? [5, 10]
: totalCount > 5
? [5]
: []
);
setPagination(totalCount >= 10);
let pageSizeArrayCount: any = [];

if (totalCount > 15) {
pageSizeArrayCount = [5, 10, 15];
} else if (totalCount >= 10) {
pageSizeArrayCount = [5, 10];
} else if (totalCount > 5) {
pageSizeArrayCount = [5];
}

setPageSizeArray(pageSizeArrayCount);
const pageCount = Math.ceil(totalCount / pageLimit);
setPageCount(pageCount);
} else {
Expand Down Expand Up @@ -1380,7 +1383,7 @@ const Tenant: React.FC = () => {
limit={pageLimit}
roleButton
offset={pageOffset}
paginationEnable={totalCount > Numbers.TEN}
paginationEnable={totalCount >= Numbers.TEN}
PagesSelector={PagesSelector}
pagination={pagination}
PageSizeSelector={PageSizeSelectorFunction}
Expand Down

0 comments on commit 3c78bdc

Please sign in to comment.