<script setup lang="ts">
import { crudQueryParamsMode } from '~/lib/system-constants';
import List from './list.vue'
import Add from './add.vue'
import Edit from './edit.vue'

const props = defineProps<{
  encounter_id: number
}>()

const { crudQueryParams, goToEntry } = useQueryCRUD()
</script>

<template>
  <List v-if="crudQueryParams.mode === crudQueryParamsMode.list" :encounter_id="encounter_id" :redirectToForm="goToEntry" />
  <Add v-else-if="crudQueryParams.mode === crudQueryParamsMode.entry && !crudQueryParams.recordId" :encounter_id="encounter_id" />
  <Edit v-else-if="crudQueryParams.mode === crudQueryParamsMode.entry && crudQueryParams.recordId"
    :encounter_id="encounter_id" 
    :record_id="crudQueryParams.recordId" />
    
  <List v-else :encounter_id="encounter_id" :redirectToForm="goToEntry" />
</template>
