<template>
  <v-container :fluid="true" class="container">
    <v-row>
      <v-col cols="12" sm="6">
        <UiInputText
          v-model="proxyEntity.label"
          field="label"
          type="string"
          :rules="getAsserts('label')"
        />
      </v-col>
    </v-row>
  </v-container>
</template>

<script setup lang="ts">
import ResidenceArea from '~/models/Billing/ResidenceArea'
import { getAssertUtils } from '~/services/asserts/getAssertUtils'

const props = defineProps<{
  entity: ResidenceArea
}>()

const emit = defineEmits(['update:entity'])

// Pour éviter l'erreur eslint "Unexpected mutation of "modelValue" prop"
const proxyEntity = computed({
  get: () => props.entity,
  set: (value) => emit('update:entity', value),
})

const getAsserts = (key: string) =>
  getAssertUtils(
    ResidenceArea.getAsserts() as Record<string, Record<string, unknown>>,
    key,
  )
</script>
