⚠️ refactor (soapi): refactor form component to use usequerycrudmode and update api call

This commit is contained in:
Abizrh
2025-11-17 20:57:13 +07:00
parent 6ca03f562d
commit a8696284d7
5 changed files with 38 additions and 27 deletions
+8 -1
View File
@@ -7,6 +7,8 @@ import { EarlySchema } from '~/schemas/soapi.schema'
import { toast } from '~/components/pub/ui/toast'
import { handleActionSave, handleActionEdit } from '~/handlers/soapi-early.handler'
const { goToEntry, backToList } = useQueryCRUDMode('mode')
const { recordId } = useQueryCRUDMode('record-id')
const route = useRoute()
const isOpen = ref(false)
const data = ref([])
@@ -40,7 +42,7 @@ const isLoading = reactive<DataTableLoader>({
async function getPatientList() {
isLoading.isTableLoading = true
const resp = await xfetch('/api/v1/patient')
const resp = await xfetch(`/api/v1/soapi/${recordId}`)
if (resp.success) {
data.value = (resp.body as Record<string, any>).data
}
@@ -59,6 +61,11 @@ function handleOpen(type: string) {
const entryRef = ref()
async function actionHandler(type: string) {
console.log(type)
// if(type === ''
if (type === 'back') {
backToList()
return
}
const result = await entryRef.value?.validate()
if (result?.valid) {
console.log('data', result.data)