<template>
    <UiForm
        ref="form"
        :model="Cycle"
        :entity="cycle"
        :submitActions="submitActions"
    >
      <UiInputText field="label" v-model="cycle.label" :rules="rules()" />
    </UiForm>
</template>

<script setup lang="ts">
import Cycle from "~/models/Education/Cycle";
import {AnyJson} from "~/types/data";
import {SUBMIT_TYPE} from "~/types/enum/enums";

const props = defineProps({
  cycle: {
    type: Object as () => Cycle,
    required: true
  }
})

const i18n = useI18n()

const goBackRoute = { path: `/parameters`, query: { tab: 'teaching' } }

const submitActions = computed(() => {
  let actions: AnyJson = {}
  actions[SUBMIT_TYPE.SAVE_AND_BACK] = goBackRoute
  return actions
})

const rules = () => [
  (label: string | null) => (label !== null && label.length > 0) || i18n.t('please_enter_a_value'),
]
</script>

<style scoped lang="scss">

</style>