6.0 KiB
Quick Fix: Settings Not Editable Issue
🔴 Problem
Settings showing as "not editable" in the frontend.
🎯 Root Cause
Field Mapping Issue: Database uses is_editable (snake_case) but frontend expects isEditable (camelCase).
✅ Solution Applied
1. Fixed Admin Controller ✅
Added field mapping from snake_case to camelCase:
// Re_Backend/src/controllers/admin.controller.ts
const configurations = rawConfigurations.map(config => ({
configId: config.config_id, // ✅ Mapped
isEditable: config.is_editable, // ✅ Mapped
isSensitive: config.is_sensitive, // ✅ Mapped
requiresRestart: config.requires_restart, // ✅ Mapped
// ... all other fields
}));
2. Database Fix Required
Option A: Delete and Re-seed (Recommended if no custom configs)
-- Connect to your database
DELETE FROM admin_configurations;
-- Restart backend - auto-seeding will run
-- Check logs for: "✅ Default configurations seeded (18 settings)"
Option B: Fix Existing Records (If you have custom values)
-- Update existing records to add missing fields
UPDATE admin_configurations
SET
is_sensitive = COALESCE(is_sensitive, false),
requires_restart = COALESCE(requires_restart, false),
is_editable = COALESCE(is_editable, true)
WHERE is_sensitive IS NULL
OR requires_restart IS NULL
OR is_editable IS NULL;
-- Set requires_restart = true for settings that need it
UPDATE admin_configurations
SET requires_restart = true
WHERE config_key IN (
'WORK_START_HOUR',
'WORK_END_HOUR',
'MAX_FILE_SIZE_MB',
'ALLOWED_FILE_TYPES'
);
🚀 Step-by-Step Fix
Step 1: Stop Backend
# Press Ctrl+C to stop the server
Step 2: Clear Configurations (if any exist)
-- Connect to PostgreSQL
psql -U postgres -d re_workflow
-- Check if configurations exist
SELECT COUNT(*) FROM admin_configurations;
-- If count > 0, delete them
DELETE FROM admin_configurations;
-- Verify
SELECT COUNT(*) FROM admin_configurations;
-- Should show: 0
Step 3: Restart Backend (Auto-seeds)
cd Re_Backend
npm run dev
Step 4: Verify Seeding in Logs
Look for:
⚙️ System configurations initialized
✅ Default configurations seeded successfully (18 settings across 7 categories)
Step 5: Test in Frontend
- Login as Admin user
- Go to Settings → System Configuration
- You should see 7 category tabs
- Click any tab (e.g., "TAT SETTINGS")
- All settings should now have:
- ✅ Editable input fields
- ✅ Save button enabled
- ✅ Reset to Default button
🧪 Verify Configuration Loaded Correctly
Test API Endpoint:
# Get all configurations
curl http://localhost:5000/api/v1/admin/configurations \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Expected Response:
{
"success": true,
"data": [
{
"configId": "uuid...",
"configKey": "DEFAULT_TAT_EXPRESS_HOURS",
"configCategory": "TAT_SETTINGS",
"configValue": "24",
"valueType": "NUMBER",
"displayName": "Default TAT for Express Priority",
"isEditable": true, // ✅ Should be true
"isSensitive": false,
"validationRules": {"min": 1, "max": 168},
"uiComponent": "number",
"sortOrder": 1,
"requiresRestart": false
},
// ... 17 more configurations
],
"count": 18
}
Check the isEditable field - should be true for all!
🐛 Common Issues & Solutions
Issue 1: "Configurations already exist. Skipping seed."
Cause: Old configurations in database
Fix: Delete them and restart backend
Issue 2: Settings show as gray/disabled
Cause: is_editable = false in database
Fix: Run SQL update to set all to true
Issue 3: "Configuration not found or not editable" error when saving
Cause: Backend can't find the config or is_editable = false
Fix: Verify database has correct values
Issue 4: Empty settings page
Cause: No configurations in database
Fix: Check backend logs for seeding errors, run seed manually
📊 Expected Database State
After successful seeding, your admin_configurations table should have:
| Count | Category | All Editable? |
|---|---|---|
| 6 | TAT_SETTINGS | ✅ Yes |
| 3 | DOCUMENT_POLICY | ✅ Yes |
| 2 | AI_CONFIGURATION | ✅ Yes |
| 3 | NOTIFICATION_RULES | ✅ Yes |
| 4 | DASHBOARD_LAYOUT | ✅ Yes |
| 3 | WORKFLOW_SHARING | ✅ Yes |
| 2 | WORKFLOW_LIMITS | ✅ Yes |
| 18 Total | 7 Categories | ✅ All Editable |
Query to verify:
SELECT
config_category,
COUNT(*) as total,
SUM(CASE WHEN is_editable = true THEN 1 ELSE 0 END) as editable_count
FROM admin_configurations
GROUP BY config_category
ORDER BY config_category;
Should show 100% editable in all categories!
✅ After Fix - Settings UI Will Show:
Settings → System Configuration
┌─────────────────────────────────────────┐
│ [TAT SETTINGS] [DOCUMENT POLICY] [...] │ ← 7 tabs
├─────────────────────────────────────────┤
│ │
│ ⏰ Default TAT for Express Priority │
│ (Description...) │
│ ┌──────┐ ← EDITABLE │
│ │ 24 │ │
│ └──────┘ │
│ [💾 Save] [🔄 Reset] ← ENABLED │
│ │
│ ⏰ First TAT Reminder (%) │
│ ━━━━●━━━━ 50% ← SLIDER WORKS │
│ [💾 Save] [🔄 Reset] │
│ │
└─────────────────────────────────────────┘
All inputs should be EDITABLE and Save buttons ENABLED! ✅