<template>
  <div>
    <v-container class="bg-white rounded-lg" fluid>
      <v-row>
        <v-col cols="3">
          <v-autocomplete :label="$t('message.search.resulttype')" variant="outlined" hide-details
            menu-icon="mdi-chevron-down" :items="['Radiodiagnostik', 'Ultrasonografi', 'BMD', 'MRI']"></v-autocomplete>
        </v-col>
        <v-col cols="3">
          <v-text-field :label="$t('message.search.noreg')" variant="outlined" hide-details
            append-inner-icon="mdi-magnify"></v-text-field>
        </v-col>
        <v-col cols="3">
          <div class="d-flex align-center ga-2">
            <v-menu v-model="actionDate" :close-on-content-click="false" transition="scale-transition" offset-y
              min-width="auto" max-width="290px">
              <template v-slot:activator="{ props }">
                <v-text-field :model-value="formatDate()" :label="$t('message.search.actionDate')"
                  prepend-inner-icon="mdi-calendar" hide-details readonly variant="outlined"
                  v-bind="props"></v-text-field>
              </template>
              <v-date-picker hide-header show-adjacent-months rounded="lg" color="primary" v-model="date"
                @update:modelValue="actionDate = false"></v-date-picker>
            </v-menu>
          </div>
        </v-col>
        <v-col cols="2.5">
          <v-autocomplete :label="$t('message.search.group')" variant="outlined" hide-details
            menu-icon="mdi-chevron-down"
            :items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"></v-autocomplete>
        </v-col>

        <v-col cols="1">
          <v-btn variant="flat" small style="height: 55px; width: 40px;" class="bg-primary rounded-lg">
            <iconify-icon style="font-size: 2rem;" icon="fluent:search-20-regular"></iconify-icon>
          </v-btn>
        </v-col>
      </v-row>
    </v-container>
  </div>
</template>

<style scoped></style>

<script type="module">
export default {
  name: "SearchPatient",
  data() {
    return {
      actionDate: false,
      visible: false,
    };
  },
  computed: {
    date: {
      get() {
        return this.$store.state.documentation.date;
      },
      set(val) {
        console.log(val)
        this.$store.commit("documentation/setDate", val);
      },
    },
  },
  methods: {
    formatDate() {
      if (!this.date) return null;

      return moment(this.date).format("DD-MM-YYYY");
    },
    deFormatedDate(date) {
      if (!date) return null;

      const [day, month, year] = date.split("-");
      return `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
    },
  },
  wacth: {

  }
}
</script>