<template>
  <q-page>
    <TableList ref="tableListRef" @show-uploader="showUploader = true" />
  </q-page>
  <UploaderDialog
    :show="showUploader"
    @close="showUploader = false"
    @upload="onUpload"
  />
</template>

<script setup lang="ts">
import UploaderDialog from 'src/components/UploaderDialog.vue';
import { Ref, ref } from 'vue';
import TableList from 'src/components/TableList.vue';
import { wpMenuHelper } from 'src/helpers/wpMenuHelper';

/**
 * LIFE-CYCLE HOOK: CREATED
 */
(() => {
  wpMenuHelper('tables');
})();

/**
 * CONSTANTS
 */
const showUploader: Ref<boolean> = ref(false);
const tableListRef: Ref<InstanceType<any>> = ref(null);

/**
 * ON UPLOAD
 */
function onUpload() {
  tableListRef.value?.onFetchTables();
}
</script>
