-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathunshipped-items.jsx
More file actions
87 lines (73 loc) · 2.13 KB
/
unshipped-items.jsx
File metadata and controls
87 lines (73 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* @flow */
// libs
import _ from 'lodash';
import React, { Component, Element } from 'react';
import { autobind } from 'core-decorators';
// data
import { itemStateTitles, itemReasonsTitles } from 'paragons/shipment';
// components
import ContentBox from 'components/core/content-box';
import TableView from 'components/table/tableview';
import TableRow from 'components/table/row';
import TableCell from 'components/table/cell';
import Currency from 'components/common/currency';
import ProductImage from 'components/imgix/product-image';
// styles
import styles from './unshipped-items.css';
// types
import type { TUnshippedLineItem } from 'paragons/shipment';
type Props = {
items: Array<TUnshippedLineItem>;
};
const viewColumns = [
{field: 'imagePath', text: 'Image', type: 'image'},
{field: 'name', text: 'Name'},
{field: 'sku', text: 'SKU'},
{field: 'price', text: 'Price', type: 'currency'},
{field: 'quantity', text: 'Quantity'},
{field: 'state', text: 'Item State'},
{field: 'reason', text: 'Reason'},
];
export default class UnshippedItems extends Component {
props: Props;
@autobind
renderRow(row: Object, index: number): Element<*> {
return (
<TableRow key={index}>
<TableCell>
<ProductImage src={row.imagePath} width={50} height={50} />
</TableCell>
<TableCell>{row.name}</TableCell>
<TableCell>{row.sku}</TableCell>
<TableCell>
<Currency value={row.price} />
</TableCell>
<TableCell>{row.quantity}</TableCell>
<TableCell>{itemStateTitles[row.state]}</TableCell>
<TableCell>{itemReasonsTitles[row.reason]}</TableCell>
</TableRow>
);
}
get content(): Element<*> {
const { items } = this.props;
return (
<TableView
columns={viewColumns}
data={{rows: items}}
renderRow={this.renderRow}
emptyMessage="There are no unshipped items."
renderHeadIfEmpty={false}
/>
);
}
render() {
return (
<ContentBox
styleName="box"
title="Unshipped Items"
indentContent={false}
viewContent={this.content}
/>
);
}
}