Remove refresh icon and fix Safari/WebKit runtime errors
- Removed manual refresh button from frontend (kept auto-refresh functionality) - Fixed WebKit 'object cannot be found' error by replacing absolute positioning with flexbox - Added lazy loading to images to prevent preload warnings - Cleaned up unused imports and variables: - Removed unused useRef import - Removed unused colors state variable and colorService - Removed unused ColorSwatch import from FilamentTableV2 - Removed unused getModifierIcon function from MaterialBadge - Updated tests to match current implementation - Improved layout stability for better cross-browser compatibility - Removed temporary migration scripts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import { Filament } from '@/src/types/filament';
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000/api';
|
||||
|
||||
@@ -23,16 +24,15 @@ api.interceptors.request.use((config) => {
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error) => {
|
||||
// Only redirect to login for protected routes
|
||||
const protectedPaths = ['/colors', '/filaments'];
|
||||
const isProtectedRoute = protectedPaths.some(path =>
|
||||
error.config?.url?.includes(path) && error.config?.method !== 'get'
|
||||
);
|
||||
|
||||
if ((error.response?.status === 401 || error.response?.status === 403) && isProtectedRoute) {
|
||||
if (error.response?.status === 401 || error.response?.status === 403) {
|
||||
// Clear auth data
|
||||
localStorage.removeItem('authToken');
|
||||
localStorage.removeItem('tokenExpiry');
|
||||
window.location.href = '/upadaj';
|
||||
|
||||
// Only redirect if we're in a protected admin route
|
||||
if (window.location.pathname.includes('/upadaj/')) {
|
||||
window.location.href = '/upadaj';
|
||||
}
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
@@ -51,12 +51,12 @@ export const colorService = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
create: async (color: { name: string; hex: string }) => {
|
||||
create: async (color: { name: string; hex: string; cena_refill?: number; cena_spulna?: number }) => {
|
||||
const response = await api.post('/colors', color);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update: async (id: string, color: { name: string; hex: string }) => {
|
||||
update: async (id: string, color: { name: string; hex: string; cena_refill?: number; cena_spulna?: number }) => {
|
||||
const response = await api.put(`/colors/${id}`, color);
|
||||
return response.data;
|
||||
},
|
||||
@@ -70,32 +70,16 @@ export const colorService = {
|
||||
export const filamentService = {
|
||||
getAll: async () => {
|
||||
const response = await api.get('/filaments');
|
||||
// Transform boja_hex to bojaHex for frontend compatibility
|
||||
return response.data.map((f: any) => ({
|
||||
...f,
|
||||
bojaHex: f.boja_hex || f.bojaHex
|
||||
}));
|
||||
},
|
||||
|
||||
create: async (filament: any) => {
|
||||
// Transform bojaHex to boja_hex for backend
|
||||
const data = {
|
||||
...filament,
|
||||
boja_hex: filament.bojaHex || filament.boja_hex
|
||||
};
|
||||
delete data.bojaHex; // Remove the frontend field
|
||||
const response = await api.post('/filaments', data);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update: async (id: string, filament: any) => {
|
||||
// Transform bojaHex to boja_hex for backend
|
||||
const data = {
|
||||
...filament,
|
||||
boja_hex: filament.bojaHex || filament.boja_hex
|
||||
};
|
||||
delete data.bojaHex; // Remove the frontend field
|
||||
const response = await api.put(`/filaments/${id}`, data);
|
||||
create: async (filament: Partial<Filament>) => {
|
||||
const response = await api.post('/filaments', filament);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
update: async (id: string, filament: Partial<Filament>) => {
|
||||
const response = await api.put(`/filaments/${id}`, filament);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user