123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <script setup>
  2. import { Inertia } from '@inertiajs/inertia'
  3. import { watch } from 'vue'
  4. import { Head } from '@inertiajs/inertia-vue3'
  5. import { pickBy } from 'lodash'
  6. import { indexTable } from './tableHeader'
  7. import { useSearchText } from '@/components/useSearchText'
  8. import { useDateRangeFilter } from '@/components/useDateRangeFilter'
  9. import DashboardLayout from '@/layouts/DashboardLayout.vue'
  10. import AppPagination from '@/components/AppPagination.vue'
  11. import AppButtonLink from '@/components/AppButtonLink.vue'
  12. const props = defineProps({
  13. topUp: Object,
  14. initialSearch: String,
  15. initialDateRange: Array,
  16. })
  17. const { search } = useSearchText(props)
  18. const { dates, startDate, endDate } = useDateRangeFilter(props)
  19. watch([dates, search], () => {
  20. Inertia.get(
  21. '/top-ups',
  22. pickBy({
  23. startDate: startDate.value,
  24. endDate: endDate.value,
  25. search: search.value,
  26. }),
  27. {
  28. preserveState: true,
  29. }
  30. )
  31. })
  32. const filterReset = () => {
  33. Inertia.get('/top-ups')
  34. }
  35. </script>
  36. <template>
  37. <Head title="Top Up" />
  38. <DashboardLayout>
  39. <DataTable
  40. responsive-layout="scroll"
  41. column-resize-mode="expand"
  42. :value="topUp.data"
  43. :row-hover="true"
  44. :striped-rows="true"
  45. >
  46. <template #header>
  47. <h1>Top Up</h1>
  48. <div class="grid">
  49. <div class="col-12 md:col-8">
  50. <div class="grid">
  51. <div class="col-12 md:col-3">
  52. <InputText class="w-full" placeholder="cari, contoh: 08xx, tina" v-model="search" />
  53. </div>
  54. <div class="col-12 md:col-3">
  55. <Calendar
  56. touch-u-i
  57. class="w-full"
  58. v-model="dates"
  59. selection-mode="range"
  60. placeholder="filter waktu..."
  61. date-format="dd/mm/yy"
  62. :manual-input="false"
  63. />
  64. </div>
  65. <div class="col-auto mt-2 ml-2">
  66. <Button label="reset" class="p-button-link" @click="filterReset" />
  67. </div>
  68. </div>
  69. </div>
  70. <div class="col-12 md:col-4 flex flex-column md:flex-row justify-content-end">
  71. <AppButtonLink
  72. label="Top Up"
  73. class="p-button-outlined"
  74. icon="pi pi-pencil"
  75. :href="route('top-ups.create')"
  76. />
  77. </div>
  78. </div>
  79. </template>
  80. <Column v-for="value in indexTable" :field="value.field" :header="value.header" :key="value.field" />
  81. <Column>
  82. <template #body="{ data }">
  83. <AppButtonLink
  84. icon="pi pi-eye"
  85. class="p-button-text p-button-icon-only p-button-rounded p-button-text"
  86. :href="route('top-ups.show', data.id)"
  87. />
  88. </template>
  89. </Column>
  90. </DataTable>
  91. <AppPagination :links="topUp.links" />
  92. </DashboardLayout>
  93. </template>