diff --git a/frontend/src/components/WarrantyPanel.vue b/frontend/src/components/WarrantyPanel.vue index 9d83bdd..be152b7 100644 --- a/frontend/src/components/WarrantyPanel.vue +++ b/frontend/src/components/WarrantyPanel.vue @@ -33,6 +33,9 @@ const props = defineProps({ assetid: { type: [Number, String], default: null }, // When true, render the card even with no warranties (shows an "Add one" link). showEmpty: { type: Boolean, default: false }, + // Optional pre-fetched warranties. When provided, the panel uses them instead + // of fetching (lets a parent share one fetch with e.g. a hero badge). + items: { type: Array, default: null }, }) const warranties = ref([]) @@ -47,6 +50,8 @@ function formatDate(d) { } async function load() { + // Parent-supplied data wins - skip the fetch. + if (props.items !== null) { warranties.value = props.items; return } if (!props.assetid) { warranties.value = []; return } try { const response = await warrantyApi.forAsset(props.assetid) @@ -59,6 +64,7 @@ async function load() { onMounted(load) watch(() => props.assetid, load) +watch(() => props.items, load)