| 1 | <template> |
| 2 | <n-card |
| 3 | title="Recent Cases" |
| 4 | segmented |
| 5 | :content-class="`flex flex-col gap-4 overflow-hidden ${!recentCases.length ? 'items-center justify-center' : 'p-0!'}`" |
| 6 | > |
| 7 | <n-empty v-if="!recentCases.length" description="No recent cases" /> |
| 8 | |
| 9 | <n-scrollbar v-else class="flex grow" trigger="none"> |
| 10 | <div class="flex flex-col gap-4 p-4"> |
| 11 | <RecentCaseCard |
| 12 | v-for="caseData in recentCases" |
| 13 | :key="caseData.id" |
| 14 | embedded |
| 15 | :case-data |
| 16 | @updated="handleCaseUpdated()" |
| 17 | /> |
| 18 | </div> |
| 19 | </n-scrollbar> |
| 20 | |
| 21 | <n-button :text="!!recentCases.length" class="mb-4!" @click="goToCases()"> |
| 22 | <template #icon> |
| 23 | <Icon name="carbon:launch" /> |
| 24 | </template> |
| 25 | View all cases |
| 26 | </n-button> |
| 27 | </n-card> |
| 28 | </template> |
| 29 | |
| 30 | <script setup lang="ts"> |
| 31 | import type { DashboardCase } from "./types" |
| 32 | import { NButton, NCard, NEmpty, NScrollbar } from "naive-ui" |
| 33 | import Icon from "@/components/common/Icon.vue" |
| 34 | import { useNavigation } from "@/composables/common/useNavigation" |
| 35 | import RecentCaseCard from "./RecentCaseCard.vue" |
| 36 | |
| 37 | defineProps<{ |
| 38 | recentCases: DashboardCase[] |
| 39 | }>() |
| 40 | |
| 41 | const emit = defineEmits<{ |
| 42 | (e: "updated"): void |
| 43 | }>() |
| 44 | |
| 45 | const { routeCasesList } = useNavigation() |
| 46 | |
| 47 | function goToCases() { |
| 48 | routeCasesList().navigate() |
| 49 | } |
| 50 | |
| 51 | function handleCaseUpdated() { |
| 52 | emit("updated") |
| 53 | } |
| 54 | </script> |