Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to inbox codes #1904

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TimelinePopUpWrapper from "./timelinePopUpWrapper";
import { CustomSVG } from "@egovernments/digit-ui-components";
import { CheckBox } from "@egovernments/digit-ui-components";
import EditVillagePopulationPopUp from "./editVillagePopulationPopUP";
import { tableCustomStyle,getTableCustomStyle } from "./tableCustomStyle";
import { tableCustomStyle, getTableCustomStyle } from "./tableCustomStyle";
import { CustomLoader } from "./RoleTableComposer";
import { min } from "lodash";
import VillageHierarchyTooltipWrapper from "./VillageHierarchyTooltipWrapper";
Expand All @@ -26,23 +26,24 @@ const PopInboxTable = ({ ...props }) => {
const [selectedBoundaryCode, setSelectedBoundaryCode] = useState(null);

const columns = useMemo(() => {

return [
{
name: t(`INBOX_VILLAGE`),
cell: (row, index, column, id) => (
<div style={{display:"flex", gap:".5rem"}} className="village-tooltip-wrap">
<Button
label={t(`${row.boundaryCode}`)}
onClick={() =>
history.push(`/${window.contextPath}/employee/microplan/village-view?microplanId=${url?.microplanId}&boundaryCode=${row.boundaryCode}&campaignId=${url?.campaignId}`)
}
title={t(`${row.boundaryCode}`)}
variation="link"
size={"medium"}
style={{ minWidth: "unset" }}
/>
<VillageHierarchyTooltipWrapper boundaryCode={row?.boundaryCode} wrapperClassName={"village-hierarchy-tooltip-wrapper-class"}/>
<div style={{ display: "flex", gap: ".5rem" }} className="village-tooltip-wrap">
<Button
label={t(`${row.boundaryCode}`)}
onClick={() =>
history.push(
`/${window.contextPath}/employee/microplan/village-view?microplanId=${url?.microplanId}&boundaryCode=${row.boundaryCode}&campaignId=${url?.campaignId}`
)
}
title={t(`${row.boundaryCode}`)}
variation="link"
size={"medium"}
style={{ minWidth: "unset" }}
/>
<VillageHierarchyTooltipWrapper boundaryCode={row?.boundaryCode} wrapperClassName={"village-hierarchy-tooltip-wrapper-class"} />
</div>
),
// selector:(row, index)=>row.boundaryCode,
Expand All @@ -60,51 +61,47 @@ const PopInboxTable = ({ ...props }) => {
name: t("INBOX_ASSIGNEE"),
selector: (row, index) =>
row?.assignee?.length > 0 ? (
<AssigneeChips
assignees={row?.assignee}
assigneeNames={props?.employeeNameData}
heading={t("HCM_MICROPLAN_POP_INBOX_TOTAL_ASSIGNEES")}
/>
<AssigneeChips assignees={row?.assignee} assigneeNames={props?.employeeNameData} heading={t("HCM_MICROPLAN_POP_INBOX_TOTAL_ASSIGNEES")} />
) : (
t("ES_COMMON_NA")
t("ES_COMMON_NA")
),
sortable: true,
width: "180px",
},
...(
(props?.censusData?.[0]?.additionalFields || [])
.filter((field) => field.showOnUi)
.sort((a, b) => a.order - b.order)
.map((field) => ({
name: t(field.key) || t("ES_COMMON_NA"),
selector: (row) => {
const fieldValue = row.additionalFields.find((f) => f.key === field.key)?.value || t("ES_COMMON_NA");
...(props?.censusData?.[0]?.additionalFields || [])
.filter((field) => field.showOnUi)
.sort((a, b) => a.order - b.order)
.map((field) => ({
name: t(`INBOX_${field.key}`) || t("ES_COMMON_NA"),
selector: (row) => {
const fieldValue = row.additionalFields.find((f) => f.key === field.key)?.value || t("ES_COMMON_NA");

// Render a button if editable is true, otherwise render the field value as text
return row.additionalFields.find((f) => f.key === field.key)?.editable ? (
<div style={{ display: 'flex', alignItems: 'center', justifyContent: "flex-end" }}>
<span style={{ marginRight: '0.5rem' }}>{fieldValue}</span>
{props.showEditColumn && <Button
// Render a button if editable is true, otherwise render the field value as text
return row.additionalFields.find((f) => f.key === field.key)?.editable ? (
<div style={{ display: "flex", alignItems: "center", justifyContent: "flex-end" }}>
<span style={{ marginRight: "0.5rem" }}>{fieldValue}</span>
{props.showEditColumn && (
<Button
onClick={() => {
setShowEditVillagePopup(row);
}}
variation="secondary"
icon={"Edit"}
size="small"
style={{ paddingLeft: "16px", minWidth: "unset", paddingRight: "8px" }}
/>}
</div>
) : (
fieldValue
);
},
sortable: true,
width: "180px",
style: {
justifyContent: "flex-end",
},
}))
),
/>
)}
</div>
) : (
fieldValue
);
},
sortable: true,
width: "180px",
style: {
justifyContent: "flex-end",
},
})),
{
name: t("INBOX_STATUSLOGS"),
cell: (row, index, column, id) => (
Expand All @@ -130,8 +127,6 @@ const PopInboxTable = ({ ...props }) => {
props?.handlePageChange(page, totalRows);
};



const handleRowSelect = (event) => {
// if(!event?.allSelected && event?.selectedCount >0){
// setIsIntermediate(true);
Expand All @@ -152,14 +147,14 @@ const PopInboxTable = ({ ...props }) => {
if (showTimelinePopup) {
return (
<TimelinePopUpWrapper
key={`${selectedBusinessId}-${Date.now()}`}
key={`${selectedBusinessId}-${Date.now()}`}
onClose={() => {
setShowTimelinePopup(false);
setSelectedBoundaryCode(null);
setSelectedBusinessId(null); // Reset the selectedBusinessId when popup is closed
}}
businessId={selectedBusinessId} // Pass selectedBusinessId as businessId
heading={`${t("HCM_MICROPLAN_STATUS_LOG_FOR_LABEL")} ${t(selectedBoundaryCode)}`}
heading={`${t("HCM_MICROPLAN_STATUS_LOG_FOR_LABEL")} ${t(selectedBoundaryCode)}`}
labelPrefix={"POP_ACTIONS_"}
/>
);
Expand Down Expand Up @@ -196,7 +191,7 @@ const PopInboxTable = ({ ...props }) => {
// defaultSortFieldId={1}
selectableRowsComponentProps={selectProps}
progressPending={props?.progressPending}
progressComponent={<Loader />}// progressPending={loading}
progressComponent={<Loader />} // progressPending={loading}
pagination
paginationServer
paginationDefaultPage={props?.currentPage}
Expand All @@ -212,4 +207,4 @@ const PopInboxTable = ({ ...props }) => {
);
};

export default PopInboxTable;
export default PopInboxTable;
Loading