-
Notifications
You must be signed in to change notification settings - Fork 47
Console v0.5 #2965
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
base: master
Are you sure you want to change the base?
Console v0.5 #2965
Changes from 19 commits
0cb1fa4
3cd151a
45c5ffe
230df89
6e9194d
ad486aa
a0cc3f4
ff44c55
2bcee17
3f516d6
747151d
c671b13
d3672b5
5272fef
4ffc60e
4bdcd7b
218abb2
468c4e9
f42593c
218a4ae
046c25a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import React, { useState, Fragment, useEffect } from "react"; | ||
| import { TextInput, Dropdown, RadioButtons, Button, FieldV1, Switch, Loader } from "@egovernments/digit-ui-components"; | ||
| import { useTranslation } from "react-i18next"; | ||
| const FiltersRenderer = ({ cField, drawerState, setDrawerState, t, disabled }) => { | ||
| const [localSelectedSchema, setLocalSelectedSchema] = useState(null); | ||
| const [localActiveOptions, setLocalActiveOptions] = useState([]); // store codes | ||
|
|
||
| // Fetch MDMS data based on selected schema | ||
| const { isLoading, data: mdmsOptions = [] } = Digit.Hooks.useCustomMDMS( | ||
| Digit.ULBService.getCurrentTenantId(), | ||
| localSelectedSchema?.moduleName, | ||
| localSelectedSchema?.masterName ? [{ name: localSelectedSchema.masterName }] : [], | ||
| { | ||
| enabled: !!localSelectedSchema?.moduleName && !!localSelectedSchema?.masterName, | ||
| select: (data) => data?.[localSelectedSchema?.moduleName]?.[localSelectedSchema.masterName] || [], | ||
| }, | ||
| { schemaCode: "FILTERSDROPDOWNLIST" } | ||
| ); | ||
|
|
||
| // When MDMS options load, set default active | ||
| useEffect(() => { | ||
| if (mdmsOptions.length > 0) { | ||
| const defaultActive = mdmsOptions.filter((opt) => opt.active).map((opt) => opt.code); | ||
| setLocalActiveOptions(defaultActive); | ||
| // Also initialize enums in drawerState with these active objects | ||
| const activeObjects = mdmsOptions.filter((item) => defaultActive.includes(item.code)); | ||
| setDrawerState((prev) => ({ | ||
| ...prev, | ||
| enums: activeObjects, | ||
| })); | ||
| } | ||
| }, [mdmsOptions]); | ||
|
|
||
| // Handle toggle | ||
| const handleToggle = (code, checked) => { | ||
| setLocalActiveOptions((prev) => { | ||
| let updated = [...prev]; | ||
| if (checked) { | ||
| if (!updated.includes(code)) updated.push(code); | ||
| } else { | ||
| updated = updated.filter((c) => c !== code); | ||
| } | ||
|
|
||
| // Map updated codes to full objects | ||
| const activeObjects = mdmsOptions.filter((item) => updated.includes(item.code)); | ||
|
|
||
| // Update drawerState.enums directly | ||
| setDrawerState((prev) => ({ | ||
| ...prev, | ||
| enums: activeObjects, | ||
| })); | ||
|
|
||
| return updated; | ||
| }); | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| {/* Dropdown for selecting schema */} | ||
| <Dropdown | ||
| variant={""} | ||
| t={t} | ||
| disabled={disabled} | ||
| option={cField?.mdmsOptions || []} | ||
| optionKey={"schemaCode"} | ||
| selected={localSelectedSchema || {}} | ||
| select={(value) => { | ||
| setLocalSelectedSchema(value); | ||
| setLocalActiveOptions([]); // reset active when schema changes | ||
| setDrawerState((prev) => ({ ...prev, enums: [] })); // reset enums | ||
| }} | ||
| /> | ||
|
|
||
| {isLoading && <Loader/>} | ||
|
|
||
| {!isLoading && mdmsOptions.length > 0 && ( | ||
| <div style={{ marginTop: "1rem", display: "flex", flexDirection: "column", gap: "0.5rem" }}> | ||
| {mdmsOptions.map((opt) => { | ||
| const isActive = localActiveOptions.includes(opt.code); | ||
| return ( | ||
| <Switch | ||
| key={opt.code} | ||
| label={t(opt.name)} | ||
| isCheckedInitially={isActive} | ||
| onToggle={(checked) => handleToggle(opt.code, checked)} | ||
| disable={false} | ||
| shapeOnOff | ||
| /> | ||
| ); | ||
| })} | ||
| </div> | ||
| )} | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default FiltersRenderer; | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ import React, { useState, useMemo, Fragment, useEffect } from "react"; | |||||||
| import { useTranslation } from "react-i18next"; | ||||||||
| import { useLocation, useHistory } from "react-router-dom"; | ||||||||
| import { Wrapper } from "./SelectingBoundaryComponent"; | ||||||||
| import { AlertCard, Stepper, TextBlock, Tag, Card, HeaderComponent, Loader,Chip } from "@egovernments/digit-ui-components"; | ||||||||
| import { AlertCard, Stepper, TextBlock, Tag, Card, HeaderComponent, Loader, PopUp, Button, Chip } from "@egovernments/digit-ui-components"; | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CardText used but not imported — will crash at runtime You render inside PopUp, but it isn’t imported. Either import CardText or replace it with the already-imported TextBlock. Apply this minimal fix: -import { AlertCard, Stepper, TextBlock, Tag, Card, HeaderComponent, Loader, PopUp, Button, Chip } from "@egovernments/digit-ui-components";
+import { AlertCard, Stepper, TextBlock, Tag, Card, HeaderComponent, Loader, PopUp, Button, Chip, CardText } from "@egovernments/digit-ui-components";📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| import { CONSOLE_MDMS_MODULENAME } from "../Module"; | ||||||||
| import TagComponent from "./TagComponent"; | ||||||||
|
|
||||||||
|
|
@@ -78,7 +78,7 @@ const SelectingBoundariesDuplicate = ({ onSelect, formData, ...props }) => { | |||||||
| }, | ||||||||
| }; | ||||||||
|
|
||||||||
| const { data: campaignData, isFetching } = Digit.Hooks.useCustomAPIHook(reqCriteria); | ||||||||
| const { data: campaignData, isFetching } = Digit.Hooks.useCustomAPIHook(reqCriteria); | ||||||||
|
|
||||||||
|
Comment on lines
+81
to
82
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Hook result aliasing: remove unused isFetching or use for loader You destructure isFetching but never use it. Either wire it into your loading state or drop it to keep the file clean. 🤖 Prompt for AI Agents |
||||||||
| useEffect(() => { | ||||||||
| onSelect("boundaryType", { selectedData: selectedData, boundaryData: boundaryOptions, updateBoundary: !restrictSelection }); | ||||||||
|
|
@@ -107,9 +107,9 @@ const SelectingBoundariesDuplicate = ({ onSelect, formData, ...props }) => { | |||||||
| setBoundaryOptions(sessionData?.boundaryData || {}); | ||||||||
| } | ||||||||
| setTimeout(() => setIsLoading(false), 10); | ||||||||
| }, [props?.props?.sessionData?.HCM_CAMPAIGN_SELECTING_BOUNDARY_DATA?.boundaryType , campaignData]); | ||||||||
| }, [props?.props?.sessionData?.HCM_CAMPAIGN_SELECTING_BOUNDARY_DATA?.boundaryType, campaignData]); | ||||||||
|
|
||||||||
| useEffect(() => { | ||||||||
| useEffect(() => { | ||||||||
| if ( | ||||||||
| props?.props?.sessionData?.HCM_CAMPAIGN_UPLOAD_BOUNDARY_DATA?.uploadBoundary?.uploadedFile?.length > 0 || | ||||||||
| props?.props?.sessionData?.HCM_CAMPAIGN_UPLOAD_FACILITY_DATA?.uploadFacility?.uploadedFile?.length > 0 || | ||||||||
|
|
@@ -191,7 +191,7 @@ const SelectingBoundariesDuplicate = ({ onSelect, formData, ...props }) => { | |||||||
| <TagComponent campaignName={campaignName} /> | ||||||||
| { | ||||||||
| isDraftCampaign ? ( | ||||||||
| <div className="digit-tag-container" style={{margin:"0rem"}}> | ||||||||
| <div className="digit-tag-container" style={{ margin: "0rem" }}> | ||||||||
| <Chip text={`${t(`CANCEL_CAMPAIGN`)}`} onClick={handleCancelClick} hideClose={false} /> | ||||||||
| </div> | ||||||||
| ) : null | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropdown uses prop “disable”, not “disabled” — current control won’t disable
The shared Dropdown component checks props.disable, so passing disabled has no effect. Update to disable to ensure the dropdown can be disabled.
📝 Committable suggestion
🤖 Prompt for AI Agents