Add order mongoose schema

This commit is contained in:
Rene Vergara 2021-10-25 12:49:50 -05:00
parent cd1a0208df
commit eea8e06d48
4 changed files with 30 additions and 1 deletions

12
backend/models/order.js Normal file
View file

@ -0,0 +1,12 @@
const mongoose = require('mongoose');
const orderSchema = mongoose.Schema({
address: {type: String, required: true},
timestamp: {type: Date, required: true, default: Date.now},
closed: { type: Boolean, required: true, default:false },
lines: [{
qty: {type: Number, required: true, default: 1},
item: { type: String, required: true},
cost: { type: Number, required: true, default: 0}
}]
});

View file

@ -8,7 +8,7 @@
<td>{{item.name}}</td> <td>{{item.name}}</td>
<td align="right"> <td align="right">
<p class="price">{{item.cost | currency: 'USD'}}</p> <p class="price">{{item.cost | currency: 'USD'}}</p>
<p class="price"><img class="icon" src="/assets/zec.png" width="12px" />{{priceUpdate | async}}</p> <p class="price"><img class="icon" src="/assets/zec.png" width="12px" />{{(item.cost/price) | number: '1.0-6'}}</p>
</td> </td>
</tr> </tr>
</table> </table>

View file

@ -18,6 +18,7 @@ import { ItemCreateComponent } from '../item-create/item-create.component';
export class ItemListComponent implements OnInit{ export class ItemListComponent implements OnInit{
public items: Item[] = []; public items: Item[] = [];
private owner: Owner = {_id: '', name: '', address: ''}; private owner: Owner = {_id: '', name: '', address: ''};
public price: number = 1;
public ownerUpdate: Observable<Owner>; public ownerUpdate: Observable<Owner>;
public itemsUpdate: Observable<Item[]>; public itemsUpdate: Observable<Item[]>;
public priceUpdate: Observable<number>; public priceUpdate: Observable<number>;
@ -38,6 +39,9 @@ export class ItemListComponent implements OnInit{
this.items = items; this.items = items;
}); });
}); });
this.priceUpdate.subscribe((price) => {
this.price = price;
});
} }
ngOnInit(){ ngOnInit(){

View file

@ -0,0 +1,13 @@
import { Injectable } from '@angular/core';
import { Subject, BehaviorSubject, Observable } from 'rxjs';
import { HttpClient, HttpParams } from '@angular/common/http';
@Injectable({providedIn: 'root'})
export class OrderService {
//TODO implement the Order interface
private dataStore: { order: string } = { order: ''};
constructor(private http: HttpClient) {
}
}