Skip to content

Commit

Permalink
Merge pull request #37 from chaitanyakole/filter_fixes
Browse files Browse the repository at this point in the history
Bug #234323[Admin] Tenant filter default option is set to "Public Users" instead of "All" in Cohorts List and Learners List. PFA; Bug #234329[Admin- learner list] Showing irrelevant search results when searching learner. PFAi
  • Loading branch information
gouravmore authored Feb 5, 2025
2 parents 4b6a6bb + 0e3abf4 commit 3182722
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 989 deletions.
116 changes: 0 additions & 116 deletions src/components/AreaSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,7 @@ interface Cohort {
label: string;
}
interface DropdownBoxProps {
// states: State[];
// districts: District[];
// blocks: Block[];
// allCenters?: Centers[];
// selectedState: string[];
// selectedDistrict: string[];
// selectedBlock: string[];
// selectedCenter?: any;
inModal?: boolean;
// handleStateChangeWrapper: (
// selectedNames: string[],
// selectedCodes: string[]
// ) => Promise<void>;
// handleDistrictChangeWrapper: (
// selected: string[],
// selectedCodes: string[]
// ) => Promise<void>;
// handleBlockChangeWrapper: (
// selected: string[],
// selectedCodes: string[]
// ) => void;
// handleCenterChangeWrapper?: (
// selected: string[],
// selectedCodes: string[]
// ) => void;

isMobile: boolean;
isMediumScreen: boolean;
isCenterSelection?: boolean;
Expand All @@ -82,25 +57,10 @@ interface DropdownBoxProps {
}

const AreaSelection: React.FC<DropdownBoxProps> = ({
// states,
// districts,
// blocks,
// allCenters = [],
// selectedState,
// selectedDistrict,
// selectedBlock,
// selectedCenter = [],
// handleStateChangeWrapper,
// handleDistrictChangeWrapper,
// handleBlockChangeWrapper,
isMobile,
isMediumScreen,
isCenterSelection = false,
inModal = false,
// handleCenterChangeWrapper = () => {},
// stateDefaultValue,
// blockDefaultValue,
// districtDefaultValue,
tenants,
cohorts,
selectedTenant,
Expand All @@ -116,9 +76,6 @@ const AreaSelection: React.FC<DropdownBoxProps> = ({
}) => {
const { t } = useTranslation();
const theme = useTheme<any>();
const [singleState, setSingleState] = useState<boolean>(true);
const [stateValue, setStateValue] = useState<string>("");
const [stateCode, setStateCode] = useState<string>("");
let isSmallScreen = useMediaQuery((theme: any) =>
theme.breakpoints.down("sm")
);
Expand Down Expand Up @@ -239,76 +196,3 @@ const AreaSelection: React.FC<DropdownBoxProps> = ({
};

export default AreaSelection;

{
/* <Grid
item
xs={12}
sm={inModal ? 12 : 6}
md={inModal ? 12 : 4}
lg={inModal ? 12 : isCenterSelection ? 3 : 4}
>
{shouldRenderSelectCheckmarks && (
<MultipleSelectCheckmarks
names={capitalizeFirstLetterOfEachWordInArray(
blocks?.length > 0 ? blocks.map((block) => block.label) : []
// blocks.map((block) => block.label)
)}
codes={
blocks?.length > 0
? blocks?.map((block) => block.value)
: []
// blocks?.map((block) => block.value)
}
tagName={t("FACILITATORS.BLOCK")}
selectedCategories={capitalizeFirstLetterOfEachWordInArray(
selectedBlock
)}
onCategoryChange={handleBlockChangeWrapper}
disabled={
blocks?.length <= 0 ||
selectedDistrict?.length === 0 ||
selectedDistrict[0] === t("COMMON.ALL_DISTRICTS")
}
overall={!inModal}
defaultValue={
selectedDistrict?.length > 0 && blocks?.length === 0
? t("COMMON.NO_BLOCKS")
: t("COMMON.ALL_BLOCKS")
}
/>
)}
</Grid> */
}
{
/* {isCenterSelection && (
<Grid
item
xs={12}
sm={inModal ? 12 : 6}
md={inModal ? 12 : 4}
lg={inModal ? 12 : isCenterSelection ? 3 : 4}
>
<MultipleSelectCheckmarks
names={capitalizeFirstLetterOfEachWordInArray(
allCenters?.map((center) => center.name)
)}
codes={allCenters?.map((center) => center.cohortId)}
tagName={t("CENTERS.CENTERS")}
selectedCategories={selectedCenter}
onCategoryChange={handleCenterChangeWrapper}
disabled={
selectedBlock.length === 0 ||
selectedBlock[0] === t("COMMON.ALL_BLOCKS") ||
(selectedBlock?.length > 0 && allCenters?.length === 0)
}
overall={!inModal}
defaultValue={
selectedBlock?.length > 0 && allCenters?.length === 0
? t("COMMON.NO_CENTERS")
: t("COMMON.ALL_CENTERS")
}
/>
</Grid>
)} */
}
9 changes: 2 additions & 7 deletions src/components/FormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,9 @@ const MultipleSelectCheckmarks: React.FC<MultipleSelectCheckmarksProps> = ({
labelId="multiple-checkbox-label"
id="multiple-checkbox"
value={
// If no categories are selected (empty or invalid selection), show default value or the first name from 'names'
selectedCategories?.length <= 0 || selectedCategories[0] === ""
? names?.length >= 1
? [names[0]]
: defaultValue
? [defaultValue]
: []
: selectedCategories // If categories are selected, use selectedCategories
? ["All"]
: selectedCategories
}
onChange={handleChange} // Handle the change event for the selection
input={<OutlinedInput label={tagName} />}
Expand Down
Loading

0 comments on commit 3182722

Please sign in to comment.