From 33e9bf3019e029ff95b4493de5a90aabab53d0f7 Mon Sep 17 00:00:00 2001 From: DaX Date: Fri, 11 Jul 2025 11:27:21 +0200 Subject: [PATCH] Add PLA Translucent colors and restrict finish options by filament type - Added Light Jade (#A4D6AD) and Cherry Pink (#E9B6CC) PLA Translucent colors - Implement dynamic finish options based on selected filament type - ABS now only shows GF and Bez Finisha options - Each filament type has appropriate finish options - Auto-reset finish when changing type if incompatible --- app/upadaj/dashboard/page.tsx | 45 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/app/upadaj/dashboard/page.tsx b/app/upadaj/dashboard/page.tsx index 56012ae..15fcd41 100644 --- a/app/upadaj/dashboard/page.tsx +++ b/app/upadaj/dashboard/page.tsx @@ -51,6 +51,19 @@ interface FilamentWithId extends Filament { boja_hex?: string; } +// Finish options by filament type +const FINISH_OPTIONS_BY_TYPE: Record = { + 'ABS': ['GF', 'Bez Finisha'], + 'PLA': ['85A', '90A', '95A HF', 'Aero', 'Basic', 'Basic Gradient', 'CF', 'FR', 'Galaxy', 'GF', 'Glow', 'HF', 'Marble', 'Matte', 'Metal', 'Silk Multi-Color', 'Silk+', 'Sparkle', 'Translucent', 'Wood'], + 'TPU': ['85A', '90A', '95A HF'], + 'PETG': ['Basic', 'CF', 'FR', 'HF', 'Translucent'], + 'PC': ['CF', 'Bez Finisha'], + 'ASA': ['Bez Finisha'], + 'PA': ['CF', 'GF', 'Bez Finisha'], + 'PVA': ['Bez Finisha'], + 'HIPS': ['Bez Finisha'] +}; + export default function AdminDashboard() { const router = useRouter(); const [filaments, setFilaments] = useState([]); @@ -705,6 +718,15 @@ function FilamentForm({ ...formData, [name]: numValue }); + } else if (name === 'tip') { + // If changing filament type, reset finish if it's not compatible + const newTypeFinishes = FINISH_OPTIONS_BY_TYPE[value] || []; + const resetFinish = !newTypeFinishes.includes(formData.finish); + setFormData({ + ...formData, + [name]: value, + ...(resetFinish ? { finish: '' } : {}) + }); } else if (name === 'boja') { // If changing to a refill-only color, reset spulna to 0 const refillOnly = isRefillOnly(value, formData.finish); @@ -814,26 +836,9 @@ function FilamentForm({ className="custom-select w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500" > - - - - - - - - - - - - - - - - - - - - + {(FINISH_OPTIONS_BY_TYPE[formData.tip] || []).map(finish => ( + + ))}