"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useGetDataSelectTarget = void 0;
const tslib_1 = require("tslib");
const react_1 = require("react");
const query_1 = require("../graphql/query");
const getLoginInfo_1 = tslib_1.__importDefault(require("../../Func/getLoginInfo"));
const PHXGrpcClientV3_1 = require("../../Func/GRPC/PHXGrpcClientV3");
const useGetDataSelectTarget = ({ schoolYearId }) => {
    const [selectOptions, setSelectOptions] = (0, react_1.useState)({
        EDUCATIONAL_LEVEL: [],
        GRADE: [],
        CLASSROOM: [],
        DEPARTMENT: [],
        ALL: [],
    });
    const [loading, setLoading] = (0, react_1.useState)(true);
    const userInfo = (0, getLoginInfo_1.default)();
    const getDataSelect = async () => {
        setLoading(true);
        try {
            const { data: { classroom, department, educational_level, grade }, } = await (0, PHXGrpcClientV3_1.PHXClientQueryV3)({
                query: query_1.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);
        }
    };
    (0, react_1.useEffect)(() => {
        if (schoolYearId) {
            getDataSelect();
        }
    }, [schoolYearId]);
    return { selectOptions, loading };
};
exports.useGetDataSelectTarget = useGetDataSelectTarget;
//# sourceMappingURL=use-get-data-select.js.map