-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.js
43 lines (40 loc) · 1.72 KB
/
setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const app = require('./app');
// Setup Route to render setup page
app.get('/setup', (req, res) => {
const domain = req.query.domain || '';
res.render('setup', { domain });
});
// app.get('/404', (req, res) => {
// //const domain = req.query.domain || '';
// res.render('404');
// });
app.get('/404', (req, res) => {
// Render the 404.ejs view
res.status(404).render('404');
});
// Setup POST Route to handle form submission
app.post('/setup', async (req, res) => {
const {
domain, location_id, v_location_id, logo_url, background, dark_back, side_dark_back, side_back,
grid_back, dark_grid_back, text_light, text_dark, icon_button_back, button_bottom_border,
company_name, company_address, heading_color
} = req.body;
try {
const insertQuery = `
INSERT INTO domain_config (
domain, location_id, v_location_id, logo_url, background, dark_back, side_dark_back, side_back,
grid_back, dark_grid_back, text_light, text_dark, icon_button_back, button_bottom_border,
company_name, company_address, heading_color
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`;
await pool.query(insertQuery, [
domain, location_id, v_location_id, logo_url, background, dark_back, side_dark_back, side_back,
grid_back, dark_grid_back, text_light, text_dark, icon_button_back, button_bottom_border,
company_name, company_address, heading_color
]);
res.redirect('/'); // Redirect to home or another appropriate page
} catch (error) {
console.error('Database error:', error);
res.status(500).send('Failed to save domain configuration.');
}
});