import {useGetLensTypesQuery} from "../../../../../../../Api/lensTypesApi.js";
import {useGetSetContentQuery} from "../../../../../../../Api/setContentApi.js";


const useSetForm = (setData) => {
    const {data: lensTypes = [], isLoading: isLoadingLensTypes, isError: isErrorLensTypes} =
        useGetLensTypesQuery(undefined);

    const setId = setData?.id;

    const {
        data: setContents = [],
        isLoading: isLoadingSetContents,
        isError: isErrorSetContents
    } = useGetSetContentQuery(setId, {
        skip: !setId,
    });

    return {
        lensTypes,
        setContents,
        isLoading: isLoadingLensTypes || (setId && isLoadingSetContents),
        isError: isErrorLensTypes || (setId && isErrorSetContents),
    };
};

export default useSetForm;