// voteCommon.js
import { ref } from "vue";

export function voteCommon(isVOte= false) {
    const itemList = ref(isVOte ? [] : [{ content: "", url: "" }, { content: "", url: "" }]);

    const addItem = () => {
        if (itemList.value.length < 10) {
            itemList.value.push({ content: "", url: "" });
        }
    };

    const removeItem = (index) => {
        if (!isVOte && index >= 2) {
            itemList.value.splice(index, 1);
        } else if (isVOte && itemList.value.length > 0) {
            itemList.value.splice(index, 1);
        }
    };

    return {
        itemList,
        addItem,
        removeItem,
    };
}
