Преглед изворни кода

fix: corrected TS errors for computed and icon imports

unknown пре 1 дан
родитељ
комит
f80385a29c
1 измењених фајлова са 15 додато и 7 уклоњено
  1. 15 7
      src/pages/Admin.vue

+ 15 - 7
src/pages/Admin.vue

@@ -245,7 +245,7 @@
                   <div class="flex flex-wrap gap-2 max-h-[200px] overflow-y-auto pr-1">
                      <div v-for="p in (editingOrder?.photos || [])" :key="p.id" class="relative group">
                         <img :src="`${RESOURCES_BASE_URL}/${p.file_path}`" class="w-12 h-12 object-cover rounded-lg border border-border/50 shadow-sm" />
-                        <button type="button" @click="handleDeletePhoto(editingOrder.id, p.id)" class="absolute -top-1 -right-1 p-0.5 bg-rose-500 text-white rounded-full opacity-0 group-hover:opacity-100 transition-opacity shadow-lg">
+                        <button type="button" @click="handleDeletePhoto(p.id)" class="absolute -top-1 -right-1 p-0.5 bg-rose-500 text-white rounded-full opacity-0 group-hover:opacity-100 transition-opacity shadow-lg">
                            <X class="w-2.5 h-2.5" />
                         </button>
                      </div>
@@ -327,7 +327,7 @@
 </template>
 
 <script setup lang="ts">
-import { ref, watch, reactive, onMounted, onUnmounted } from "vue";
+import { ref, watch, reactive, computed, onMounted, onUnmounted } from "vue";
 import { useRouter, useRoute, RouterLink } from "vue-router";
 import { useI18n } from "vue-i18n";
 import { loadAdminTranslations } from "@/i18n";
@@ -336,7 +336,8 @@ import { toast } from "vue-sonner";
 // Icons
 import { 
   Package, Clock, RefreshCw, Search, Layers, Plus, Database, 
-  Newspaper, History, X, Users, ImageIcon, Truck, CheckCircle2, XCircle, Star
+  Newspaper, History, X, Users, ImageIcon, Truck, CheckCircle2, XCircle, Star,
+  Trash2, MessageCircle, Edit2
 } from "lucide-vue-next";
 
 // UI Components
@@ -480,8 +481,8 @@ onUnmounted(() => {
 
 const newColor = ref("");
 
-const activeMaterials = computed(() => materials.value.filter(m => m.is_active));
-const selectedMaterialObj = computed(() => activeMaterials.value.find(m => m.name === orderForm.material_name));
+const activeMaterials = computed(() => materials.value.filter((m: any) => m.is_active));
+const selectedMaterialObj = computed(() => activeMaterials.value.find((m: any) => m.name === orderForm.material_name));
 const materialColors = computed(() => {
   if (!selectedMaterialObj.value) return [];
   try {
@@ -599,9 +600,16 @@ const handleDeleteFile = async (id: number, fid: number, fname: string) => {
   }
 };
 
-const handleDeletePhoto = async (id: number) => {
+const handleDeletePhoto = async (photoId: number) => {
   if (confirm(`Delete photo?`)) { 
-    try { await adminDeletePhoto(id); fetchData(); }
+    try { 
+      await adminDeletePhoto(photoId); 
+      await fetchData();
+      if (editingOrder.value) {
+        const updated = orders.value.find(o => o.id === editingOrder.value?.id);
+        if (updated) editingOrder.value = updated;
+      }
+    }
     catch (err: any) { toast.error(err.message); }
   }
 };