import { inject, watch } from "vue";

export default function useDashboardOption(
  SetFn,
  injectData = "dashboard_items"
) {
  const { initialData } = inject(injectData);

  watch(initialData, (newValue) => {
    const data = newValue.points[1].values.filter(({ value }) => value !== 0);
    SetFn(
      data.map(({ value, text }, index) => ({
        title: text,
        key: `option_${value}`,
        active: index === 0,
        typeOption: value,
      }))
    );
  });
}
