<script setup>
const props = defineProps({
  page: String, // Due/Overdue
  paymentScheduleId: Number,
});
const { $store } = useNuxtApp();
$store.commit('selectedPaymentSchedulesForEmailInDue', []);
$store.commit('selectedPaymentSchedulesForEmailInOverdue', []);
const storeProp = `selectedPaymentSchedulesForEmailIn${props.page}`;
</script>
<template>
  <input
    type="checkbox" 
    :checked="$store[storeProp].includes(props.paymentScheduleId)"
    @change="(e) => {
      if (e.target.checked) {
        $store.commit(
          storeProp,
          [ ...$store[storeProp], props.paymentScheduleId],
        ) 
      } else {
        $store.commit(
          storeProp,
          $store[storeProp].filter(x => x !== props.paymentScheduleId),
        )
      }
    }" 
  />
</template>