Skip to content

Commit

Permalink
Merge pull request #79 from upendraTekdi/cohort_list
Browse files Browse the repository at this point in the history
Task #223475: change names cohorts to centers,optimize function for firstLetterUppercase , font family changes , update status imediately after delete center
  • Loading branch information
itsvick authored Aug 1, 2024
2 parents 3397cfb + af4c40a commit b6ac985
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 34 deletions.
13 changes: 7 additions & 6 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"SURE_REASSIGN_CENTER": "Are you sure you want to re-assign Center to this user?",
"OTHER": "Other",
"SORT": "Sort",
"EDIT_COHORT_NAME": "Edit Center",
"EDIT_CENTER_NAME": "Edit Center",
"NAME": "Name",
"UPDATE_COHORT": "Update Center",
"UPDATE_CENTER": "Update Center",
"EDIT": "Edit",
"DELETE": "Delete",
"NO_DATA_FOUND": "No data found",
Expand Down Expand Up @@ -59,7 +59,7 @@
"DASHBOARD": "Dashboard",
"MANAGE_USERS": "Manage Users",
"COURSE_PLANNER": "Course Planner",
"COHORTS": "Center",
"CENTER": "Center",
"FACILITATORS": "Facilitators",
"LEARNERS": "Learners",
"TEAM_LEADERS": "Team Leaders",
Expand Down Expand Up @@ -148,10 +148,11 @@
"RENAME": "Rename",
"CENTER_RENAMED": "Center Renamed Successfully!",
"SEND_REQUEST": "Send Request",
"SURE_DELETE_COHORT": "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"
"CENTER_CREATED_SUCCESSFULLY": "Center Created Successfully",
"SEARCHBAR_PLACEHOLDER": "Search Center.."
},
"FORM": {
"FULL_NAME": "Full Name",
Expand Down Expand Up @@ -207,7 +208,7 @@
"EMAIL": "Email",
"YEAR_OF_JOINING_SCP": "Year of joining SCP",
"ASSIGN_CENTERS": "Assign Centers",
"TYPE_OF_COHORT": "Type Of Center List",
"TYPE_OF_COHORT": "Type Of Center",
"UNIT_NAME": "Unit Name",
"SUBJECTS_I_TEACH": "Subject I Teach",
"MY_MAIN_SUBJECTS": "Main subjects",
Expand Down
6 changes: 4 additions & 2 deletions src/components/ActionIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ const ActionIcon: React.FC<ActionCellProps> = ({
}}
>
<EditIcon />
<Typography variant="body2">{t("COMMON.EDIT")}</Typography>
<Typography variant="body2" fontFamily={"Poppins"}>
{t("COMMON.EDIT")}
</Typography>
</Box>
</Tooltip>
<Tooltip title={t("COMMON.DELETE")}>
Expand All @@ -72,7 +74,7 @@ const ActionIcon: React.FC<ActionCellProps> = ({
: "rgb(244, 67, 54)",
}}
/>
<Typography variant="body2">{t("COMMON.DELETE")}</Typography>
<Typography variant="body2" fontFamily={"Poppins"}>{t("COMMON.DELETE")}</Typography>
</Box>
</Tooltip>
</Box>
Expand Down
16 changes: 12 additions & 4 deletions src/components/KaTableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
},
cell: {
content: (props) => {
if (
props.column.key === DataKey.ACTIONS

) {
if (props.column.key === DataKey.ACTIONS) {
return (
<ActionIcon
rowData={props.rowData}
Expand Down Expand Up @@ -146,6 +143,17 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
);
}
}
if (props.column.key === DataKey.NAME) {
return firtstLetterInUpperCase(props.rowData?.name)
}
if (props.column.key === "selection-cell") {
return (
<Checkbox
checked={selectedRowIds.includes(props.rowData.id)}
onChange={() => handleCheckboxChange(props.rowData.id)}
/>
);
}
// if (props.column.key === "selection-cell") {
// return (
// <Checkbox
Expand Down
4 changes: 2 additions & 2 deletions src/components/layouts/sidebar/MenuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const Menuitems = [
},

{
title: "SIDEBAR.COHORTS",
title: "SIDEBAR.CENTER",
icon: "users",
href: "/cohorts",
href: "/centers",
},

{
Expand Down
30 changes: 20 additions & 10 deletions src/pages/cohorts.tsx → src/pages/centers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ interface CohortDetails {
customFields?: CustomField[];
}

const Cohorts: React.FC = () => {
const Center: React.FC = () => {
// use hooks
const { t } = useTranslation();

Expand Down Expand Up @@ -111,7 +111,7 @@ const Cohorts: React.FC = () => {
const [selectedBlock, setSelectedBlock] = React.useState<string[]>([]);
const [selectedSort, setSelectedSort] = useState("Sort");
const [selectedFilter, setSelectedFilter] = useState("All");
const [cohortData, setCohortData] = useState<UserDetails[]>([]);
const [cohortData, setCohortData] = useState<cohortFilterDetails[]>([]);
const [pageSize, setPageSize] = React.useState<string | number>("10");
const [open, setOpen] = React.useState(false);
const [confirmationModalOpen, setConfirmationModalOpen] =
Expand Down Expand Up @@ -363,14 +363,24 @@ const Cohorts: React.FC = () => {
const resp = await updateCohortUpdate(selectedCohortId, cohortDetails);
console.log(resp);
if (resp?.responseCode === 200) {
console.log(resp?.params?.successmessage);
showToastMessage(t("CENTERS.CENTER_DELETE_SUCCESSFULLY"), "success");
fetchUserList();
const cohort = cohortData?.find(
(item: any) => item.cohortId == selectedCohortId
);
if (cohort) {
cohort.status = Status.ARCHIVED;
}
// setCohortData(updatedCohorts);
console.log(resp?.params?.successmessage);

// fetchUserList();
} else {
console.log("Cohort Not Archived");
}
setSelectedCohortId("");
} else {
console.log("No Cohort Selected");
setSelectedCohortId("");
}
};

Expand Down Expand Up @@ -546,8 +556,8 @@ const Cohorts: React.FC = () => {

// props to send in header
const userProps = {
userType: t("SIDEBAR.COHORTS"),
searchPlaceHolder: t("COHORTS.SEARCHBAR_PLACEHOLDER"),
userType: t("SIDEBAR.CENTER"),
searchPlaceHolder: t("CENTERS.SEARCHBAR_PLACEHOLDER"),
selectedState: selectedState,
selectedStateCode: selectedStateCode,
selectedDistrict: selectedDistrict,
Expand All @@ -568,9 +578,9 @@ const Cohorts: React.FC = () => {
<CustomModal
open={editModelOpen}
handleClose={onCloseEditMOdel}
title={t("COMMON.EDIT_COHORT_NAME")}
title={t("COMMON.EDIT_CENTER_NAME")}
// subtitle={t("COMMON.NAME")}
primaryBtnText={t("COMMON.UPDATE_COHORT")}
primaryBtnText={t("COMMON.UPDATE_CENTER")}
secondaryBtnText="Cancel"
primaryBtnClick={handleUpdateAction}
primaryBtnDisabled={confirmButtonDisable}
Expand All @@ -587,7 +597,7 @@ const Cohorts: React.FC = () => {
</Box>
</CustomModal>
<ConfirmationModal
message={t("CENTERS.SURE_DELETE_COHORT")}
message={t("CENTERS.SURE_DELETE_CENTER")}
handleAction={handleActionForDelete}
buttonNames={{
primary: t("COMMON.YES"),
Expand Down Expand Up @@ -658,4 +668,4 @@ export async function getStaticProps({ locale }: any) {
};
}

export default Cohorts;
export default Center;
8 changes: 6 additions & 2 deletions src/styles/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
}

.table-header {
font-family: "Poppins", sans-serif;
font-family: "Poppins", sans-serif !important;
font-size: small;
}

.table-cell {
font-family: "Poppins", sans-serif;
font-family: "Poppins", sans-serif !important;
font-size: small;
}

.ka-table {
font-family: "Poppins" !important;
}
15 changes: 7 additions & 8 deletions src/utils/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,15 @@ export const transformArray = (arr: State[]): State[] => {
}));
};

export const firtstLetterInUpperCase = (label: string) => {
if (label) {
const firstLetter = label.charAt(0);
const firstLetterCap = firstLetter.toUpperCase();
const remainingLetters = label.slice(1);
const firstUpperCaseLetter = firstLetterCap + remainingLetters;
return firstUpperCaseLetter;
} else {
export const firtstLetterInUpperCase = (label: string): string | null => {
if (!label) {
return null;
}

return label
?.split(" ")
?.map((word) => word?.charAt(0).toUpperCase() + word?.slice(1))
?.join(" ");
};
export const capitalizeFirstLetterOfEachWordInArray = (arr: string[]): string[] => {
console.log(arr)
Expand Down
1 change: 1 addition & 0 deletions src/utils/app.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export enum DataKey {
CREATEDBY = "createdBy",
UPDATEDBY = "updatedBy",
STATUS = "status",
NAME = "name",
}

export enum DateFormat {
Expand Down

0 comments on commit b6ac985

Please sign in to comment.