Skip to content

Commit

Permalink
Fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-north committed Feb 5, 2018
1 parent 062dabe commit e14e191
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/db/sqlite-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class SQLiteDB extends SQLDatabase<sqlite.Statement> {
return setupPreparedStatements<
sqlite.Statement,
SQLDatabase<sqlite.Statement>
>(db);
>(db);
})
.then(statements => {
db.statements = statements;
Expand All @@ -67,7 +67,6 @@ export default class SQLiteDB extends SQLDatabase<sqlite.Statement> {
});
return dbPromises[name];
}
private filePath: string;
private db: sqlite.Database;
protected constructor(db: sqlite.Database) {
super();
Expand Down
18 changes: 9 additions & 9 deletions src/routers/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ function normalizeOrderDetails(raw: { [k: string]: any[] }): Array<Partial<Order
details.push(o as any);
}
return details.map(d => {
let [id, price] = d.ProductId.split(';');
let discount = parseFloat(d.Discount as string);
let [id, price] = d.productid.split(';');
let discount = parseFloat(d.discount as string);
return {
Id: d.Id,
ProductId: parseInt(id, 10),
UnitPrice: parseFloat(price) * (1 - discount),
Quantity: parseInt(d.Quantity as string, 10),
Discount: discount,
id: d.id,
productid: parseInt(id, 10),
unitprice: parseFloat(price) * (1 - discount),
quantity: parseInt(d.quantity as string, 10),
discount: discount,
};
});
}
Expand Down Expand Up @@ -92,7 +92,7 @@ router.post('/', ORDER_VALIDATIONS, async (req: Request, res: Response) => {
let details: Array<Partial<OrderDetail>> = normalizeOrderDetails(detailsObj);
try {
let order = await createOrder(orderData, details);
res.redirect(`orders/${order.Id}`);
res.redirect(`orders/${order.id}`);
} catch (e) {
res.status(500);
res.send(e.toString());
Expand All @@ -111,7 +111,7 @@ router.post('/:id', ORDER_VALIDATIONS, async (req: Request, res: Response) => {
let details: Array<Partial<OrderDetail>> = normalizeOrderDetails(detailsObj);
try {
let order = await updateOrder(req.params.id, orderData as any, details);
res.redirect(`/orders/${order.Id}`);
res.redirect(`/orders/${order.id}`);
} catch (e) {
res.status(500);
res.send(e.toString());
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"strict": true
},
"include": [
"src/**/*.ts"
"src"
]
}

0 comments on commit e14e191

Please sign in to comment.