✨ feat (medicine): implement medicine entry form and list
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
<script setup lang="ts"></script>
|
||||
<script setup lang="ts">
|
||||
const data = ref({
|
||||
name: '',
|
||||
password: '',
|
||||
status: '',
|
||||
type: '',
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg xl:text-xl">
|
||||
<Icon name="i-lucide-user" class="me-2" />
|
||||
<span class="font-semibold">Tambah</span> Pasien
|
||||
<span class="font-semibold">Tambah</span> Obat
|
||||
</div>
|
||||
<AppPatientEntryForm />
|
||||
<AppMedicineEntryForm v-model="data" />
|
||||
</template>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { DataTableLoader } from '~/components/pub/base/data-table/type'
|
||||
import type { Summary } from '~/components/pub/base/summary-card/type'
|
||||
import type { HeaderPrep, RefSearchNav } from '~/components/pub/custom-ui/data/types'
|
||||
import { Calendar, Hospital, UserCheck, UsersRound } from 'lucide-vue-next'
|
||||
import SummaryCard from '~/components/pub/base/summary-card/summary-card.vue'
|
||||
import Header from '~/components/pub/custom-ui/nav-header/prep.vue'
|
||||
|
||||
const data = ref([])
|
||||
@@ -31,63 +28,17 @@ const recAction = ref<string>('')
|
||||
const recItem = ref<any>(null)
|
||||
|
||||
const hreaderPrep: HeaderPrep = {
|
||||
title: 'Pasien',
|
||||
icon: 'i-lucide-users',
|
||||
title: 'Obat',
|
||||
icon: 'i-lucide-medicine-bottle',
|
||||
addNav: {
|
||||
label: 'Tambah',
|
||||
onClick: () => navigateTo('/patient/add'),
|
||||
onClick: () => navigateTo('/tools-equipment-src/medicine/add'),
|
||||
},
|
||||
}
|
||||
|
||||
// Initial/default data structure
|
||||
const summaryData: Summary[] = [
|
||||
{
|
||||
title: 'Total Pasien',
|
||||
icon: UsersRound,
|
||||
metric: 23,
|
||||
trend: 15,
|
||||
timeframe: 'daily',
|
||||
},
|
||||
{
|
||||
title: 'Pasien Aktif',
|
||||
icon: UserCheck,
|
||||
metric: 100,
|
||||
trend: 9,
|
||||
timeframe: 'daily',
|
||||
},
|
||||
{
|
||||
title: 'Kunjungan Hari Ini',
|
||||
icon: Calendar,
|
||||
metric: 52,
|
||||
trend: 1,
|
||||
timeframe: 'daily',
|
||||
},
|
||||
{
|
||||
title: 'Peserta BPJS',
|
||||
icon: Hospital,
|
||||
metric: 71,
|
||||
trend: -3,
|
||||
timeframe: 'daily',
|
||||
},
|
||||
]
|
||||
|
||||
// API call function
|
||||
async function getPatientSummary() {
|
||||
try {
|
||||
isLoading.summary = true
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
} catch (error) {
|
||||
console.error('Error fetching patient summary:', error)
|
||||
// Keep default/existing data on error
|
||||
} finally {
|
||||
isLoading.summary = false
|
||||
}
|
||||
}
|
||||
|
||||
async function getPatientList() {
|
||||
isLoading.isTableLoading = true
|
||||
const resp = await xfetch('/api/v1/patient')
|
||||
const resp = await xfetch('/api/v1/medicine')
|
||||
if (resp.success) {
|
||||
data.value = (resp.body as Record<string, any>).data
|
||||
}
|
||||
@@ -95,7 +46,6 @@ async function getPatientList() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getPatientSummary()
|
||||
getPatientList()
|
||||
})
|
||||
|
||||
@@ -108,14 +58,6 @@ provide('table_data_loader', isLoading)
|
||||
<template>
|
||||
<Header :prep="{ ...hreaderPrep }" :ref-search-nav="refSearchNav" />
|
||||
<div class="my-4 flex flex-1 flex-col gap-4 md:gap-8">
|
||||
<div class="grid gap-4 md:grid-cols-2 md:gap-8 lg:grid-cols-4">
|
||||
<template v-if="isLoading.summary">
|
||||
<SummaryCard v-for="n in 4" :key="n" is-skeleton />
|
||||
</template>
|
||||
<template v-else>
|
||||
<SummaryCard v-for="card in summaryData" :key="card.title" :stat="card" />
|
||||
</template>
|
||||
</div>
|
||||
<AppPatientList :data="data" />
|
||||
<AppMedicineList :data="data" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user