|
1 | 1 | <template>
|
2 |
| - <div class="flex items-center justify-between mb-3"> |
3 |
| - <h1 class="text-3xl font-semibold">Products</h1> |
4 |
| - <button type="button" |
5 |
| - @click="showAddNewModal()" |
6 |
| - class="py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" |
7 |
| - > |
8 |
| - Add new Product |
9 |
| - </button> |
10 |
| - </div> |
11 | 2 | <div class="bg-white p-4 rounded-lg shadow">
|
12 | 3 | <div class="flex justify-between border-b-2 pb-3">
|
13 | 4 | <div class="flex items-center">
|
|
20 | 11 | <option value="50">50</option>
|
21 | 12 | <option value="100">100</option>
|
22 | 13 | </select>
|
| 14 | + <span class="ml-3">Found {{products.total}} products</span> |
23 | 15 | </div>
|
24 | 16 | <div>
|
25 | 17 | <input v-model="search" @change="getProducts(null)"
|
|
54 | 46 | </TableHeaderCell>
|
55 | 47 | </tr>
|
56 | 48 | </thead>
|
57 |
| - <tbody v-if="products.loading"> |
| 49 | + <tbody v-if="products.loading || !products.data.length"> |
58 | 50 | <tr>
|
59 | 51 | <td colspan="6">
|
60 |
| - <Spinner/> |
| 52 | + <Spinner v-if="products.loading"/> |
| 53 | + <p v-else class="text-center py-8 text-gray-700"> |
| 54 | + There are no products |
| 55 | + </p> |
61 | 56 | </td>
|
62 | 57 | </tr>
|
63 | 58 | </tbody>
|
|
142 | 137 | </table>
|
143 | 138 |
|
144 | 139 | <div v-if="!products.loading" class="flex justify-between items-center mt-5">
|
145 |
| - <span> |
146 |
| - Showing from {{ products.from }} to {{ products.to }} |
147 |
| - </span> |
| 140 | + <div v-if="products.data.length"> |
| 141 | + Showing from {{ products.from }} to {{ products.to }} |
| 142 | + </div> |
148 | 143 | <nav
|
149 | 144 | v-if="products.total > products.limit"
|
150 | 145 | class="relative z-0 inline-flex justify-center rounded-md shadow-sm -space-x-px"
|
|
173 | 168 | </nav>
|
174 | 169 | </div>
|
175 | 170 | </div>
|
176 |
| - <ProductModal v-model="showProductModal" :product="product"/> |
177 | 171 | </template>
|
178 | 172 |
|
179 | 173 | <script setup>
|
180 | 174 | import {computed, onMounted, ref} from "vue";
|
181 |
| -import store from "../store"; |
182 |
| -import Spinner from "../components/core/Spinner.vue"; |
183 |
| -import {PRODUCTS_PER_PAGE} from "../constants"; |
184 |
| -import TableHeaderCell from "../components/core/Table/TableHeaderCell.vue"; |
| 175 | +import store from "../../store"; |
| 176 | +import Spinner from "../../components/core/Spinner.vue"; |
| 177 | +import {PRODUCTS_PER_PAGE} from "../../constants"; |
| 178 | +import TableHeaderCell from "../../components/core/Table/TableHeaderCell.vue"; |
185 | 179 | import {Menu, MenuButton, MenuItem, MenuItems} from "@headlessui/vue";
|
186 | 180 | import {DotsVerticalIcon, PencilIcon, TrashIcon} from '@heroicons/vue/outline'
|
187 | 181 | import ProductModal from "./ProductModal.vue";
|
|
0 commit comments