diff --git a/backend/app.js b/backend/app.js index b374f9f..7ada4dd 100644 --- a/backend/app.js +++ b/backend/app.js @@ -127,7 +127,7 @@ var blockInterval = setInterval( function() { if (txData.confirmations >= 6 ) { usermodel.findOne({address: address, session: session, blocktime: blocktime}).then(function(doc){ if (doc == null){ - console.log('User not found', session, blocktime, amount); + console.log('User not found', session, blocktime); const n = crypto.randomInt(0, 10000000); const pin = n.toString().padStart(6, '0'); sendPin(pin, address); @@ -333,6 +333,7 @@ app.get('/api/getowner', (req, res, next) => { }); app.post('/api/addowner', (req, res, next) => { + // TODO: confirm passing owner works console.log('Post: /api/addowner'); const owner = new ownermodel(req.body); owner.save(); diff --git a/backend/models/owner.js b/backend/models/owner.js index 0eae770..b718a7e 100644 --- a/backend/models/owner.js +++ b/backend/models/owner.js @@ -13,7 +13,8 @@ const ownerSchema = mongoose.Schema({ city: {type: String, required: true}, state: {type: String, required: true}, postal: {type: String, required: true}, - phone: {type: String, required: true} + phone: {type: String, required: true}, + paid: {type: Boolean, required: true, default: false} }); module.exports = mongoose.model('Owner', ownerSchema); diff --git a/src/app/fullnode.service.ts b/src/app/fullnode.service.ts index 602068a..4f7d444 100644 --- a/src/app/fullnode.service.ts +++ b/src/app/fullnode.service.ts @@ -30,7 +30,15 @@ export class FullnodeService{ tax: false, taxValue: 0, vat: false, - vatValue: 0 + vatValue: 0, + email: '', + street: '', + city: '', + state: '', + postal: '', + phone: '', + paid: false + }; constructor(private http: HttpClient, public userService: UserService){ diff --git a/src/app/header/header.component.ts b/src/app/header/header.component.ts index 925fec6..9ea7929 100644 --- a/src/app/header/header.component.ts +++ b/src/app/header/header.component.ts @@ -23,7 +23,15 @@ export class HeaderComponent implements OnInit, OnDestroy { tax: false, taxValue: 0, vat: false, - vatValue: 0 + vatValue: 0, + email: '', + street: '', + city: '', + state: '', + postal: '', + phone: '', + paid: false + }; private session: string | null = ''; public heightUpdate: Observable; diff --git a/src/app/items/item-list/item-list.component.ts b/src/app/items/item-list/item-list.component.ts index a7f93ea..55126ad 100644 --- a/src/app/items/item-list/item-list.component.ts +++ b/src/app/items/item-list/item-list.component.ts @@ -28,7 +28,15 @@ export class ItemListComponent implements OnInit{ tax: false, taxValue: 0, vat: false, - vatValue: 0 + vatValue: 0, + email: '', + street: '', + city: '', + state: '', + postal: '', + phone: '', + paid: false + }; public price: number = 1; public ownerUpdate: Observable; diff --git a/src/app/login/login.component.ts b/src/app/login/login.component.ts index 2f5ca56..d8b0217 100644 --- a/src/app/login/login.component.ts +++ b/src/app/login/login.component.ts @@ -9,6 +9,7 @@ import { FullnodeService } from '../fullnode.service'; import { ScanComponent} from '../scan/scan.component'; import { Tx } from '../tx.model'; import {User} from '../user.model'; +import { Owner } from '../owner.model'; import { Subscription, Observable } from 'rxjs'; import { take } from 'rxjs/operators'; import { v4 as uuidv4 } from 'uuid'; @@ -38,11 +39,28 @@ export class LoginComponent implements OnInit, AfterViewInit { pin: '', validated: false }; + public owner:Owner = { + address: '', + name: '', + currency: '', + tax: false, + taxValue:0, + vat: false, + vatValue: 0, + email: '', + street: '', + city: '', + state: '', + postal: '', + phone: '', + paid: false + }; private FullnodeSub: Subscription = new Subscription(); private UserSub: Subscription = new Subscription(); public heightUpdate: Observable; public uZaddrUpdate: Observable; public userUpdate:Observable; + public ownerUpdate:Observable; public txsUpdate: Observable; tickets = [ { @@ -87,9 +105,13 @@ export class LoginComponent implements OnInit, AfterViewInit { this.heightUpdate = fullnodeService.heightUpdate; this.uZaddrUpdate = userService.uZaddrUpdate; this.userUpdate = userService.userUpdate; + this.ownerUpdate = userService.ownerUpdate; this.userUpdate.subscribe((user) => { this.user = user; }); + this.ownerUpdate.subscribe((owner) => { + this.owner = owner; + }); this.txsUpdate = userService.txUpdate; this.txsUpdate.subscribe((txs) => { this.txs = txs; diff --git a/src/app/order/order.service.ts b/src/app/order/order.service.ts index 18072cd..25b0fd6 100644 --- a/src/app/order/order.service.ts +++ b/src/app/order/order.service.ts @@ -30,7 +30,14 @@ export class OrderService { tax: false, taxValue: 0, vat: false, - vatValue: 0 + vatValue: 0, + email: '', + street: '', + city: '', + state: '', + postal: '', + phone: '', + paid: false }, order: { address: '', diff --git a/src/app/owner.model.ts b/src/app/owner.model.ts index ad4c0ed..2ecca3b 100644 --- a/src/app/owner.model.ts +++ b/src/app/owner.model.ts @@ -13,4 +13,5 @@ export interface Owner { state: string; postal: string; phone: string; + paid: boolean; } diff --git a/src/app/user.service.ts b/src/app/user.service.ts index 55c0cd4..1ffb051 100644 --- a/src/app/user.service.ts +++ b/src/app/user.service.ts @@ -25,7 +25,15 @@ export class UserService{ tax: false, taxValue: 0, vat: false, - vatValue: 0 + vatValue: 0, + email: '', + street: '', + city: '', + state: '', + postal: '', + phone: '', + paid: false + }, txs : [] }; @@ -38,10 +46,12 @@ export class UserService{ private uNameUpdated = new Subject(); private _ownerUpdated: BehaviorSubject = new BehaviorSubject(this.dataStore.owner); private _txsUpdated: BehaviorSubject = new BehaviorSubject(this.dataStore.txs); + private _paidUpdated: BehaviorSubject = new BehaviorSubject(this.dataStore.owner.paid); public readonly uZaddrUpdate: Observable = this._uZaddrUpdated.asObservable(); public readonly ownerUpdate: Observable = this._ownerUpdated.asObservable(); public readonly userUpdate: Observable = this._userUpdated.asObservable(); public readonly txUpdate: Observable = this._txsUpdated.asObservable(); + public readonly paidUpdate: Observable = this._paidUpdated.asObservable(); private reqHeaders: HttpHeaders; private apiKey = 'Le2adeic8Thah4Aeng4daem6i'; @@ -116,18 +126,8 @@ export class UserService{ }); } - addOwner(address: string) { - const owner: Owner={ - _id: '', - address: address, - name: 'Zgo-'.concat(address.substring(0,5)), - currency: 'usd', - tax: false, - taxValue: 0, - vat: false, - vatValue: 0 - }; - let obs = this.http.post<{message: string}>(this.beUrl+'api/addowner', {address: owner.address, name: owner.name}, {headers: this.reqHeaders}); + addOwner(owner: Owner) { + let obs = this.http.post<{message: string}>(this.beUrl+'api/addowner', {owner: owner}, {headers: this.reqHeaders}); obs.subscribe((responseData) => { console.log(responseData.message); @@ -157,9 +157,7 @@ export class UserService{ this.dataStore.owner = OwnerDataResponse.body!.owner[0]; //console.log('getOwner object', this.dataStore.owner); this._ownerUpdated.next(Object.assign({},this.dataStore).owner); - } else { - console.log("No owner found, adding"); - this.addOwner(address); + this._paidUpdated.next(Object.assign({}, this.dataStore).owner.paid); } }); diff --git a/src/app/viewer/viewer.component.ts b/src/app/viewer/viewer.component.ts index 00694d1..0066b45 100644 --- a/src/app/viewer/viewer.component.ts +++ b/src/app/viewer/viewer.component.ts @@ -36,7 +36,14 @@ export class ViewerComponent implements OnInit { tax: false, taxValue: 0, vat: false, - vatValue: 0 + vatValue: 0, + email: '', + street: '', + city: '', + state: '', + postal: '', + phone: '', + paid: false }; public addrUpdate: Observable; public ownerUpdate: Observable;