<template>

  <LayoutContainer>
    <v-col cols="12" sm="12" md="12">
      <UiLoadingPanel v-if="pending" />
      <UiForm
          v-else-if="parameters !== null"
          :model="Parameters"
          :entity="parameters"
      >
        <v-expansion-panels :multiple="true" v-model="openedPanels">

          <UiExpansionPanel title="general_parameters" icon="fas fa-info">
            <LayoutParametersPreferencesTabGeneralParameters :parameters="parameters" />
          </UiExpansionPanel>

          <UiExpansionPanel title="website" icon="fas fa-info">
          </UiExpansionPanel>

          <UiExpansionPanel title="teaching" icon="fas fa-info">
          </UiExpansionPanel>

          <UiExpansionPanel title="intranet_access" icon="fas fa-info">
          </UiExpansionPanel>

          <UiExpansionPanel title="educationNotations" icon="fas fa-info">
          </UiExpansionPanel>

          <UiExpansionPanel title="bulletin" icon="fas fa-info">
          </UiExpansionPanel>

          <UiExpansionPanel title="educationTimings" icon="fas fa-info">
          </UiExpansionPanel>

          <UiExpansionPanel title="attendances" icon="fas fa-info">
          </UiExpansionPanel>

          <UiExpansionPanel title="residenceAreas" icon="fas fa-info">
          </UiExpansionPanel>

          <UiExpansionPanel title="sms_option" icon="fas fa-info">
          </UiExpansionPanel>

          <UiExpansionPanel title="super_admin" icon="fas fa-info">
          </UiExpansionPanel>
        </v-expansion-panels>
      </UiForm>
      <span v-else>
        {{ $t('an_error_happened') }}
      </span>
    </v-col>
  </LayoutContainer>





</template>

<script setup lang="ts">

// On déplie les expansion panels dans le onMounted en attendant la résolution du bug : https://github.com/vuetifyjs/vuetify/issues/16427#issuecomment-1380927133
// TODO: quand le bug ci dessus est résolu, remplacer par `const openedPanels: Ref<Array<string>> = ref(['informations', 'bills', 'more_features'])`
import {Ref} from "@vue/reactivity";
import {useEntityFetch} from "~/composables/data/useEntityFetch";
import {useOrganizationProfileStore} from "~/stores/organizationProfile";
import Parameters from "~/models/Organization/Parameters";

const openedPanels: Ref<Array<string>> = ref([])
onMounted(() => {
  openedPanels.value = [
    'general_parameters',
    'website',
    'teaching',
    'intranet_access',
    'educationNotations',
    'bulletin',
    'educationTimings',
    'attendances',
    'residenceAreas',
    'sms_option',
    'super_admin',
  ]
})

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)




</script>

<style scoped lang="scss">

</style>
