Fix admin panel dropdown reset on window focus
This commit is contained in:
@@ -154,16 +154,6 @@ export default function AdminDashboard() {
|
||||
|
||||
useEffect(() => {
|
||||
fetchAllData();
|
||||
|
||||
// Refresh when window regains focus
|
||||
const handleFocus = () => {
|
||||
fetchAllData();
|
||||
};
|
||||
window.addEventListener('focus', handleFocus);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('focus', handleFocus);
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Sorting logic
|
||||
@@ -721,7 +711,21 @@ function FilamentForm({
|
||||
cena_refill: refillPrice || 3499,
|
||||
cena_spulna: spulnaPrice || 3999,
|
||||
});
|
||||
}, [filament, availableColors]);
|
||||
}, [filament]);
|
||||
|
||||
// Update prices when color selection changes
|
||||
useEffect(() => {
|
||||
if (formData.boja && availableColors.length > 0) {
|
||||
const colorData = availableColors.find(c => c.name === formData.boja);
|
||||
if (colorData) {
|
||||
setFormData(prev => ({
|
||||
...prev,
|
||||
cena_refill: colorData.cena_refill || prev.cena_refill,
|
||||
cena_spulna: colorData.cena_spulna || prev.cena_spulna,
|
||||
}));
|
||||
}
|
||||
}
|
||||
}, [formData.boja, availableColors.length]);
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>) => {
|
||||
const { name, value } = e.target;
|
||||
|
||||
Reference in New Issue
Block a user