feat: Implement tabbed settings dashboard (System Settings and Mail Settings)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
// API routes handler
|
// API routes handler
|
||||||
import realtime from './realtime';
|
import realtime from './realtime';
|
||||||
|
import settingsApi from './settings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple API router for client-side application
|
* Simple API router for client-side application
|
||||||
@@ -16,6 +17,9 @@ const api = {
|
|||||||
if (path === '/api/realtime') {
|
if (path === '/api/realtime') {
|
||||||
console.log("Routing to realtime handler");
|
console.log("Routing to realtime handler");
|
||||||
return await realtime(body);
|
return await realtime(body);
|
||||||
|
} else if (path === '/api/settings') {
|
||||||
|
console.log("Routing to settings handler");
|
||||||
|
return await settingsApi(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return 404 for unknown routes
|
// Return 404 for unknown routes
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
|
||||||
|
import { settingsService } from "@/services/settingsService";
|
||||||
|
|
||||||
|
const settingsApi = async (body: any) => {
|
||||||
|
try {
|
||||||
|
const { action, data } = body;
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case 'getSettings':
|
||||||
|
const settings = await settingsService.getGeneralSettings();
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
json: {
|
||||||
|
success: true,
|
||||||
|
data: settings
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
case 'updateSettings':
|
||||||
|
if (!data.id) {
|
||||||
|
return {
|
||||||
|
status: 400,
|
||||||
|
json: {
|
||||||
|
success: false,
|
||||||
|
message: 'Settings ID is required'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const updatedSettings = await settingsService.updateGeneralSettings(data.id, data);
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
json: {
|
||||||
|
success: true,
|
||||||
|
data: updatedSettings
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
case 'testEmailConnection':
|
||||||
|
// This would typically connect to the SMTP server to test the connection
|
||||||
|
// For now, we'll just simulate a successful connection
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
json: {
|
||||||
|
success: true,
|
||||||
|
message: 'Connection successful'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
default:
|
||||||
|
return {
|
||||||
|
status: 400,
|
||||||
|
json: {
|
||||||
|
success: false,
|
||||||
|
message: 'Invalid action'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error in settings API:', error);
|
||||||
|
return {
|
||||||
|
status: 500,
|
||||||
|
json: {
|
||||||
|
success: false,
|
||||||
|
message: 'Internal server error'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default settingsApi;
|
||||||
Reference in New Issue
Block a user