<script setup>
const props = defineProps({
  productId: Number,
});
const { $store } = useNuxtApp();
$store.commit('selectedProductsForHandoverEmail', []);
</script>
<template>
  <input
    type="checkbox" 
    :checked="$store.selectedProductsForHandoverEmail.includes(props.productId)"
    @change="(e) => {
      if (e.target.checked) {
        $store.commit(
          'selectedProductsForHandoverEmail',
          [ ...$store.selectedProductsForHandoverEmail, props.productId],
        ) 
      } else {
        $store.commit(
          'selectedProductsForHandoverEmail',
          $store.selectedProductsForHandoverEmail.filter(x => x !== props.productId),
        )
      }
    }" 
  />
</template>