bananas-commerce-admin 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,7 +57,7 @@ const ReceiptCard = ({ receipt, refund, }) => {
57
57
  const [refundable, setRefundable] = react_1.default.useState(receipt.intention === 1);
58
58
  return (react_1.default.createElement(Card_1.default, null,
59
59
  react_1.default.createElement(CardHeader_1.default, { title: react_1.default.createElement(Typography_1.default, { variant: "h6" },
60
- react_1.default.createElement("b", null, "Receipt")), avatar: react_1.default.createElement(Receipt_1.default, null), action: react_1.default.createElement(FormControlLabel_1.default, { disabled: refundable, control: react_1.default.createElement(Switch_1.default, { value: editing, onChange: (_, checked) => setEditing(checked), color: "secondary" }), label: "Refund" }), sx: {
60
+ react_1.default.createElement("b", null, "Receipt")), avatar: react_1.default.createElement(Receipt_1.default, null), action: react_1.default.createElement(FormControlLabel_1.default, { disabled: !refundable, control: react_1.default.createElement(Switch_1.default, { value: editing, onChange: (_, checked) => setEditing(checked), color: "secondary" }), label: "Edit" }), sx: {
61
61
  borderBottomWidth: 1,
62
62
  borderBottomStyle: "solid",
63
63
  borderBottomColor: theme.palette.divider,
@@ -80,6 +80,7 @@ const ReceiptCard = ({ receipt, refund, }) => {
80
80
  ? (react_1.default.createElement(Button_1.default, { variant: "contained", color: "error", disabled: selected.length === 0, onClick: () => {
81
81
  refund === null || refund === void 0 ? void 0 : refund(selected);
82
82
  setRefundable(false);
83
+ setEditing(false);
83
84
  } }, "Refund"))
84
85
  : null),
85
86
  react_1.default.createElement(TableCell_1.default, { align: "right" },
@@ -50,9 +50,10 @@ const ReceiptTable = ({ lines, editable, onSelect }) => {
50
50
  selected.length < lines.length, checked: lines.length !== 0 &&
51
51
  selected.length === lines.length, onChange: toggleSelectAll, disabled: lines.length === 0 })))
52
52
  : null,
53
- react_1.default.createElement(TableCell_1.default, { align: "left" }, "Item"),
53
+ react_1.default.createElement(TableCell_1.default, { align: "left" }),
54
54
  react_1.default.createElement(TableCell_1.default, { align: "right" }, "Quantity"),
55
- react_1.default.createElement(TableCell_1.default, { align: "right" }, "Price"))),
55
+ react_1.default.createElement(TableCell_1.default, { align: "right" }, "Unit"),
56
+ react_1.default.createElement(TableCell_1.default, { align: "right" }, "Total"))),
56
57
  react_1.default.createElement(TableBody_1.default, null, lines.map((line) => {
57
58
  const isSelected = selected.map(({ line_number }) => line_number)
58
59
  .includes(line.line_number);
@@ -65,6 +66,7 @@ const ReceiptTable = ({ lines, editable, onSelect }) => {
65
66
  react_1.default.createElement(TableCell_1.default, { align: "right" }, editable
66
67
  ? (react_1.default.createElement(Input_1.default, { type: "number", defaultValue: line.quantity, inputProps: { min: 0, max: line.quantity }, disabled: !isSelected, onChange: (event) => lineQuantityChange(Object.assign(Object.assign({}, line), { quantity: parseInt(event.target.value) })) }))
67
68
  : line.quantity),
69
+ react_1.default.createElement(TableCell_1.default, { align: "right" }, `${line.unit_price} SEK`),
68
70
  react_1.default.createElement(TableCell_1.default, { align: "right" }, `${line.total_amount} SEK`)));
69
71
  })))));
70
72
  };
@@ -16,7 +16,7 @@ const PurchaseDetailPage = ({ data: { purchase, receipts } }) => {
16
16
  const { enqueueSnackbar } = (0, notistack_1.useSnackbar)();
17
17
  const doRefund = (lines) => {
18
18
  api.operations["pos.purchase:refund-items"].call({
19
- params: { pruchase_number: purchase.number },
19
+ params: { purchase_number: purchase.number },
20
20
  body: lines.map(({ reference, quantity }) => ({ reference, quantity })),
21
21
  }).then((response) => {
22
22
  if (response.ok) {
@@ -28,7 +28,7 @@ export const ReceiptCard = ({ receipt, refund, }) => {
28
28
  const [refundable, setRefundable] = React.useState(receipt.intention === 1);
29
29
  return (React.createElement(Card, null,
30
30
  React.createElement(CardHeader, { title: React.createElement(Typography, { variant: "h6" },
31
- React.createElement("b", null, "Receipt")), avatar: React.createElement(ReceiptIcon, null), action: React.createElement(FormControlLabel, { disabled: refundable, control: React.createElement(Switch, { value: editing, onChange: (_, checked) => setEditing(checked), color: "secondary" }), label: "Refund" }), sx: {
31
+ React.createElement("b", null, "Receipt")), avatar: React.createElement(ReceiptIcon, null), action: React.createElement(FormControlLabel, { disabled: !refundable, control: React.createElement(Switch, { value: editing, onChange: (_, checked) => setEditing(checked), color: "secondary" }), label: "Edit" }), sx: {
32
32
  borderBottomWidth: 1,
33
33
  borderBottomStyle: "solid",
34
34
  borderBottomColor: theme.palette.divider,
@@ -51,6 +51,7 @@ export const ReceiptCard = ({ receipt, refund, }) => {
51
51
  ? (React.createElement(Button, { variant: "contained", color: "error", disabled: selected.length === 0, onClick: () => {
52
52
  refund === null || refund === void 0 ? void 0 : refund(selected);
53
53
  setRefundable(false);
54
+ setEditing(false);
54
55
  } }, "Refund"))
55
56
  : null),
56
57
  React.createElement(TableCell, { align: "right" },
@@ -44,9 +44,10 @@ export const ReceiptTable = ({ lines, editable, onSelect }) => {
44
44
  selected.length < lines.length, checked: lines.length !== 0 &&
45
45
  selected.length === lines.length, onChange: toggleSelectAll, disabled: lines.length === 0 })))
46
46
  : null,
47
- React.createElement(TableCell, { align: "left" }, "Item"),
47
+ React.createElement(TableCell, { align: "left" }),
48
48
  React.createElement(TableCell, { align: "right" }, "Quantity"),
49
- React.createElement(TableCell, { align: "right" }, "Price"))),
49
+ React.createElement(TableCell, { align: "right" }, "Unit"),
50
+ React.createElement(TableCell, { align: "right" }, "Total"))),
50
51
  React.createElement(TableBody, null, lines.map((line) => {
51
52
  const isSelected = selected.map(({ line_number }) => line_number)
52
53
  .includes(line.line_number);
@@ -59,6 +60,7 @@ export const ReceiptTable = ({ lines, editable, onSelect }) => {
59
60
  React.createElement(TableCell, { align: "right" }, editable
60
61
  ? (React.createElement(Input, { type: "number", defaultValue: line.quantity, inputProps: { min: 0, max: line.quantity }, disabled: !isSelected, onChange: (event) => lineQuantityChange(Object.assign(Object.assign({}, line), { quantity: parseInt(event.target.value) })) }))
61
62
  : line.quantity),
63
+ React.createElement(TableCell, { align: "right" }, `${line.unit_price} SEK`),
62
64
  React.createElement(TableCell, { align: "right" }, `${line.total_amount} SEK`)));
63
65
  })))));
64
66
  };
@@ -11,7 +11,7 @@ const PurchaseDetailPage = ({ data: { purchase, receipts } }) => {
11
11
  const { enqueueSnackbar } = useSnackbar();
12
12
  const doRefund = (lines) => {
13
13
  api.operations["pos.purchase:refund-items"].call({
14
- params: { pruchase_number: purchase.number },
14
+ params: { purchase_number: purchase.number },
15
15
  body: lines.map(({ reference, quantity }) => ({ reference, quantity })),
16
16
  }).then((response) => {
17
17
  if (response.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bananas-commerce-admin",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Bananas-commerce admin interface and building blocks",
5
5
  "keywords": [
6
6
  "admin",
@@ -67,7 +67,7 @@ export const ReceiptCard: React.FC<ReceiptCardProps> = ({
67
67
  avatar={<ReceiptIcon />}
68
68
  action={
69
69
  <FormControlLabel
70
- disabled={refundable}
70
+ disabled={!refundable}
71
71
  control={
72
72
  <Switch
73
73
  value={editing}
@@ -75,7 +75,7 @@ export const ReceiptCard: React.FC<ReceiptCardProps> = ({
75
75
  color="secondary"
76
76
  />
77
77
  }
78
- label="Refund"
78
+ label="Edit"
79
79
  />
80
80
  }
81
81
  sx={{
@@ -117,6 +117,7 @@ export const ReceiptCard: React.FC<ReceiptCardProps> = ({
117
117
  onClick={() => {
118
118
  refund?.(selected);
119
119
  setRefundable(false);
120
+ setEditing(false);
120
121
  }}
121
122
  >
122
123
  Refund
@@ -77,14 +77,15 @@ export const ReceiptTable: React.FC<ReceiptTableProps> = (
77
77
  </TableCell>
78
78
  )
79
79
  : null}
80
- <TableCell align="left">
81
- Item
82
- </TableCell>
80
+ <TableCell align="left" />
83
81
  <TableCell align="right">
84
82
  Quantity
85
83
  </TableCell>
86
84
  <TableCell align="right">
87
- Price
85
+ Unit
86
+ </TableCell>
87
+ <TableCell align="right">
88
+ Total
88
89
  </TableCell>
89
90
  </TableRow>
90
91
  </TableHead>
@@ -127,6 +128,9 @@ export const ReceiptTable: React.FC<ReceiptTableProps> = (
127
128
  )
128
129
  : line.quantity}
129
130
  </TableCell>
131
+ <TableCell align="right">
132
+ {`${line.unit_price} SEK`}
133
+ </TableCell>
130
134
  <TableCell align="right">
131
135
  {`${line.total_amount} SEK`}
132
136
  </TableCell>
@@ -18,7 +18,7 @@ const PurchaseDetailPage: PageComponent<PurchaseDetail> = (
18
18
 
19
19
  const doRefund = (lines: ReceiptLine[]) => {
20
20
  api.operations["pos.purchase:refund-items"].call({
21
- params: { pruchase_number: purchase.number },
21
+ params: { purchase_number: purchase.number },
22
22
  body: lines.map(({ reference, quantity }) => ({ reference, quantity })),
23
23
  }).then((response) => {
24
24
  if (response.ok) {