import {defineStore} from "pinia";
import {CHECK_STORE_KEY} from "@/stores/constant";
import type {CheckData} from "@/api/check/interface";


export const useCheckStore = defineStore("check", {
    id: CHECK_STORE_KEY,

    state: () => ({
        devices: Array<CheckData.Device>(),
        planId: String(""),
        planCode: String(""),
        scriptId: String(""),
        errorSysId: String(""),
    }),

    getters: {},

    actions: {
        addDevices(device: CheckData.Device[]) {
            this.devices.push(...device);
        },

        clearDevices() {
            this.devices = [];
        },

        setPlanId(planId: string) {
            this.planId = planId
        },

        setPlanCode(planCode: string) {
            this.planCode = planCode
        },

        setScriptId(scriptId: string) {
            this.scriptId = scriptId
        },

        setErrorSysId(errorSysId: string) {
            this.errorSysId = errorSysId
        }
    }
});