TP-53751 | Merge master

This commit is contained in:
yashmantri
2024-05-13 18:26:32 +05:30
7 changed files with 69 additions and 10 deletions

View File

@@ -134,8 +134,8 @@ def reactNativeArchitectures() {
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}
def VERSION_CODE = 152
def VERSION_NAME = "2.9.11"
def VERSION_CODE = 153
def VERSION_NAME = "2.9.12"
android {
ndkVersion rootProject.ext.ndkVersion

View File

@@ -1,7 +1,7 @@
{
"name": "AV_APP",
"version": "2.9.11",
"buildNumber": "152",
"version": "2.9.12",
"buildNumber": "153",
"private": true,
"scripts": {
"android:dev": "yarn move:dev && react-native run-android",

View File

@@ -25,6 +25,11 @@ export const RANGE_FILTER_SEPARATOR = '-';
export interface Option {
label: string;
value: any;
meta?: Record<string, string[]>;
}
export interface SubLabelOption extends Option {
subLabel?: string;
}
export enum FirestoreUpdateTypes {

View File

@@ -9,6 +9,7 @@ import { IFilterOptionsProps } from './Interface';
import { useSelector } from 'react-redux';
import { RootState } from '../../../../store/store';
import styles from './styles';
import {getKeys, getOptions} from "@components/screens/allCases/allCasesFilters/FilterUtils";
const FilterOptions: React.FC<IFilterOptionsProps> = ({
selectedFilterKey,
@@ -19,19 +20,21 @@ const FilterOptions: React.FC<IFilterOptionsProps> = ({
const { filters } = useSelector((state: RootState) => ({
filters: state.filters.filters,
}));
if (Object.keys(filters).length === 0) {
return <></>;
return null;
}
if (selectedFilterKey) {
const options =
filterSearchString.length > 0
? Search(
filterSearchString,
filters[selectedFilterKey.filterGroup].filters[selectedFilterKey.filterKey].options ||
getOptions(filters[selectedFilterKey.filterGroup].filters[selectedFilterKey.filterKey].options, selectedFilterKey.filterKey) ||
[],
{ keys: ['label'] }
{ keys: getKeys(selectedFilterKey.filterKey) }
).map((option) => option.obj)
: filters[selectedFilterKey.filterGroup].filters[selectedFilterKey.filterKey].options;
: getOptions(filters[selectedFilterKey.filterGroup].filters[selectedFilterKey.filterKey].options, selectedFilterKey.filterKey);
switch (
filters[selectedFilterKey.filterGroup].filters[selectedFilterKey.filterKey].selectionType
) {

View File

@@ -7,12 +7,14 @@ import {
} from '../../../../screens/allCases/interface';
import {
CONDITIONAL_OPERATORS,
FILTER_TYPES,
FILTER_TYPES, Option,
RANGE_FILTER_SEPARATOR,
SELECTION_TYPES,
SELECTION_TYPES, SubLabelOption,
} from '../../../../common/Constants';
import { getObjectValueFromKeys } from '../../../utlis/parsers';
import { _map } from '../../../../../RN-UI-LIB/src/utlis/common';
import { pluralise } from "@utils/commonFunctions";
import { FilterKeys, OptionTypes } from "@components/screens/allCases/allCasesFilters/types";
export const evaluateFilterForCases = (
caseRecord: CaseDetail,
@@ -169,3 +171,40 @@ export function filterTransformer(filterResponseList: FilterResponse[]) {
});
return { filterGroupMap, quickFilters };
}
const populateSubLabelsAndSort = (options: Option[], subLabelKey: string) => options.map(option => {
const subLabelList = option?.meta? option.meta[subLabelKey]: [""];
const subLabel = subLabelList?.length > 0 ? subLabelList[0] : "";
return {
...option,
subLabel
};
}).sort((firstOption, secondOption) => {
if (firstOption.subLabel && secondOption.subLabel && firstOption.subLabel.localeCompare(secondOption.subLabel) === 0) {
return firstOption.label.localeCompare(secondOption.label);
} else if (firstOption.subLabel && secondOption.subLabel) {
return firstOption.subLabel.localeCompare(secondOption.subLabel);
} else if (firstOption?.subLabel) {
return -1;
} else if (secondOption?.subLabel) {
return 1;
} else {
return firstOption.label.localeCompare(secondOption.label);
}
});
export const getOptions = (options: Option[], filterKey: string) => {
if (filterKey === FilterKeys.PIN_CODE) {
return populateSubLabelsAndSort(options, OptionTypes.LOCALITY);
}
return options;
}
export const getKeys = (filterKey: string) => {
if (filterKey === FilterKeys.PIN_CODE) {
return ["label", "subLabel"];
}
return ["label"];
}

View File

@@ -0,0 +1,8 @@
export enum OptionTypes {
COLLECTION_CASE = 'COLLECTION_CASE',
LOCALITY = 'LOCALITY'
}
export enum FilterKeys {
PIN_CODE = 'PINCODE'
}

View File

@@ -520,4 +520,8 @@ export const sendDeviceDetailsToClickstream = async () => {
});
};
export const pluralise = (count: number, singularWord: string, pluralWord: string) => {
return count === 1 ? singularWord : pluralWord;
}
export const isFunction = (fn: unknown): fn is (...args: any[]) => void => typeof fn === 'function';