update: shop page

This commit is contained in:
Rifqy Zacky Ariadhy
2019-01-02 21:16:50 +07:00
parent 0794e91ad0
commit e503b70640
5 changed files with 387 additions and 302 deletions

View File

@@ -85,19 +85,19 @@ export default class All extends React.Component {
componentDidMount() {
// this.myStoreItem.isSearching = false;
if(this.userData.role == 'store') {
this.myStoreItem.getAll();
}
if(this.userData.role == 'administrator') {
this.myStoreItem.setRequestQuery({user_store_id : this.props.id});
console.log('ini id',this.props.id);
this.myStoreItem.getAll();
}
// if(this.userData.role == 'store') {
// this.myStoreItem.getAll();
// }
// if(this.userData.role == 'administrator') {
// this.myStoreItem.setRequestQuery({user_store_id : this.props.id});
// console.log('ini id',this.props.id);
// this.myStoreItem.getAll();
// }
}
componentWillUnmount(){
this.myStoreItem.isSearching = false;
this.myStoreItem.reset();
// this.myStoreItem.isSearching = false;
// this.myStoreItem.reset();
}
deleteClicked = (id) => {
@@ -145,7 +145,315 @@ export default class All extends React.Component {
render() {
console.log(this.myStoreItem.data.length);
const data = [
{
category_id: "1e444a5a-cf4d-48e5-bde4-0f984ebd557d",
created_at: "2019-01-02T04:00:08.803Z",
custom_fields: null,
deleted_at: null,
description: null,
height: "0.00",
id: "7e3072c1-9bfd-4b52-af38-9c6e30456c73",
images: {main: "https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png", gallery: ["https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png"]},
item_status_id: "2b1a2598-8333-4b19-ae7b-c054bec87540",
length: "0.00",
name: "Silly Oregano Seasoning",
odoo_additional_data: {product_id: 205, product_uom: 21, product_tmpl_id: 291},
product_id: 205,
product_tmpl_id: 291,
product_uom: 21,
odoo_stock_id: 123634,
order: 147291,
preorder: null,
regular_price: "10",
sale_date_from: null,
sale_date_to: null,
sale_price: null,
seen: 0,
sold: 0,
stock: "34.00",
uom: "pack",
updated_at: "2019-01-02T13:00:05.042Z",
use_weight_as_stock: false,
user_store_id: "959194a0-7067-400c-b354-2e8d03300660",
visible: true,
weight: "0.04",
width: "0.00",
wishlist: "0",
},{
category_id: "1e444a5a-cf4d-48e5-bde4-0f984ebd557d",
created_at: "2019-01-02T04:00:08.803Z",
custom_fields: null,
deleted_at: null,
description: null,
height: "0.00",
id: "7e3072c1-9bfd-4b52-af38-9c6e30456c73",
images: {main: "https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png", gallery: ["https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png"]},
item_status_id: "2b1a2598-8333-4b19-ae7b-c054bec87540",
length: "0.00",
name: "Silly Oregano Seasoning",
odoo_additional_data: {product_id: 205, product_uom: 21, product_tmpl_id: 291},
product_id: 205,
product_tmpl_id: 291,
product_uom: 21,
odoo_stock_id: 123634,
order: 147291,
preorder: null,
regular_price: "10",
sale_date_from: null,
sale_date_to: null,
sale_price: null,
seen: 0,
sold: 0,
stock: "34.00",
uom: "pack",
updated_at: "2019-01-02T13:00:05.042Z",
use_weight_as_stock: false,
user_store_id: "959194a0-7067-400c-b354-2e8d03300660",
visible: true,
weight: "0.04",
width: "0.00",
wishlist: "0",
},{
category_id: "1e444a5a-cf4d-48e5-bde4-0f984ebd557d",
created_at: "2019-01-02T04:00:08.803Z",
custom_fields: null,
deleted_at: null,
description: null,
height: "0.00",
id: "7e3072c1-9bfd-4b52-af38-9c6e30456c73",
images: {main: "https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png", gallery: ["https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png"]},
item_status_id: "2b1a2598-8333-4b19-ae7b-c054bec87540",
length: "0.00",
name: "Silly Oregano Seasoning",
odoo_additional_data: {product_id: 205, product_uom: 21, product_tmpl_id: 291},
product_id: 205,
product_tmpl_id: 291,
product_uom: 21,
odoo_stock_id: 123634,
order: 147291,
preorder: null,
regular_price: "10",
sale_date_from: null,
sale_date_to: null,
sale_price: null,
seen: 0,
sold: 0,
stock: "34.00",
uom: "pack",
updated_at: "2019-01-02T13:00:05.042Z",
use_weight_as_stock: false,
user_store_id: "959194a0-7067-400c-b354-2e8d03300660",
visible: true,
weight: "0.04",
width: "0.00",
wishlist: "0",
},{
category_id: "1e444a5a-cf4d-48e5-bde4-0f984ebd557d",
created_at: "2019-01-02T04:00:08.803Z",
custom_fields: null,
deleted_at: null,
description: null,
height: "0.00",
id: "7e3072c1-9bfd-4b52-af38-9c6e30456c73",
images: {main: "https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png", gallery: ["https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png"]},
item_status_id: "2b1a2598-8333-4b19-ae7b-c054bec87540",
length: "0.00",
name: "Silly Oregano Seasoning",
odoo_additional_data: {product_id: 205, product_uom: 21, product_tmpl_id: 291},
product_id: 205,
product_tmpl_id: 291,
product_uom: 21,
odoo_stock_id: 123634,
order: 147291,
preorder: null,
regular_price: "10",
sale_date_from: null,
sale_date_to: null,
sale_price: null,
seen: 0,
sold: 0,
stock: "34.00",
uom: "pack",
updated_at: "2019-01-02T13:00:05.042Z",
use_weight_as_stock: false,
user_store_id: "959194a0-7067-400c-b354-2e8d03300660",
visible: true,
weight: "0.04",
width: "0.00",
wishlist: "0",
},{
category_id: "1e444a5a-cf4d-48e5-bde4-0f984ebd557d",
created_at: "2019-01-02T04:00:08.803Z",
custom_fields: null,
deleted_at: null,
description: null,
height: "0.00",
id: "7e3072c1-9bfd-4b52-af38-9c6e30456c73",
images: {main: "https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png", gallery: ["https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png"]},
item_status_id: "2b1a2598-8333-4b19-ae7b-c054bec87540",
length: "0.00",
name: "Silly Oregano Seasoning",
odoo_additional_data: {product_id: 205, product_uom: 21, product_tmpl_id: 291},
product_id: 205,
product_tmpl_id: 291,
product_uom: 21,
odoo_stock_id: 123634,
order: 147291,
preorder: null,
regular_price: "10",
sale_date_from: null,
sale_date_to: null,
sale_price: null,
seen: 0,
sold: 0,
stock: "34.00",
uom: "pack",
updated_at: "2019-01-02T13:00:05.042Z",
use_weight_as_stock: false,
user_store_id: "959194a0-7067-400c-b354-2e8d03300660",
visible: true,
weight: "0.04",
width: "0.00",
wishlist: "0",
},{
category_id: "1e444a5a-cf4d-48e5-bde4-0f984ebd557d",
created_at: "2019-01-02T04:00:08.803Z",
custom_fields: null,
deleted_at: null,
description: null,
height: "0.00",
id: "7e3072c1-9bfd-4b52-af38-9c6e30456c73",
images: {main: "https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png", gallery: ["https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png"]},
item_status_id: "2b1a2598-8333-4b19-ae7b-c054bec87540",
length: "0.00",
name: "Silly Oregano Seasoning",
odoo_additional_data: {product_id: 205, product_uom: 21, product_tmpl_id: 291},
product_id: 205,
product_tmpl_id: 291,
product_uom: 21,
odoo_stock_id: 123634,
order: 147291,
preorder: null,
regular_price: "10",
sale_date_from: null,
sale_date_to: null,
sale_price: null,
seen: 0,
sold: 0,
stock: "34.00",
uom: "pack",
updated_at: "2019-01-02T13:00:05.042Z",
use_weight_as_stock: false,
user_store_id: "959194a0-7067-400c-b354-2e8d03300660",
visible: true,
weight: "0.04",
width: "0.00",
wishlist: "0",
},{
category_id: "1e444a5a-cf4d-48e5-bde4-0f984ebd557d",
created_at: "2019-01-02T04:00:08.803Z",
custom_fields: null,
deleted_at: null,
description: null,
height: "0.00",
id: "7e3072c1-9bfd-4b52-af38-9c6e30456c73",
images: {main: "https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png", gallery: ["https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png"]},
item_status_id: "2b1a2598-8333-4b19-ae7b-c054bec87540",
length: "0.00",
name: "Silly Oregano Seasoning",
odoo_additional_data: {product_id: 205, product_uom: 21, product_tmpl_id: 291},
product_id: 205,
product_tmpl_id: 291,
product_uom: 21,
odoo_stock_id: 123634,
order: 147291,
preorder: null,
regular_price: "10",
sale_date_from: null,
sale_date_to: null,
sale_price: null,
seen: 0,
sold: 0,
stock: "34.00",
uom: "pack",
updated_at: "2019-01-02T13:00:05.042Z",
use_weight_as_stock: false,
user_store_id: "959194a0-7067-400c-b354-2e8d03300660",
visible: true,
weight: "0.04",
width: "0.00",
wishlist: "0",
},{
category_id: "1e444a5a-cf4d-48e5-bde4-0f984ebd557d",
created_at: "2019-01-02T04:00:08.803Z",
custom_fields: null,
deleted_at: null,
description: null,
height: "0.00",
id: "7e3072c1-9bfd-4b52-af38-9c6e30456c73",
images: {main: "https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png", gallery: ["https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png"]},
item_status_id: "2b1a2598-8333-4b19-ae7b-c054bec87540",
length: "0.00",
name: "Silly Oregano Seasoning",
odoo_additional_data: {product_id: 205, product_uom: 21, product_tmpl_id: 291},
product_id: 205,
product_tmpl_id: 291,
product_uom: 21,
odoo_stock_id: 123634,
order: 147291,
preorder: null,
regular_price: "10",
sale_date_from: null,
sale_date_to: null,
sale_price: null,
seen: 0,
sold: 0,
stock: "34.00",
uom: "pack",
updated_at: "2019-01-02T13:00:05.042Z",
use_weight_as_stock: false,
user_store_id: "959194a0-7067-400c-b354-2e8d03300660",
visible: true,
weight: "0.04",
width: "0.00",
wishlist: "0",
},{
category_id: "1e444a5a-cf4d-48e5-bde4-0f984ebd557d",
created_at: "2019-01-02T04:00:08.803Z",
custom_fields: null,
deleted_at: null,
description: null,
height: "0.00",
id: "7e3072c1-9bfd-4b52-af38-9c6e30456c73",
images: {main: "https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png", gallery: ["https://marketplace-sillyfish-api.asacreative.com/uploads/item_123634.png"]},
item_status_id: "2b1a2598-8333-4b19-ae7b-c054bec87540",
length: "0.00",
name: "Silly Oregano Seasoning",
odoo_additional_data: {product_id: 205, product_uom: 21, product_tmpl_id: 291},
product_id: 205,
product_tmpl_id: 291,
product_uom: 21,
odoo_stock_id: 123634,
order: 147291,
preorder: null,
regular_price: "10",
sale_date_from: null,
sale_date_to: null,
sale_price: null,
seen: 0,
sold: 0,
stock: "34.00",
uom: "pack",
updated_at: "2019-01-02T13:00:05.042Z",
use_weight_as_stock: false,
user_store_id: "959194a0-7067-400c-b354-2e8d03300660",
visible: true,
weight: "0.04",
width: "0.00",
wishlist: "0",
}
];
const actionsDelete = [
<FlatButton
@@ -173,7 +481,7 @@ export default class All extends React.Component {
style={{fontSize: 14}}
hintStyle={{fontSize: 14}}
underlineShow={false}
onChange={this.search}
// onChange={this.search}
/>
</ToolbarGroup>
{/*<ToolbarGroup className="ToolbarGroupLast">*/}
@@ -244,7 +552,7 @@ export default class All extends React.Component {
</Col> : ""
}
{(this.myStoreItem.isSearching ? this.myStoreItem.dataFiltered : this.myStoreItem.data).map(item => {
{data.map(item => {
return (<Col key={item.id} className="gutter-row col" span={4} style={{marginBottom: 20}}>
<div className="gutter-box"><ItemCard data={item}/></div>
</Col>)

View File

@@ -31,8 +31,9 @@ export class ItemCard extends React.Component {
render() {
const {data = {}} = this.props;
const main = get(data,'images.main',null)
const mainImage = this.http.appendImagePath(main);
const main = get(data,'images.main',null);
// const mainImage = this.http.appendImagePath(main);
const mainImage = main;
return (
<Link to={`${LINKS.FORM_ITEMS}/edit/${data.id}`}>
@@ -43,10 +44,12 @@ export class ItemCard extends React.Component {
{/*<CardTitle style={{padding:8}} subtitleStyle={{display:'none'}} title={data.name} titleStyle={{fontSize: 12}}/>*/}
<CardTitle title={<Link to={`${LINKS.FORM_ITEMS}/${data.id}`}>{(data.name.length > 14) ? data.name.substring(0,13)+`...` : data.name}</Link>} titleStyle={{fontWeight: 'bold', fontSize: 18, lineHeight: '30px', whiteSpace: 'nowrap'}}
subtitle={<NumberFormat style={{fontWeight: 'bold', color: 'orangered'}}
value={data.regular_price}
displayType={'text'}
thousandSeparator={true} prefix={'Rp'}/>}/>
subtitle={<span style={{fontWeight: 'bold', color: 'orangered'}}>{data.regular_price} Points</span>}/>
{/*<CardTitle title={<Link to={`${LINKS.FORM_ITEMS}/${data.id}`}>{(data.name.length > 14) ? data.name.substring(0,13)+`...` : data.name}</Link>} titleStyle={{fontWeight: 'bold', fontSize: 18, lineHeight: '30px', whiteSpace: 'nowrap'}}*/}
{/*subtitle={<NumberFormat style={{fontWeight: 'bold', color: 'orangered'}}*/}
{/*value={data.regular_price}*/}
{/*displayType={'text'}*/}
{/*thousandSeparator={true} prefix={'Rp'}/>}/>*/}
{/*<CardText style={{padding: 8}}>*/}
{/*<p className="font-14" style={{marginBottom: 32, fontWeight: 'bold'}}>{data.name}</p>*/}

View File

@@ -1,22 +1,12 @@
import React from 'react';
import {inject, observer} from 'mobx-react';
import {Link} from 'react-router';
import { Affix, Card, Slider, Select } from 'antd';
import {Tab, Tabs} from 'material-ui';
import './style.scss';
import All from "./All/index";
import Active from "./Active/index";
import Unactive from "./Unactive/index";
import SoldOut from "./SoldOut/index";
import Banned from "./Banned/index";
export const ITEM_TABS = {
ALL: 'all',
ACTIVE: 'active',
UNACTIVE : 'unactive',
SOLD_OUT: 'sold_out',
BANNED: 'banned',
};
const Option = Select.Option;
@inject('appstate')
@observer
export default class ItemsComponent extends React.Component {
@@ -24,72 +14,70 @@ export default class ItemsComponent extends React.Component {
super(props);
this.props = props;
this.state = {
tabSelected: 'all',
valueMinimal: 0,
valueMaximal: 0,
};
this.handleChange = this.handleChange.bind(this);
this.defaultState = Object.assign({}, this.state);
this.http = props.appstate.http;
this.authStore = props.appstate.auth;
this.globalUI = props.appstate.globalUI;
this.appStore = props.appstate.app;
this.myStore = props.appstate.myStore;
}
componentDidMount() {
}
handleChange = (tabSelected) => {
this.setState({tabSelected: tabSelected});
this.globalUI.itemsTabSelected = tabSelected;
handleChangeMinimal = (valueMinimal) => {
this.setState({ valueMinimal });
};
getContent() {
switch (this.globalUI.itemsTabSelected) {
case ITEM_TABS.ALL:
return <All/>;
case ITEM_TABS.ACTIVE:
return <Active/>;
case ITEM_TABS.UNACTIVE:
return <Unactive/>;
case ITEM_TABS.SOLD_OUT:
return <SoldOut/>;
case ITEM_TABS.BANNED:
return <Banned/>;
default:
return <All/>
}
handleChangeMaximal = (valueMaximal) => {
this.setState({ valueMaximal });
};
handleChange = (value) => {
console.log(`selected ${value}`);
}
handleBlur = () => {
console.log('blur');
}
handleFocus = () => {
console.log('focus');
}
render() {
const {type:appType} = this.appStore;
const { valueMinimal, valueMaximal } = this.state;
return (
<div className="setting containerMiddle">
<div className="setting">
<div className="row">
<div className="col l12 m12 s12 no-padding">
<Tabs
value={this.globalUI.itemsTabSelected}
onChange={this.handleChange}
inkBarStyle={{background: 'transparent'}}
className="tabsAkun"
style={{background: 'transparent'}} >
<Tab label="All" value="all" className={(this.globalUI.itemsTabSelected === 'all') ? "buttonTabs buttonTabsActive" : 'buttonTabs'}>
</Tab>
<Tab label="Active" value="active" className={(this.globalUI.itemsTabSelected === 'active') ? "buttonTabs buttonTabsActive" : 'buttonTabs'}>
</Tab>
{/*<Tab label="Inactive" value="unactive" className={(this.globalUI.itemsTabSelected === 'unactive') ? "buttonTabs buttonTabsActive" : 'buttonTabs'}>
</Tab>*/}
<Tab label="Sold Out" value="sold_out" className={(this.globalUI.itemsTabSelected === 'sold_out') ? "buttonTabs buttonTabsActive" : 'buttonTabs'}>
</Tab>
{/*<Tab label="Banned" value="banned" className={(this.globalUI.itemsTabSelected === 'banned') ? "buttonTabs buttonTabsActive" : 'buttonTabs'}>*/}
{/**/}
{/*</Tab>*/}
</Tabs>
{this.getContent()}
<div className="col l3 m3 s3 no-padding">
<Affix offsetTop={90}>
<Card title="Filter" bordered={true} style={{ width: '100%' }}>
<p>Min. Points</p>
<Slider max={1000} onChange={this.handleChangeMinimal} value={valueMinimal} />
<p>Max. Points</p>
<Slider max={1000} onChange={this.handleChangeMaximal} value={valueMaximal} />
<p style={{marginTop: 25}}>Category</p>
<Select
showSearch
style={{ width: '100%' }}
placeholder="Select a category"
optionFilterProp="children"
onChange={this.handleChange}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
// filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
>
<Option value="jack">Electronic</Option>
<Option value="lucy">Fashion</Option>
<Option value="tom">Food</Option>
</Select>
</Card>
</Affix>
</div>
<div className="col l9 m9 s9 no-padding">
<All/>
</div>
</div>
</div>