Add bulk price editing features and fix quantity update price preservation

- Fix FilamentForm to preserve prices when updating quantities
  - Add isInitialLoad flag to prevent price override on form load
  - Only update prices when color is actively changed, not on initial render

- Add bulk filament price editor to dashboard
  - Filter by material and finish
  - Set refill and/or spool prices for multiple filaments
  - Preview changes before applying
  - Update all filtered filaments at once

- Add bulk color price editor to colors page
  - Edit prices for all colors in one interface
  - Global price application with search filtering
  - Individual price editing with change tracking

- Add auto-kill script for dev server
  - Kill existing processes on ports 3000/3001 before starting
  - Prevent "port already in use" errors
  - Clean start every time npm run dev is executed
This commit is contained in:
DaX
2025-11-18 19:14:01 +01:00
parent b1dfa2352a
commit f6f9da9c5b
6 changed files with 703 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import { colorService } from '@/src/services/api';
import { bambuLabColors, getColorHex } from '@/src/data/bambuLabColorsComplete';
import { BulkPriceEditor } from '@/src/components/BulkPriceEditor';
import '@/src/styles/select.css';
interface Color {
@@ -221,7 +222,7 @@ export default function ColorsManagement() {
/>
<h1 className="text-3xl font-bold text-gray-900 dark:text-white">Upravljanje bojama</h1>
</div>
<div className="flex gap-4">
<div className="flex gap-4 flex-wrap">
{!showAddForm && !editingColor && (
<button
onClick={() => setShowAddForm(true)}
@@ -230,6 +231,7 @@ export default function ColorsManagement() {
Dodaj novu boju
</button>
)}
<BulkPriceEditor colors={colors} onUpdate={fetchColors} />
{selectedColors.size > 0 && (
<button
onClick={handleBulkDelete}