Forráskód Böngészése

fix: corrected TS errors by moving window events to script section

unknown 1 napja
szülő
commit
6392d34e33
1 módosított fájl, 13 hozzáadás és 8 törlés
  1. 13 8
      src/components/admin/OrderCard.vue

+ 13 - 8
src/components/admin/OrderCard.vue

@@ -16,7 +16,7 @@
 
     <div class="flex flex-col lg:flex-row divide-y lg:divide-y-0 lg:divide-x divide-border/50">
       <!-- Info Column (Clickable for editing) -->
-      <div class="p-6 lg:w-1/2 cursor-pointer hover:bg-primary/5 transition-colors" @click="() => { $emit('edit-order', order); window.dispatchEvent(new CustomEvent('admin-edit-order', { detail: order })); }">
+      <div class="p-6 lg:w-1/2 cursor-pointer hover:bg-primary/5 transition-colors" @click="triggerEditOrder">
         <div class="flex items-center justify-between mb-4">
           <div class="flex items-center gap-2">
             <span class="text-xl font-black text-foreground bg-primary/10 px-3 py-1 rounded-xl tracking-tight">#{{ order.id }}</span>
@@ -32,7 +32,7 @@
           <div class="flex flex-col">
             <div class="flex items-center gap-2">
               <h3 class="font-bold leading-none">{{ order.first_name }} {{ order.last_name }}</h3>
-              <button @click.stop="() => { $emit('edit-order', order); window.dispatchEvent(new CustomEvent('admin-edit-order', { detail: order })); }" class="p-1.5 bg-primary/5 hover:bg-primary/20 rounded-md text-primary transition-colors" style="position: relative; z-index: 100;">
+              <button @click.stop="triggerEditOrder" class="p-1.5 bg-primary/5 hover:bg-primary/20 rounded-md text-primary transition-colors" style="position: relative; z-index: 100;">
                 <Edit2 class="w-3 h-3" />
               </button>
             </div>
@@ -49,28 +49,28 @@
           <div v-if="order.phone" class="space-y-1">
             <div class="flex items-center justify-between">
               <span class="text-[9px] font-bold uppercase text-muted-foreground tracking-widest">{{ t("admin.fields.phone") }}</span>
-              <button @click.stop="$emit('edit-order', order)" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
+              <button @click.stop="triggerEditOrder" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
             </div>
             <p class="text-xs font-medium">{{ order.phone }}</p>
           </div>
           <div class="space-y-1">
             <div class="flex items-center justify-between">
               <span class="text-[9px] font-bold uppercase text-muted-foreground tracking-widest">{{ t("admin.labels.registered") }}</span>
-              <button @click.stop="$emit('edit-order', order)" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
+              <button @click.stop="triggerEditOrder" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
             </div>
             <p class="text-xs font-medium">{{ formatDate(order.created_at) }}</p>
           </div>
           <div class="space-y-1">
             <div class="flex items-center justify-between">
               <span class="text-[9px] font-bold uppercase text-muted-foreground tracking-widest">{{ t("admin.fields.address") }}</span>
-              <button @click.stop="$emit('edit-order', order)" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
+              <button @click.stop="triggerEditOrder" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
             </div>
             <p class="text-xs font-medium leading-relaxed">{{ order.shipping_address || '—' }}</p>
           </div>
           <div class="space-y-1">
              <div class="flex items-center justify-between">
                <span class="text-[9px] font-bold uppercase text-muted-foreground tracking-widest">{{ t("admin.fields.deliveryType") }}</span>
-               <button @click.stop="$emit('edit-order', order)" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
+               <button @click.stop="triggerEditOrder" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
              </div>
              <p class="text-xs font-medium">{{ order.delivery_type === 'cargo' ? t("admin.fields.cargo") : t("admin.fields.pickup") }}</p>
           </div>
@@ -82,7 +82,7 @@
               <span class="text-[9px] font-bold uppercase text-primary/60 tracking-widest">{{ t("admin.fields.material") }} & {{ t("admin.fields.colors") }}</span>
               <p class="text-sm font-bold">{{ order.material_name || '???' }} — {{ order.color_name || '???' }}</p>
             </div>
-            <button @click.stop="() => { $emit('edit-order', order); window.dispatchEvent(new CustomEvent('admin-edit-order', { detail: order })); }" class="bg-primary text-primary-foreground p-3 rounded-xl shadow-lg hover:scale-105 transition-transform" style="position: relative; z-index: 100;">
+            <button @click.stop="triggerEditOrder" class="bg-primary text-primary-foreground p-3 rounded-xl shadow-lg hover:scale-105 transition-transform" style="position: relative; z-index: 100;">
               <Edit2 class="w-5 h-5" />
             </button>
           </div>
@@ -97,7 +97,7 @@
           <div v-if="order.notes" class="mt-8 p-4 bg-primary/5 border border-primary/10 rounded-2xl italic">
             <div class="flex items-center justify-between mb-2">
               <span class="text-[9px] font-bold uppercase text-primary/60 tracking-widest">{{ t("admin.fields.projectNotes") }}</span>
-              <button @click.stop="$emit('edit-order', order)" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
+              <button @click.stop="triggerEditOrder" class="p-1 text-primary hover:bg-primary/5 rounded"><Edit2 class="w-2.5 h-2.5" /></button>
             </div>
             <p class="text-[11px] leading-relaxed">"{{ order.notes }}"</p>
           </div>
@@ -313,4 +313,9 @@ const statusIcon = props.statusConfig[props.order.status]?.icon || Clock;
 const formatDate = (date: string) => {
   return new Date(date).toLocaleDateString();
 };
+
+const triggerEditOrder = () => {
+  emit('edit-order', props.order);
+  window.dispatchEvent(new CustomEvent('admin-edit-order', { detail: props.order }));
+};
 </script>