more specific price seach should be working

This commit is contained in:
2018-08-14 23:36:09 -05:00
parent 4757abfff3
commit 5423b81c95
9 changed files with 157 additions and 17 deletions

View File

@@ -1,5 +1,7 @@
import { WebviewTag } from 'electron';
import * as _ from 'lodash';
import React from 'react';
import { ItemTextService } from '../services';
import { PoeService } from '../services/poe.service';
import { LoginWebview } from './login-webview';
import { PriceListItem } from './price-list-item/price-list-item';
@@ -44,9 +46,13 @@ export class Home extends React.Component<any, IState> {
if (json === null || json['error']) {
this.setState({ showLogin: true });
} else if (json.items) {
this.setState({ showLogin: false, data: json.items });
this.getItemPrice(json.items, 0);
console.log(json.items);
const items = _.map(json.items, item => {
item.fullText = ItemTextService.parseItem(item);
return item;
});
this.setState({ showLogin: false, data: items });
this.getItemPrice(items, 0);
}
}
@@ -60,8 +66,10 @@ export class Home extends React.Component<any, IState> {
return;
}
const res = await PoeService.priceCheck(data[index].typeLine);
if (res.currency_rec && res.min_price) {
console.log(data[index]);
console.log(data[index].fullText + '\n\n\n');
const res = await PoeService.priceCheck(data[index].fullText);
if ((res.min && res.currency) || (res.currency_rec && res.min_price)) {
const dataCopy: any = [...data];
dataCopy[index].priceInfo = res;
await new Promise(resolve => this.setState({ data: dataCopy }, resolve));
@@ -79,6 +87,10 @@ export class Home extends React.Component<any, IState> {
public render() {
const { data, showLogin } = this.state;
const url =
'https://www.pathofexile.com/character-window/get-stash-items' +
'?league=Incursion&tabs=1&tabIndex=0&accountName=DoctorCoctor';
return (
<div style={{ padding: '20px' }}>
{showLogin && <LoginWebview onSuccess={this.onLogin} />}
@@ -88,7 +100,7 @@ export class Home extends React.Component<any, IState> {
ref="webview"
partition="persist:poe"
preload="ipc-renderer.js"
src="https://www.pathofexile.com/character-window/get-stash-items?league=Incursion&tabs=1&tabIndex=13&accountName=DoctorCoctor"
src={url}
style={{ opacity: 0, width: '0', height: '0' }}
/>
</div>

View File

@@ -30,7 +30,7 @@ export class LoginWebview extends React.Component<IProps, any> {
ref="webview"
partition="persist:poe"
src="https://www.pathofexile.com/login"
style={{ height: '100%', width: '100%' }}
style={{ height: '500px', width: '100%' }}
/>
);
}

View File

@@ -18,17 +18,20 @@ export class PriceListItem extends React.Component<IProps, IState> {
componentDidMount() {}
render() {
const { data } = this.props;
const { fullText, icon, priceInfo, typeLine } = this.props.data;
return (
<div className="pli">
<div className="pli" title={fullText}>
<div style={{ width: '100px' }}>
<img src={data.icon} className="pli__img" />
<img src={icon} className="pli__img" />
</div>
<div style={{ flex: 1 }}>
<div style={{ marginBottom: '10px' }}>
<b>{data.typeLine}</b>
<b>{typeLine}</b>
</div>
<div>
{priceInfo ? `${priceInfo.min || priceInfo.min_price} ${priceInfo.currency || priceInfo.currency_rec}` : ''}
</div>
<div>{data.priceInfo ? `${data.priceInfo.min_price} ${data.priceInfo.currency_rec}` : ''}</div>
</div>
</div>
);