Skip to content

Commit cf40964

Browse files
committed
chore: wip
1 parent 80f7d61 commit cf40964

File tree

3 files changed

+131
-17
lines changed

3 files changed

+131
-17
lines changed

storage/framework/defaults/views/dashboard/commerce/categories/index.vue

Lines changed: 124 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const categories = ref([
1515
description: 'Traditional and specialty pizzas',
1616
productCount: 24,
1717
featured: true,
18-
createdAt: '2023-05-10'
18+
createdAt: '2023-05-10',
19+
image: '/images/categories/pizza.jpg'
1920
},
2021
{
2122
id: 2,
@@ -24,7 +25,8 @@ const categories = ref([
2425
description: 'Gourmet and classic burgers',
2526
productCount: 18,
2627
featured: true,
27-
createdAt: '2023-05-15'
28+
createdAt: '2023-05-15',
29+
image: ''
2830
},
2931
{
3032
id: 3,
@@ -33,7 +35,8 @@ const categories = ref([
3335
description: 'Fresh sushi, rolls, and Japanese cuisine',
3436
productCount: 32,
3537
featured: true,
36-
createdAt: '2023-06-01'
38+
createdAt: '2023-06-01',
39+
image: '/images/categories/sushi.jpg'
3740
},
3841
{
3942
id: 4,
@@ -42,7 +45,8 @@ const categories = ref([
4245
description: 'Authentic Mexican dishes and street food',
4346
productCount: 22,
4447
featured: false,
45-
createdAt: '2023-06-10'
48+
createdAt: '2023-06-10',
49+
image: ''
4650
},
4751
{
4852
id: 5,
@@ -51,7 +55,8 @@ const categories = ref([
5155
description: 'Italian pasta dishes and specialties',
5256
productCount: 16,
5357
featured: false,
54-
createdAt: '2023-06-20'
58+
createdAt: '2023-06-20',
59+
image: '/images/categories/pasta.jpg'
5560
},
5661
{
5762
id: 6,
@@ -60,7 +65,8 @@ const categories = ref([
6065
description: 'Nutritious, plant-based, and health-conscious options',
6166
productCount: 28,
6267
featured: true,
63-
createdAt: '2023-07-05'
68+
createdAt: '2023-07-05',
69+
image: '/images/categories/healthy.jpg'
6470
},
6571
{
6672
id: 7,
@@ -69,7 +75,8 @@ const categories = ref([
6975
description: 'Sweet treats, cakes, and pastries',
7076
productCount: 35,
7177
featured: false,
72-
createdAt: '2023-07-15'
78+
createdAt: '2023-07-15',
79+
image: ''
7380
},
7481
{
7582
id: 8,
@@ -78,7 +85,8 @@ const categories = ref([
7885
description: 'Coffee, tea, smoothies, and specialty drinks',
7986
productCount: 19,
8087
featured: false,
81-
createdAt: '2023-08-01'
88+
createdAt: '2023-08-01',
89+
image: '/images/categories/beverages.jpg'
8290
},
8391
{
8492
id: 9,
@@ -87,7 +95,8 @@ const categories = ref([
8795
description: 'Starters, small plates, and shareable items',
8896
productCount: 26,
8997
featured: true,
90-
createdAt: '2023-08-10'
98+
createdAt: '2023-08-10',
99+
image: '/images/categories/appetizers.jpg'
91100
},
92101
{
93102
id: 10,
@@ -96,7 +105,8 @@ const categories = ref([
96105
description: 'Creative dishes combining Asian culinary traditions',
97106
productCount: 21,
98107
featured: false,
99-
createdAt: '2023-08-20'
108+
createdAt: '2023-08-20',
109+
image: ''
100110
}
101111
])
102112
@@ -152,17 +162,45 @@ const newCategory = ref<{
152162
name: string;
153163
description: string;
154164
featured: boolean;
165+
image: string;
155166
}>({
156167
name: '',
157168
description: '',
158-
featured: false
169+
featured: false,
170+
image: ''
159171
})
160172
173+
// Image preview helper
174+
const imagePreview = computed(() => {
175+
return newCategory.value.image || '/images/categories/placeholder.jpg'
176+
})
177+
178+
// Handle file upload
179+
function handleImageUpload(event: Event): void {
180+
const input = event.target as HTMLInputElement
181+
if (input.files && input.files[0]) {
182+
const file = input.files[0]
183+
184+
// In a real application, you would upload the file to a server
185+
// and get back a URL. For this demo, we'll simulate that by
186+
// creating a local object URL.
187+
const reader = new FileReader()
188+
reader.onload = (e) => {
189+
if (e.target && e.target.result) {
190+
// In a real app, this would be the URL returned from the server
191+
newCategory.value.image = e.target.result as string
192+
}
193+
}
194+
reader.readAsDataURL(file)
195+
}
196+
}
197+
161198
function openAddModal(): void {
162199
newCategory.value = {
163200
name: '',
164201
description: '',
165-
featured: false
202+
featured: false,
203+
image: ''
166204
}
167205
showAddModal.value = true
168206
}
@@ -183,10 +221,19 @@ function addCategory(): void {
183221
description: newCategory.value.description || '',
184222
productCount: 0,
185223
featured: newCategory.value.featured,
186-
createdAt: currentDate
224+
createdAt: currentDate,
225+
image: newCategory.value.image || '/images/categories/placeholder.jpg'
187226
})
188227
closeAddModal()
189228
}
229+
230+
// Color mapping for initial letters
231+
const initialColors: Record<string, string> = {
232+
'Burgers': 'bg-red-500',
233+
'Mexican': 'bg-green-500',
234+
'Desserts': 'bg-purple-500',
235+
'Asian Fusion': 'bg-blue-500'
236+
}
190237
</script>
191238

192239
<template>
@@ -291,8 +338,26 @@ function addCategory(): void {
291338
</thead>
292339
<tbody class="divide-y divide-gray-200 bg-white dark:divide-gray-700 dark:bg-blue-gray-800">
293340
<tr v-for="category in filteredCategories" :key="category.id">
294-
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 sm:pl-6 dark:text-white">
295-
{{ category.name }}
341+
<td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900 dark:text-white">
342+
<div class="flex items-center space-x-3">
343+
<template v-if="category.image">
344+
<img
345+
:src="category.image"
346+
:alt="category.name"
347+
class="h-10 w-10 rounded-full object-cover border border-gray-200 dark:border-gray-700 shadow-sm"
348+
onerror="this.src='/images/categories/placeholder.jpg'"
349+
/>
350+
</template>
351+
<template v-else>
352+
<div
353+
:class="['h-10 w-10 rounded-full flex items-center justify-center text-white font-medium shadow-sm',
354+
initialColors[category.name] || 'bg-blue-500']"
355+
>
356+
{{ category.name ? category.name.charAt(0).toUpperCase() : '?' }}
357+
</div>
358+
</template>
359+
<span>{{ category.name }}</span>
360+
</div>
296361
</td>
297362
<td class="px-3 py-4 text-sm text-gray-500 dark:text-gray-300">
298363
{{ category.description }}
@@ -310,7 +375,7 @@ function addCategory(): void {
310375
<td class="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-6">
311376
<div class="flex items-center justify-end space-x-2">
312377
<button type="button" class="text-blue-600 hover:text-blue-900 dark:text-blue-400 dark:hover:text-blue-300">
313-
<div class="i-hugeicons-license-draft h-5 w-5"></div>
378+
<div class="i-hugeicons-edit-01 h-5 w-5"></div>
314379
</button>
315380
<button type="button" class="text-red-600 hover:text-red-900 dark:text-red-400 dark:hover:text-red-300">
316381
<div class="i-hugeicons-waste h-5 w-5"></div>
@@ -365,6 +430,49 @@ function addCategory(): void {
365430
></textarea>
366431
</div>
367432
</div>
433+
<div>
434+
<label for="category-image" class="block text-sm font-medium leading-6 text-gray-900 dark:text-gray-200 text-left">Image</label>
435+
<div class="mt-2">
436+
<div class="flex items-center gap-3">
437+
<input
438+
type="text"
439+
id="category-image"
440+
v-model="newCategory.image"
441+
placeholder="/images/categories/your-category.jpg"
442+
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:text-sm sm:leading-6 dark:bg-blue-gray-700 dark:text-white dark:ring-gray-600"
443+
/>
444+
<span class="text-gray-500 dark:text-gray-400">or</span>
445+
<label for="file-upload" class="cursor-pointer rounded-md bg-white px-2.5 py-1.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 dark:bg-blue-gray-700 dark:text-white dark:ring-gray-600 dark:hover:bg-blue-gray-600">
446+
Browse
447+
<input
448+
id="file-upload"
449+
type="file"
450+
accept="image/*"
451+
class="sr-only"
452+
@change="handleImageUpload"
453+
/>
454+
</label>
455+
</div>
456+
</div>
457+
<div class="mt-2 flex justify-center">
458+
<template v-if="newCategory.image">
459+
<img
460+
:src="imagePreview"
461+
alt="Category preview"
462+
class="h-16 w-16 rounded-full object-cover border border-gray-200 dark:border-gray-700 shadow-sm"
463+
onerror="this.src='/images/categories/placeholder.jpg'"
464+
/>
465+
</template>
466+
<template v-else>
467+
<div
468+
class="h-16 w-16 rounded-full flex items-center justify-center text-white font-medium shadow-sm bg-blue-500"
469+
>
470+
{{ newCategory.name ? newCategory.name.charAt(0).toUpperCase() : '?' }}
471+
</div>
472+
</template>
473+
</div>
474+
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400 text-left">Enter the URL of the category image or upload a file</p>
475+
</div>
368476
<div class="flex items-center">
369477
<input
370478
id="category-featured"

storage/framework/defaults/views/dashboard/commerce/orders/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ function getStatusClass(status: string): string {
344344
<div class="i-hugeicons-eye-01 h-5 w-5"></div>
345345
</button>
346346
<button type="button" class="text-blue-600 hover:text-blue-900 dark:text-blue-400 dark:hover:text-blue-300">
347-
<div class="i-hugeicons-license-draft h-5 w-5"></div>
347+
<div class="i-hugeicons-edit-01 h-5 w-5"></div>
348348
</button>
349349
</div>
350350
</td>

storage/framework/types/router.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ declare module 'vue-router/auto-routes' {
3535
'/dashboard/commerce/coupons/': RouteRecordInfo<'/dashboard/commerce/coupons/', '/dashboard/commerce/coupons', Record<never, never>, Record<never, never>>,
3636
'/dashboard/commerce/customers/': RouteRecordInfo<'/dashboard/commerce/customers/', '/dashboard/commerce/customers', Record<never, never>, Record<never, never>>,
3737
'/dashboard/commerce/delivery/': RouteRecordInfo<'/dashboard/commerce/delivery/', '/dashboard/commerce/delivery', Record<never, never>, Record<never, never>>,
38+
'/dashboard/commerce/delivery/delivery-routes': RouteRecordInfo<'/dashboard/commerce/delivery/delivery-routes', '/dashboard/commerce/delivery/delivery-routes', Record<never, never>, Record<never, never>>,
39+
'/dashboard/commerce/delivery/digital-delivery': RouteRecordInfo<'/dashboard/commerce/delivery/digital-delivery', '/dashboard/commerce/delivery/digital-delivery', Record<never, never>, Record<never, never>>,
40+
'/dashboard/commerce/delivery/license-keys': RouteRecordInfo<'/dashboard/commerce/delivery/license-keys', '/dashboard/commerce/delivery/license-keys', Record<never, never>, Record<never, never>>,
41+
'/dashboard/commerce/delivery/shipping-methods': RouteRecordInfo<'/dashboard/commerce/delivery/shipping-methods', '/dashboard/commerce/delivery/shipping-methods', Record<never, never>, Record<never, never>>,
42+
'/dashboard/commerce/delivery/shipping-rates': RouteRecordInfo<'/dashboard/commerce/delivery/shipping-rates', '/dashboard/commerce/delivery/shipping-rates', Record<never, never>, Record<never, never>>,
43+
'/dashboard/commerce/delivery/shipping-zones': RouteRecordInfo<'/dashboard/commerce/delivery/shipping-zones', '/dashboard/commerce/delivery/shipping-zones', Record<never, never>, Record<never, never>>,
3844
'/dashboard/commerce/gift-cards/': RouteRecordInfo<'/dashboard/commerce/gift-cards/', '/dashboard/commerce/gift-cards', Record<never, never>, Record<never, never>>,
3945
'/dashboard/commerce/manufacturers/': RouteRecordInfo<'/dashboard/commerce/manufacturers/', '/dashboard/commerce/manufacturers', Record<never, never>, Record<never, never>>,
4046
'/dashboard/commerce/orders/': RouteRecordInfo<'/dashboard/commerce/orders/', '/dashboard/commerce/orders', Record<never, never>, Record<never, never>>,

0 commit comments

Comments
 (0)