import { useEffect, useState } from 'react';
import { GET_SELECT_QUERY } from '../graphql/query';
import PHXFuncGetLoggedInfo from '../../Func/getLoginInfo';
import { PHXClientQueryV3 } from '../../Func/GRPC/PHXGrpcClientV3';
export const useGetDataSelectTarget = ({ schoolYearId }) => {
    const [selectOptions, setSelectOptions] = useState({
        EDUCATIONAL_LEVEL: [],
        GRADE: [],
        CLASSROOM: [],
        DEPARTMENT: [],
        ALL: [],
    });
    const [loading, setLoading] = useState(true);
    const userInfo = PHXFuncGetLoggedInfo();
    const getDataSelect = async () => {
        setLoading(true);
        try {
            const { data: { classroom, department, educational_level, grade }, } = await PHXClientQueryV3({
                query: GET_SELECT_QUERY,
                variables: {
                    schoolId: userInfo === null || userInfo === void 0 ? void 0 : userInfo.school_id,
                    schoolYearId,
                },
            });
            setSelectOptions({
                EDUCATIONAL_LEVEL: educational_level,
                GRADE: grade,
                CLASSROOM: classroom,
                DEPARTMENT: department,
                ALL: [],
            });
        }
        catch (e) {
            console.error(e);
        }
        finally {
            setLoading(false);
        }
    };
    useEffect(() => {
        if (schoolYearId) {
            getDataSelect();
        }
    }, [schoolYearId]);
    return { selectOptions, loading };
};
//# sourceMappingURL=use-get-data-select.js.map