Fix color synchronization between admin panel and frontend
Fixed field name mismatch causing colors to display incorrectly: - Frontend uses 'bojaHex' while backend expects 'boja_hex' - Added bidirectional field transformation in API service layer - Ensures hex color codes are properly saved and retrieved - Also prevents editing of Bambu Lab predefined color hex codes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -70,16 +70,32 @@ export const colorService = {
|
||||
export const filamentService = {
|
||||
getAll: async () => {
|
||||
const response = await api.get('/filaments');
|
||||
return response.data;
|
||||
// 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) => {
|
||||
const response = await api.post('/filaments', filament);
|
||||
// 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) => {
|
||||
const response = await api.put(`/filaments/${id}`, filament);
|
||||
// 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);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user