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:
65
api/scripts/add-basic-refills.js
Normal file
65
api/scripts/add-basic-refills.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const { Pool } = require('pg');
|
||||
require('dotenv').config();
|
||||
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
ssl: process.env.DATABASE_URL?.includes('amazonaws.com') ? { rejectUnauthorized: false } : false
|
||||
});
|
||||
|
||||
async function addBasicRefills() {
|
||||
try {
|
||||
// First, let's insert filaments for all existing colors
|
||||
const result = await pool.query(`
|
||||
INSERT INTO filaments (tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena)
|
||||
SELECT
|
||||
'PLA' as tip,
|
||||
'Basic' as finish,
|
||||
c.name as boja,
|
||||
c.hex as boja_hex,
|
||||
'1' as refill,
|
||||
'0 vakuum' as vakum,
|
||||
'0 otvorena' as otvoreno,
|
||||
1 as kolicina,
|
||||
'3999' as cena
|
||||
FROM colors c
|
||||
WHERE NOT EXISTS (
|
||||
-- Only insert if this exact combination doesn't already exist
|
||||
SELECT 1 FROM filaments f
|
||||
WHERE f.tip = 'PLA'
|
||||
AND f.finish = 'Basic'
|
||||
AND f.boja = c.name
|
||||
)
|
||||
`);
|
||||
|
||||
console.log(`Inserted ${result.rowCount} new PLA Basic filaments with 1 refill each`);
|
||||
|
||||
// Update any existing PLA Basic filaments to have at least 1 refill
|
||||
const updateResult = await pool.query(`
|
||||
UPDATE filaments
|
||||
SET refill = '1'
|
||||
WHERE tip = 'PLA'
|
||||
AND finish = 'Basic'
|
||||
AND (refill IS NULL OR refill = '0' OR refill = '')
|
||||
`);
|
||||
|
||||
console.log(`Updated ${updateResult.rowCount} existing PLA Basic filaments to have 1 refill`);
|
||||
|
||||
// Show summary
|
||||
const summary = await pool.query(`
|
||||
SELECT COUNT(*) as count
|
||||
FROM filaments
|
||||
WHERE tip = 'PLA'
|
||||
AND finish = 'Basic'
|
||||
AND refill = '1'
|
||||
`);
|
||||
|
||||
console.log(`\nTotal PLA Basic filaments with 1 refill: ${summary.rows[0].count}`);
|
||||
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('Error adding basic refills:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
addBasicRefills();
|
||||
73
api/scripts/add-refills.js
Normal file
73
api/scripts/add-refills.js
Normal file
@@ -0,0 +1,73 @@
|
||||
const { Pool } = require('pg');
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.join(__dirname, '../.env') });
|
||||
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
ssl: process.env.DATABASE_URL?.includes('amazonaws.com') ? { rejectUnauthorized: false } : false
|
||||
});
|
||||
|
||||
async function addRefills() {
|
||||
try {
|
||||
console.log('Adding 1 refill for each color as PLA Basic filaments...\n');
|
||||
|
||||
// First, get all colors
|
||||
const colorsResult = await pool.query('SELECT name, hex FROM colors ORDER BY name');
|
||||
console.log(`Found ${colorsResult.rows.length} colors in database:`);
|
||||
colorsResult.rows.forEach(color => {
|
||||
console.log(` - ${color.name} (${color.hex})`);
|
||||
});
|
||||
console.log('');
|
||||
|
||||
let inserted = 0;
|
||||
let updated = 0;
|
||||
|
||||
for (const color of colorsResult.rows) {
|
||||
// Check if PLA Basic already exists for this color
|
||||
const existing = await pool.query(
|
||||
'SELECT id, refill FROM filaments WHERE tip = $1 AND finish = $2 AND boja = $3',
|
||||
['PLA', 'Basic', color.name]
|
||||
);
|
||||
|
||||
if (existing.rows.length === 0) {
|
||||
// Insert new filament
|
||||
await pool.query(
|
||||
`INSERT INTO filaments (tip, finish, boja, boja_hex, refill, vakum, otvoreno, kolicina, cena)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
|
||||
['PLA', 'Basic', color.name, color.hex, '1', '0 vakuum', '0 otvorena', 1, '3999']
|
||||
);
|
||||
console.log(`✓ Added PLA Basic ${color.name}`);
|
||||
inserted++;
|
||||
} else if (!existing.rows[0].refill || existing.rows[0].refill === '0') {
|
||||
// Update existing to have 1 refill
|
||||
await pool.query(
|
||||
'UPDATE filaments SET refill = $1 WHERE id = $2',
|
||||
['1', existing.rows[0].id]
|
||||
);
|
||||
console.log(`✓ Updated PLA Basic ${color.name} to have 1 refill`);
|
||||
updated++;
|
||||
} else {
|
||||
console.log(`- PLA Basic ${color.name} already has ${existing.rows[0].refill} refill(s)`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\nSummary:`);
|
||||
console.log(`- Inserted ${inserted} new PLA Basic filaments`);
|
||||
console.log(`- Updated ${updated} existing filaments to have 1 refill`);
|
||||
console.log(`- Total colors processed: ${colorsResult.rows.length}`);
|
||||
|
||||
// Show final state
|
||||
const finalCount = await pool.query(
|
||||
"SELECT COUNT(*) as count FROM filaments WHERE tip = 'PLA' AND finish = 'Basic' AND refill = '1'"
|
||||
);
|
||||
console.log(`- Total PLA Basic filaments with 1 refill: ${finalCount.rows[0].count}`);
|
||||
|
||||
await pool.end();
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
addRefills();
|
||||
Reference in New Issue
Block a user