Untitled

mail@pastecode.io avatar
unknown
plain_text
9 days ago
4.8 kB
1
Indexable
Never
[
    {
        "state": "DE",
        "offering": [
            "EE",
            "CW"
        ]
    },
    {
        "state": "TX",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "FL",
        "offering": [
            "EE",
            "CW"
        ]
    },
    {
        "state": "NV",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "NY",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "WI",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "MA",
        "offering": [
            "CW",
            "EE"
        ]
    },
    {
        "state": "ME",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "OH",
        "offering": [
            "EE",
            "CW"
        ]
    },
    {
        "state": "GA",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "MI",
        "offering": [
            "EE",
            "CW"
        ]
    },
    {
        "state": "CA",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "WY",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "OR",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "IL",
        "offering": [
            "EE",
            "CW"
        ]
    },
    {
        "state": "IN",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "MT",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "VA",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "CO",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "KY",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "PA",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "CT",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "AR",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "LA",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "ND",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "RI",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "TN",
        "offering": [
            "EE",
            "CW"
        ]
    },
    {
        "state": "NH",
        "offering": [
            "EE"
        ]
    },
    {
        "state": "NM",
        "offering": [
            "EE"
        ]
    }
]




currently im getting the above values for privilegeData. create a list of unique offering values from the above data and use setFilteredOfferings() to update the offering list with the filtered values.


const filterAuthOfferings = (value) => {
        const selectedState = value;
        let refTable = rfiUtil.getRefTableDataByCacheName(
            ConstantKeys.REF_TABLE.CREATE_RFI_REF_TABLES,
        );
        let filteredOfferingData = [];
        const privilegeData = AppContext.security.getProfile().profile;
        console.log('privilegeData:', privilegeData);

        //write the code to get all the uniques offering values from the privilegeData then use setFilteredOfferings to update the offering list
        const matchedPrivileagedata = privilegeData.find(
            (detail) => detail.state === selectedState,
        );

        
        filteredOfferingData = refTable.OFFERING.filter((offering) =>
            matchedPrivileagedata.offering.includes(offering.CODE),
        );
        if (filteredOfferingData) {
            setFilteredOfferings(filteredOfferingData);
        }

        //on change of requested as reset the vaue of offering and program to default value
        setFilteredPrograms([]);
        setFilteredCategory([]);
        updateRFIRequest({
            ...rfiRequest,
            offering: '',
            category: [...ConstantKeys.DEFAULT_OPTION.CATEGORY],
            programs: [...ConstantKeys.DEFAULT_OPTION.PROGRAM],
        });
    };

    const filterProgramAndCategory = (value) => {
        const selectedOffering = value;

        const filteredProg = rfiUtil.getTableDataForOffering(
            ConstantKeys.REF_TABLE_NAMES.PROGRAM,
            selectedOffering,
        );
        setFilteredPrograms(filteredProg);

        const filteredCategories = rfiUtil.getTableDataForOffering(
            ConstantKeys.REF_TABLE_NAMES.CATEGORY,
            selectedOffering,
        );
        setFilteredCategory(filteredCategories);
    };
Leave a Comment