2023-02-28 08:29:30 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>
|
|
|
|
DataView supports <i>list</i> and <i>grid</i> display modes defined with the <i>layout</i> property. The helper <i>DataViewLayoutOptions</i> component can be used to switch between the modes however this component is optional and you may
|
2023-11-15 09:51:35 +00:00
|
|
|
use your own UI to switch modes as well.
|
2023-02-28 08:29:30 +00:00
|
|
|
</p>
|
|
|
|
</DocSectionText>
|
|
|
|
<div class="card">
|
|
|
|
<DataView :value="products" :layout="layout">
|
|
|
|
<template #header>
|
|
|
|
<div class="flex justify-content-end">
|
|
|
|
<DataViewLayoutOptions v-model="layout" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #list="slotProps">
|
2023-11-15 09:51:35 +00:00
|
|
|
<div class="grid grid-nogutter">
|
|
|
|
<div v-for="(item, index) in slotProps.items" :key="index" class="col-12">
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="flex flex-column sm:flex-row sm:align-items-center p-4 gap-3" :class="{ 'border-top-1 surface-border': index !== 0 }">
|
|
|
|
<div class="md:w-10rem relative">
|
|
|
|
<img class="shadow-2 block xl:block mx-auto border-round w-full" :src="`https://primefaces.org/cdn/primevue/images/product/${item.image}`" :alt="item.name" />
|
|
|
|
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-column md:flex-row justify-content-between md:align-items-center flex-1 gap-4">
|
|
|
|
<div class="flex flex-row md:flex-column justify-content-between align-items-start gap-2">
|
|
|
|
<div>
|
|
|
|
<span class="font-medium text-secondary text-sm">{{ item.category }}</span>
|
|
|
|
<div class="text-lg font-medium text-900 mt-2">{{ item.name }}</div>
|
|
|
|
</div>
|
|
|
|
<div class="surface-100 p-1" style="border-radius: 30px">
|
|
|
|
<div class="surface-0 flex align-items-center gap-2 justify-content-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
|
|
<span class="text-900 font-medium text-sm">{{ item.rating }}</span>
|
|
|
|
<i class="pi pi-star-fill text-yellow-500"></i>
|
|
|
|
</div>
|
2023-11-15 09:51:35 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="flex flex-column md:align-items-end gap-5">
|
|
|
|
<span class="text-xl font-semibold text-900">${{ item.price }}</span>
|
|
|
|
<div class="flex flex-row-reverse md:flex-row gap-2">
|
|
|
|
<Button icon="pi pi-heart" outlined></Button>
|
|
|
|
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial white-space-nowrap"></Button>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #grid="slotProps">
|
2023-11-15 09:51:35 +00:00
|
|
|
<div class="grid grid-nogutter">
|
2024-01-24 08:38:08 +00:00
|
|
|
<div v-for="(item, index) in slotProps.items" :key="index" class="col-12 sm:col-6 md:col-4 xl:col-6 p-2">
|
|
|
|
<div class="p-4 border-1 surface-border surface-card border-round flex flex-column">
|
|
|
|
<div class="surface-50 flex justify-content-center border-round p-3">
|
|
|
|
<div class="relative mx-auto">
|
2024-01-24 08:39:54 +00:00
|
|
|
<img class="shadow-2 border-round w-full" :src="`https://primefaces.org/cdn/primevue/images/product/${item.image}`" :alt="item.name" style="max-width: 300px" />
|
2024-01-24 08:38:08 +00:00
|
|
|
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
|
2023-11-15 09:51:35 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="pt-4">
|
|
|
|
<div class="flex flex-row justify-content-between align-items-start gap-2">
|
|
|
|
<div>
|
|
|
|
<span class="font-medium text-secondary text-sm">{{ item.category }}</span>
|
|
|
|
<div class="text-lg font-medium text-900 mt-1">{{ item.name }}</div>
|
|
|
|
</div>
|
|
|
|
<div class="surface-100 p-1" style="border-radius: 30px">
|
|
|
|
<div class="surface-0 flex align-items-center gap-2 justify-content-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
|
|
<span class="text-900 font-medium text-sm">{{ item.rating }}</span>
|
|
|
|
<i class="pi pi-star-fill text-yellow-500"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-column gap-4 mt-4">
|
|
|
|
<span class="text-2xl font-semibold text-900">${{ item.price }}</span>
|
|
|
|
<div class="flex gap-2">
|
|
|
|
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto white-space-nowrap"></Button>
|
|
|
|
<Button icon="pi pi-heart" outlined></Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</DataView>
|
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" :service="['ProductService']" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
products: null,
|
|
|
|
layout: 'grid',
|
|
|
|
code: {
|
2023-09-22 12:54:14 +00:00
|
|
|
basic: `
|
|
|
|
<DataView :value="products" :layout="layout">
|
2023-02-28 08:29:30 +00:00
|
|
|
<template #header>
|
|
|
|
<div class="flex justify-content-end">
|
|
|
|
<DataViewLayoutOptions v-model="layout" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #list="slotProps">
|
2023-11-15 09:51:35 +00:00
|
|
|
<div class="grid grid-nogutter">
|
|
|
|
<div v-for="(item, index) in slotProps.items" :key="index" class="col-12">
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="flex flex-column sm:flex-row sm:align-items-center p-4 gap-3" :class="{ 'border-top-1 surface-border': index !== 0 }">
|
|
|
|
<div class="md:w-10rem relative">
|
|
|
|
<img class="shadow-2 block xl:block mx-auto border-round w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
|
|
|
|
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-column md:flex-row justify-content-between md:align-items-center flex-1 gap-4">
|
|
|
|
<div class="flex flex-row md:flex-column justify-content-between align-items-start gap-2">
|
|
|
|
<div>
|
|
|
|
<span class="font-medium text-secondary text-sm">{{ item.category }}</span>
|
|
|
|
<div class="text-lg font-medium text-900 mt-2">{{ item.name }}</div>
|
|
|
|
</div>
|
|
|
|
<div class="surface-100 p-1" style="border-radius: 30px">
|
|
|
|
<div class="surface-0 flex align-items-center gap-2 justify-content-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
|
|
<span class="text-900 font-medium text-sm">{{ item.rating }}</span>
|
|
|
|
<i class="pi pi-star-fill text-yellow-500"></i>
|
|
|
|
</div>
|
2023-11-15 09:51:35 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="flex flex-column md:align-items-end gap-5">
|
|
|
|
<span class="text-xl font-semibold text-900">\${{ item.price }}</span>
|
|
|
|
<div class="flex flex-row-reverse md:flex-row gap-2">
|
|
|
|
<Button icon="pi pi-heart" outlined></Button>
|
|
|
|
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial white-space-nowrap"></Button>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #grid="slotProps">
|
2023-11-15 09:51:35 +00:00
|
|
|
<div class="grid grid-nogutter">
|
2024-01-24 08:38:08 +00:00
|
|
|
<div v-for="(item, index) in slotProps.items" :key="index" class="col-12 sm:col-6 md:col-4 xl:col-6 p-2">
|
|
|
|
<div class="p-4 border-1 surface-border surface-card border-round flex flex-column">
|
|
|
|
<div class="surface-50 flex justify-content-center border-round p-3">
|
|
|
|
<div class="relative mx-auto">
|
|
|
|
<img class="shadow-2 border-round w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" style="max-width: 300px"/>
|
|
|
|
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
|
2023-11-15 09:51:35 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="pt-4">
|
|
|
|
<div class="flex flex-row justify-content-between align-items-start gap-2">
|
|
|
|
<div>
|
|
|
|
<span class="font-medium text-secondary text-sm">{{ item.category }}</span>
|
|
|
|
<div class="text-lg font-medium text-900 mt-1">{{ item.name }}</div>
|
|
|
|
</div>
|
|
|
|
<div class="surface-100 p-1" style="border-radius: 30px">
|
|
|
|
<div class="surface-0 flex align-items-center gap-2 justify-content-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
|
|
<span class="text-900 font-medium text-sm">{{ item.rating }}</span>
|
|
|
|
<i class="pi pi-star-fill text-yellow-500"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-column gap-4 mt-4">
|
|
|
|
<span class="text-2xl font-semibold text-900">\${{ item.price }}</span>
|
|
|
|
<div class="flex gap-2">
|
|
|
|
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto white-space-nowrap"></Button>
|
|
|
|
<Button icon="pi pi-heart" outlined></Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2023-10-15 09:38:39 +00:00
|
|
|
</DataView>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
options: `
|
|
|
|
<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="card">
|
|
|
|
<DataView :value="products" :layout="layout">
|
|
|
|
<template #header>
|
|
|
|
<div class="flex justify-content-end">
|
|
|
|
<DataViewLayoutOptions v-model="layout" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #list="slotProps">
|
2023-11-15 09:51:35 +00:00
|
|
|
<div class="grid grid-nogutter">
|
|
|
|
<div v-for="(item, index) in slotProps.items" :key="index" class="col-12">
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="flex flex-column sm:flex-row sm:align-items-center p-4 gap-3" :class="{ 'border-top-1 surface-border': index !== 0 }">
|
|
|
|
<div class="md:w-10rem relative">
|
|
|
|
<img class="shadow-2 block xl:block mx-auto border-round w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
|
|
|
|
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-column md:flex-row justify-content-between md:align-items-center flex-1 gap-4">
|
|
|
|
<div class="flex flex-row md:flex-column justify-content-between align-items-start gap-2">
|
|
|
|
<div>
|
|
|
|
<span class="font-medium text-secondary text-sm">{{ item.category }}</span>
|
|
|
|
<div class="text-lg font-medium text-900 mt-2">{{ item.name }}</div>
|
|
|
|
</div>
|
|
|
|
<div class="surface-100 p-1" style="border-radius: 30px">
|
|
|
|
<div class="surface-0 flex align-items-center gap-2 justify-content-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
|
|
<span class="text-900 font-medium text-sm">{{ item.rating }}</span>
|
|
|
|
<i class="pi pi-star-fill text-yellow-500"></i>
|
|
|
|
</div>
|
2023-11-15 09:51:35 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="flex flex-column md:align-items-end gap-5">
|
|
|
|
<span class="text-xl font-semibold text-900">\${{ item.price }}</span>
|
|
|
|
<div class="flex flex-row-reverse md:flex-row gap-2">
|
|
|
|
<Button icon="pi pi-heart" outlined></Button>
|
|
|
|
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial white-space-nowrap"></Button>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #grid="slotProps">
|
2023-11-15 09:51:35 +00:00
|
|
|
<div class="grid grid-nogutter">
|
2024-01-24 08:38:08 +00:00
|
|
|
<div v-for="(item, index) in slotProps.items" :key="index" class="col-12 sm:col-6 md:col-4 xl:col-6 p-2">
|
|
|
|
<div class="p-4 border-1 surface-border surface-card border-round flex flex-column">
|
|
|
|
<div class="surface-50 flex justify-content-center border-round p-3">
|
|
|
|
<div class="relative mx-auto">
|
|
|
|
<img class="shadow-2 border-round w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" style="max-width: 300px"/>
|
|
|
|
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
|
2023-11-15 09:51:35 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="pt-4">
|
|
|
|
<div class="flex flex-row justify-content-between align-items-start gap-2">
|
|
|
|
<div>
|
|
|
|
<span class="font-medium text-secondary text-sm">{{ item.category }}</span>
|
|
|
|
<div class="text-lg font-medium text-900 mt-1">{{ item.name }}</div>
|
|
|
|
</div>
|
|
|
|
<div class="surface-100 p-1" style="border-radius: 30px">
|
|
|
|
<div class="surface-0 flex align-items-center gap-2 justify-content-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
|
|
<span class="text-900 font-medium text-sm">{{ item.rating }}</span>
|
|
|
|
<i class="pi pi-star-fill text-yellow-500"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-column gap-4 mt-4">
|
|
|
|
<span class="text-2xl font-semibold text-900">\${{ item.price }}</span>
|
|
|
|
<div class="flex gap-2">
|
|
|
|
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto white-space-nowrap"></Button>
|
|
|
|
<Button icon="pi pi-heart" outlined></Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</DataView>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
products: null,
|
|
|
|
layout: 'grid'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
ProductService.getProducts().then((data) => (this.products = data.slice(0, 12)));
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getSeverity(product) {
|
|
|
|
switch (product.inventoryStatus) {
|
|
|
|
case 'INSTOCK':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'LOWSTOCK':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'OUTOFSTOCK':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-09-22 12:54:14 +00:00
|
|
|
composition: `
|
|
|
|
<template>
|
2023-02-28 08:29:30 +00:00
|
|
|
<div class="card">
|
|
|
|
<DataView :value="products" :layout="layout">
|
|
|
|
<template #header>
|
|
|
|
<div class="flex justify-content-end">
|
|
|
|
<DataViewLayoutOptions v-model="layout" />
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #list="slotProps">
|
2023-11-15 09:51:35 +00:00
|
|
|
<div class="grid grid-nogutter">
|
|
|
|
<div v-for="(item, index) in slotProps.items" :key="index" class="col-12">
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="flex flex-column sm:flex-row sm:align-items-center p-4 gap-3" :class="{ 'border-top-1 surface-border': index !== 0 }">
|
|
|
|
<div class="md:w-10rem relative">
|
|
|
|
<img class="shadow-2 block xl:block mx-auto border-round w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" />
|
|
|
|
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-column md:flex-row justify-content-between md:align-items-center flex-1 gap-4">
|
|
|
|
<div class="flex flex-row md:flex-column justify-content-between align-items-start gap-2">
|
|
|
|
<div>
|
|
|
|
<span class="font-medium text-secondary text-sm">{{ item.category }}</span>
|
|
|
|
<div class="text-lg font-medium text-900 mt-2">{{ item.name }}</div>
|
|
|
|
</div>
|
|
|
|
<div class="surface-100 p-1" style="border-radius: 30px">
|
|
|
|
<div class="surface-0 flex align-items-center gap-2 justify-content-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
|
|
<span class="text-900 font-medium text-sm">{{ item.rating }}</span>
|
|
|
|
<i class="pi pi-star-fill text-yellow-500"></i>
|
|
|
|
</div>
|
2023-11-15 09:51:35 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="flex flex-column md:align-items-end gap-5">
|
|
|
|
<span class="text-xl font-semibold text-900">\${{ item.price }}</span>
|
|
|
|
<div class="flex flex-row-reverse md:flex-row gap-2">
|
|
|
|
<Button icon="pi pi-heart" outlined></Button>
|
|
|
|
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto md:flex-initial white-space-nowrap"></Button>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #grid="slotProps">
|
2023-11-15 09:51:35 +00:00
|
|
|
<div class="grid grid-nogutter">
|
2024-01-24 08:38:08 +00:00
|
|
|
<div v-for="(item, index) in slotProps.items" :key="index" class="col-12 sm:col-6 md:col-4 xl:col-6 p-2">
|
|
|
|
<div class="p-4 border-1 surface-border surface-card border-round flex flex-column">
|
|
|
|
<div class="surface-50 flex justify-content-center border-round p-3">
|
|
|
|
<div class="relative mx-auto">
|
|
|
|
<img class="shadow-2 border-round w-full" :src="\`https://primefaces.org/cdn/primevue/images/product/\${item.image}\`" :alt="item.name" style="max-width: 300px"/>
|
|
|
|
<Tag :value="item.inventoryStatus" :severity="getSeverity(item)" class="absolute" style="left: 4px; top: 4px"></Tag>
|
2023-11-15 09:51:35 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-24 08:38:08 +00:00
|
|
|
<div class="pt-4">
|
|
|
|
<div class="flex flex-row justify-content-between align-items-start gap-2">
|
|
|
|
<div>
|
|
|
|
<span class="font-medium text-secondary text-sm">{{ item.category }}</span>
|
|
|
|
<div class="text-lg font-medium text-900 mt-1">{{ item.name }}</div>
|
|
|
|
</div>
|
|
|
|
<div class="surface-100 p-1" style="border-radius: 30px">
|
|
|
|
<div class="surface-0 flex align-items-center gap-2 justify-content-center py-1 px-2" style="border-radius: 30px; box-shadow: 0px 1px 2px 0px rgba(0, 0, 0, 0.04), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)">
|
|
|
|
<span class="text-900 font-medium text-sm">{{ item.rating }}</span>
|
|
|
|
<i class="pi pi-star-fill text-yellow-500"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex flex-column gap-4 mt-4">
|
|
|
|
<span class="text-2xl font-semibold text-900">\${{ item.price }}</span>
|
|
|
|
<div class="flex gap-2">
|
|
|
|
<Button icon="pi pi-shopping-cart" label="Buy Now" :disabled="item.inventoryStatus === 'OUTOFSTOCK'" class="flex-auto white-space-nowrap"></Button>
|
|
|
|
<Button icon="pi pi-heart" outlined></Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-02-28 08:29:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</DataView>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { ref, onMounted } from "vue";
|
|
|
|
import { ProductService } from '@/service/ProductService';
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
ProductService.getProducts().then((data) => (products.value = data.slice(0, 12)));
|
|
|
|
});
|
|
|
|
|
|
|
|
const products = ref();
|
|
|
|
const layout = ref('grid');
|
|
|
|
|
|
|
|
const getSeverity = (product) => {
|
|
|
|
switch (product.inventoryStatus) {
|
|
|
|
case 'INSTOCK':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'LOWSTOCK':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'OUTOFSTOCK':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-15 09:38:39 +00:00
|
|
|
<\/script>
|
|
|
|
`,
|
2023-02-28 08:29:30 +00:00
|
|
|
data: `
|
2023-11-15 09:51:35 +00:00
|
|
|
/* ProductService */
|
2023-02-28 08:29:30 +00:00
|
|
|
{
|
|
|
|
id: '1000',
|
|
|
|
code: 'f230fh0g3',
|
|
|
|
name: 'Bamboo Watch',
|
|
|
|
description: 'Product Description',
|
|
|
|
image: 'bamboo-watch.jpg',
|
|
|
|
price: 65,
|
|
|
|
category: 'Accessories',
|
|
|
|
quantity: 24,
|
|
|
|
inventoryStatus: 'INSTOCK',
|
|
|
|
rating: 5
|
|
|
|
},
|
|
|
|
...
|
|
|
|
`
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
ProductService.getProducts().then((data) => (this.products = data.slice(0, 12)));
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
getSeverity(product) {
|
|
|
|
switch (product.inventoryStatus) {
|
|
|
|
case 'INSTOCK':
|
|
|
|
return 'success';
|
|
|
|
|
|
|
|
case 'LOWSTOCK':
|
|
|
|
return 'warning';
|
|
|
|
|
|
|
|
case 'OUTOFSTOCK':
|
|
|
|
return 'danger';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|