<template>
  <fs-page class="fs-page-custom">
    <fs-crud ref="crudRef" v-bind="crudBinding">
      <template #search-left>
        <DateRangePicker v-model="dateRange"></DateRangePicker>
      </template>
      <template #header-middle>
        <LineChart :query="queryParams"/>
      </template>
    </fs-crud>
  </fs-page>
</template>

<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { useFs, FsPage } from '@fast-crud/fast-crud'
import { LocationQueryValue } from 'vue-router'
import { usePublicData } from '/@/stores/publicData'
import { storeToRefs } from 'pinia'
import { createCrudOptions } from './crud'
import LineChart from './lineChart.vue'
import DateRangePicker from '/@/components/DateRangePicker/index.vue'

const publicData = usePublicData()
const { dateRange } = storeToRefs(publicData)
interface Props {
  campaignId: LocationQueryValue | LocationQueryValue[]
}
const props = defineProps<Props>()
const queryParams = ref({
  campaignId: props.campaignId,
  dateRange
})
const { crudBinding, crudRef, crudExpose } = useFs({ createCrudOptions, context: queryParams })

// onMounted(async () => {
// 	crudExpose.doRefresh()
// })

</script>

<style scoped>

</style>