import { ref } from 'vue';
import { defineStore } from 'pinia';

export const useArrayDataStore = defineStore('arrayDataStore', () => {
    const state = ref({});

    function get(key) {
        return state.value[key];
    }

    function set(key) {
        state.value[key] = {
            filter: {},
            userFilter: {},
            userParams: {},
            url: '',
            limit: 10,
            skip: 0,
            order: '',
            data: ref(),
            isLoading: false,
            userParamsChanged: false,
            exprBuilder: null,
        };
    }

    function clear(key) {
        delete state.value[key];
    }

    return {
        get,
        set,
        clear,
    };
});
