import { computed } from "vue";
import { useStore } from "vuex";
import { useLanding } from "./useLanding";

export function useLandingProps() {
    const store = useStore()
    const { landing } = useLanding()
    const gamas = computed(() => store.getters['gamas/gamasFlat'] || []);
    const props = computed(() => {
        if (!landing.value) return []
        const ids = landing.value.ID_GAMA?.split(',').map(Number) || []
        return gamas.value.filter(g => ids.includes(g.ID_GAMA)).flatMap(gama => gama.PROPS.map((control) => ({
            ...control,
            code: control.code.toUpperCase(),
            idGama: gama.ID_GAMA,
        }))
        )
    })
    return props
}