Enhance sticky columns in import, enhance forecasting page
This commit is contained in:
@@ -134,11 +134,10 @@ router.post('/', async (req, res) => {
|
||||
res.status(201).json(result.rows[0]);
|
||||
} catch (error) {
|
||||
console.error('Error creating template:', error);
|
||||
// Check for unique constraint violation
|
||||
if (error instanceof Error && error.message.includes('unique constraint')) {
|
||||
return res.status(409).json({
|
||||
error: 'Template already exists for this company and product type',
|
||||
details: error.message
|
||||
// Check for unique constraint violation (PostgreSQL error code 23505)
|
||||
if (error?.code === '23505') {
|
||||
return res.status(409).json({
|
||||
error: 'A template already exists for this company and product type combination. Please edit the existing template instead.',
|
||||
});
|
||||
}
|
||||
res.status(500).json({
|
||||
@@ -232,11 +231,10 @@ router.put('/:id', async (req, res) => {
|
||||
res.json(result.rows[0]);
|
||||
} catch (error) {
|
||||
console.error('Error updating template:', error);
|
||||
// Check for unique constraint violation
|
||||
if (error instanceof Error && error.message.includes('unique constraint')) {
|
||||
return res.status(409).json({
|
||||
error: 'Template already exists for this company and product type',
|
||||
details: error.message
|
||||
// Check for unique constraint violation (PostgreSQL error code 23505)
|
||||
if (error?.code === '23505') {
|
||||
return res.status(409).json({
|
||||
error: 'A template already exists for this company and product type combination. Please edit the existing template instead.',
|
||||
});
|
||||
}
|
||||
res.status(500).json({
|
||||
|
||||
Reference in New Issue
Block a user