redirect to customer list after creating a new customer, not edit page
This commit is contained in:
+17
-19
@@ -30,26 +30,24 @@ router.post('/new', (req, res) => {
|
|||||||
const name = (b.name || '').trim();
|
const name = (b.name || '').trim();
|
||||||
if (!name) return res.status(400).send('Name is required');
|
if (!name) return res.status(400).send('Name is required');
|
||||||
|
|
||||||
const info = db
|
db.prepare(
|
||||||
.prepare(
|
`INSERT INTO customers
|
||||||
`INSERT INTO customers
|
(name, phone, alt_phone, email, address_line1, address_line2, city, state, zip, internal_note)
|
||||||
(name, phone, alt_phone, email, address_line1, address_line2, city, state, zip, internal_note)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
|
).run(
|
||||||
)
|
name,
|
||||||
.run(
|
formatPhone(b.phone),
|
||||||
name,
|
formatPhone(b.alt_phone),
|
||||||
formatPhone(b.phone),
|
b.email || null,
|
||||||
formatPhone(b.alt_phone),
|
b.address_line1 || null,
|
||||||
b.email || null,
|
b.address_line2 || null,
|
||||||
b.address_line1 || null,
|
b.city || null,
|
||||||
b.address_line2 || null,
|
b.state || null,
|
||||||
b.city || null,
|
b.zip || null,
|
||||||
b.state || null,
|
b.internal_note || null
|
||||||
b.zip || null,
|
);
|
||||||
b.internal_note || null
|
|
||||||
);
|
|
||||||
|
|
||||||
res.redirect(303, `/customers/${info.lastInsertRowid}/edit`);
|
res.redirect(303, '/customers');
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/:id/edit', (req, res) => {
|
router.get('/:id/edit', (req, res) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user