<template>
  <LayoutContainer>
    <UiLoadingPanel v-if="pending" />
    <UiForm
      v-else
      :model="Parameters"
      :entity="parameters"
      action-position="bottom"
    >
      <v-row>
        <v-col cols="12">
          <UiInputCheckbox
            v-model="parameters.bulletinWithTeacher"
            field="bulletinWithTeacher"
          />

          <UiInputCheckbox
            v-model="parameters.bulletinSignatureDirector"
            field="bulletinSignatureDirector"
          />

          <UiInputCheckbox
            v-model="parameters.bulletinShowEducationWithoutEvaluation"
            field="bulletinShowEducationWithoutEvaluation"
          />

          <UiInputCheckbox
            v-model="parameters.bulletinShowAbsences"
            field="bulletinShowAbsences"
          />

          <UiInputCheckbox
            v-model="parameters.bulletinEditWithoutEvaluation"
            field="bulletinEditWithoutEvaluation"
          />

          <UiInputCheckbox
            v-model="parameters.bulletinPrintAddress"
            field="bulletinPrintAddress"
          />

          <UiInputCheckbox
            v-model="parameters.bulletinDisplayLevelAcquired"
            field="bulletinDisplayLevelAcquired"
          />

          <UiInputCheckbox
            v-model="parameters.bulletinViewTestResults"
            field="bulletinViewTestResults"
          />

          <UiInputCheckbox
            v-model="parameters.bulletinShowAverages"
            field="bulletinShowAverages"
          />

          <UiInputAutocompleteWithEnum
            v-model="parameters.bulletinReceiver"
            field="bulletinReceiver"
            enum-name="organization_bulletin_send_to"
          />

          <UiInputAutocompleteWithEnum
            v-model="parameters.bulletinCriteriaSort"
            field="bulletinCriteriaSort"
            enum-name="organization_bulletin_criteria_sort"
          />
        </v-col>
      </v-row>
    </UiForm>
  </LayoutContainer>
</template>

<script setup lang="ts">
import type { AsyncData } from '#app'
import Parameters from '~/models/Organization/Parameters'
import { useEntityFetch } from '~/composables/data/useEntityFetch'
import { useOrganizationProfileStore } from '~/stores/organizationProfile'

definePageMeta({
  name: 'parameters_bulletin_page',
})

const { fetch } = useEntityFetch()

const organizationProfile = useOrganizationProfileStore()

if (organizationProfile.parametersId === null) {
  throw new Error('Missing organization parameters id')
}

const { data: parameters, pending } = fetch(
  Parameters,
  organizationProfile.parametersId,
) as AsyncData<Parameters, Parameters | true>
</script>

<style scoped lang="scss"></style>
