import { defineStore } from 'pinia'

import { updateCusCard } from "@/api";
import { getCardData } from "@/api/card";

export const useCardStore = defineStore('card', {
    state: () => {
        return {
            cusCard: {
                card_title: '',
                show_cus: 1,
                cus_card: '',
            },
            vipCard: [],
        }
    },
    getters: {
    },
    actions: {
        async getCardData() {
            let res = await getCardData();

            if (res.code === 200) {
                this.cusCard = res.data.cus_card;
                return true;
            }

            return false;
        },
        async updateCusCard(payload) {
            let res = await updateCusCard(payload);
            if (res.code === 200) {
                this.cusCard = payload;
                return true;
            }

            return false;
        }
    },
    persist: true
})