Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
714 B
2
Indexable
Never
const fetchStateList = (collectionData) => {
    const distinctStatesValues = [...new Set(collectionData.rfiDetails.map((item) => item.state))];

    if (refTableContent) {
        const distinctStatesList = refTableContent.STATE?.filter((state) =>
            distinctStatesValues?.includes(state.CODE),
        );

        if (distinctStatesValues?.includes(ConstantKeys.REF_VALUE.ALL)) {
            distinctStatesList.push({
                CODE: ConstantKeys.REF_VALUE.ALL,
                DESCRIPTION: ConstantKeys.CONTEXT_KEYS.ALL_LOWERCASE,
            });
        }

        setFilteredStates(
            distinctStatesList.sort((a, b) => a.DESCRIPTION.localeCompare(b.DESCRIPTION)),
        );
    }
};
Leave a Comment