<script lang="ts" setup>
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter';

import { Page } from '@vben/common-ui';

import { useTableGridOptions, useVbenVxeGrid } from '#/adapter';
import { LogApi } from '#/api';

import { useColumns, useSearchSchema } from '../data.config';

const handleActionClick = async ({
  code,
}: OnActionClickParams<LogApi.RecordItem>) => {
  switch (code) {
    case 'view': {
      // await handleDelete(row.id);
      break;
    }
  }
};

const [Grid] = useVbenVxeGrid(
  useTableGridOptions({
    formOptions: {
      fieldMappingTime: [['__date', ['startTime', 'endTime']]],
      schema: useSearchSchema(),
    },
    gridOptions: {
      columns: useColumns(handleActionClick),
      proxyConfig: {
        ajax: {
          query: async ({ page }, formValues) => {
            return await LogApi.getAuditPage({
              pageIndex: page.currentPage,
              pageSize: page.pageSize,
              ...formValues,
            });
          },
        },
      },
    } as VxeTableGridOptions,
  }),
);
</script>

<template>
  <Page auto-content-height>
    <Grid>
      <template #toolbar-tools></template>
    </Grid>
  </Page>
</template>
