import {injectLocal, provideLocal} from "@vueuse/core";
import {getPaperClassStatistic} from "@/api/dz/papers.js";

const key = Symbol('PaperClassStatisticCondition')

export const useProvidePaperClassStatisticCondition = function () {
    const selectedClasses = ref([])
    const classList = ref([])

    const loadClassStatistic = async function (payload) {
        selectedClasses.value = []
        classList.value = []

        const res = await getPaperClassStatistic(payload)
        classList.value = res.data
    }

    const payload = {selectedClasses, classList, loadClassStatistic}
    provideLocal(key, payload)
    return payload
}

export const useInjectPaperClassStatisticCondition = function () {
    return injectLocal(key)
}