Skip to content

Commit

Permalink
Merge pull request #156 from AkshataKatwal16/admin
Browse files Browse the repository at this point in the history
Issue PS-1474: Reassign block and center to user
  • Loading branch information
itsvick authored Aug 24, 2024
2 parents 1351001 + 70fed35 commit 38ed193
Show file tree
Hide file tree
Showing 9 changed files with 486 additions and 33 deletions.
14 changes: 14 additions & 0 deletions public/images/apartment.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,17 @@
"OKAY": "okay",
"NEW": "New {{role}}",
"USER_CREDENTIAL_SEND_SUCCESSFULLY": "User credentials sent successfully!",
"USER_CREDENTIALS_WILL_BE_SEND_SOON":"User credentials will be sent soon"
"USER_CREDENTIALS_WILL_BE_SEND_SOON":"User credentials will be sent soon",

"REASSIGN_CENTERS": "Re-assign Center",
"REASSIGN_BLOCKS": "Re-assign Blocks",
"REASSIGN":"Reassign",
"COHORT_ID_NOT_FOUND": "Could not found cohort Id for {{block}} ",
"CENTERS_REASSIGN_SUCCESSFULLY": "Center reassign successfully",
"BLOCKS_REASSIGN_SUCCESSFULLY": "Block reassign successfully",
"CENTERS_REASSIGN_FAILED":"Center Reassignment fails",
"BLOCKS_REASSIGN_FAILED":"Block Reassignment fails"


},
"LOGIN_PAGE": {
Expand Down Expand Up @@ -239,6 +249,8 @@
"CENTER_CREATED_SUCCESSFULLY": "Center Created Successfully",
"SEARCHBAR_PLACEHOLDER": "Search Center..",
"CENTER_UPDATE_FAILED": "Something went wrong while updating center"



},
"FORM": {
Expand Down
33 changes: 33 additions & 0 deletions src/components/ActionIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,29 @@ import EditIcon from "@mui/icons-material/Edit";
import DeleteIcon from "@mui/icons-material/Delete";
import deleteIcon from '../../public/images/deleteIcon.svg';
import editIcon from '../../public/images/editIcon.svg';
import cohortIcon from '../../public/images/apartment.svg';


import Image from "next/image";

interface ActionCellProps {
onEdit: (rowData: any) => void;
onDelete: (rowData: any) => void;
reassignCohort?: (rowData: any) => void;
reassignType?: string;
rowData: any;
disable: boolean;
userAction?:boolean
}

const ActionIcon: React.FC<ActionCellProps> = ({
rowData,
onEdit,
onDelete,
reassignCohort,
userAction=false,
disable = false,
reassignType
}) => {
const { t } = useTranslation();
const theme = useTheme<any>();
Expand Down Expand Up @@ -78,6 +86,31 @@ const ActionIcon: React.FC<ActionCellProps> = ({
</Typography> */}
</Box>
</Tooltip>

{ userAction && ( <Tooltip title={reassignType}>
<Box
onClick={() => {
if(reassignCohort)
reassignCohort(rowData);
}}
sx={{
display: "flex",
flexDirection: "column",
alignItems: "center",
cursor: "pointer",
color: disable ? theme?.palette?.secondary.contrastText : "",
backgroundColor:"#E5E5E5",
p:"10px"
}}
>
<Image src={cohortIcon} alt="" />
{/*
<Typography variant="body2" fontFamily={"Poppins"}>
{t("COMMON.DELETE")}
</Typography> */}
</Box>
</Tooltip>)}

</Box>
);
};
Expand Down
7 changes: 7 additions & 0 deletions src/components/KaTableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface KaTableComponentProps {
pageSizes?: any;
onDelete?: any;
onEdit?: any;
reassignCohort?: any;
onChange?: any;
extraActions: {
name: string;
Expand All @@ -37,6 +38,7 @@ interface KaTableComponentProps {
showIcons?: boolean;
noDataMessage?: any;
pagination?: boolean;

}

const KaTableComponent: React.FC<KaTableComponentProps> = ({
Expand All @@ -48,6 +50,7 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
paginationEnable = true,
onEdit,
onDelete,
reassignCohort,
pageSizes,
noDataMessage,
pagination = true,
Expand All @@ -57,6 +60,7 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
const isMobile = useMediaQuery((theme: Theme) =>
theme.breakpoints.down("sm")
);
console.log(columns)

const handleCheckboxChange = (rowId: number) => {
setSelectedRowIds((prevSelected) =>
Expand Down Expand Up @@ -105,11 +109,14 @@ const KaTableComponent: React.FC<KaTableComponentProps> = ({
cell: {
content: (props) => {
if (props.column.key === DataKey.ACTIONS) {
console.log(props.rowData)
return (
<ActionIcon
rowData={props.rowData}
onEdit={onEdit}
reassignCohort={reassignCohort}
onDelete={onDelete}
userAction={props.rowData?.userId}
disable={props.rowData?.status === Status.ARCHIVED}
/>
);
Expand Down
Loading

0 comments on commit 38ed193

Please sign in to comment.