Skip to content

Commit 8f37914

Browse files
authored
Added functionality to easily export all names associated with an order (#97)
* Added functionality to copy all names from an order * Added better styling and layout for name-list copy button * removed unused import * Added ability to split multiple names when on a single food item
1 parent bb7456d commit 8f37914

File tree

3 files changed

+46
-80
lines changed

3 files changed

+46
-80
lines changed

imports/use-cases/main/screens/order/views/order-box/OrderBox.view.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class OrderBox extends Component {
132132
outlined: true,
133133
upperLabel: "Nick",
134134
lowerLabel:
135-
"Enter an identifiable name or nick"
135+
"Enter an identifiable name or nick (multiple names should be separated by either \"+\" or \"&\")"
136136
}}
137137
/>
138138
</DigitLayout.Column>

imports/use-cases/main/screens/order/views/pizzas/Pizzas.view.jsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
DigitText,
1111
DigitLayout,
1212
DigitIfElseRendering,
13-
DigitDesign
13+
DigitDesign,
14+
DigitButton
1415
} from "@cthit/react-digit-components";
1516

1617
const ItemsContainer = styled.div`
@@ -50,6 +51,20 @@ class Pizzas extends Component {
5051
});
5152
};
5253

54+
copyNamesToClipboard = () => {
55+
const orderItems = this.props.orderItems;
56+
//const nicks = orderItems.map(item => item.nick).join("\n");
57+
const nicks = orderItems.flatMap(item => item.nick.split(/\s*\+\s*|\s*&\s*/)).join("\n");
58+
try {
59+
navigator.clipboard.writeText(nicks);
60+
this.props.openToast({
61+
text: "Copied to clipboard"
62+
});
63+
} catch (err) {
64+
console.error("Failed to copy: ", err);
65+
}
66+
}
67+
5368
undoRemoveOrderItem = orderItem => {
5469
const { nick, pizza, order } = orderItem;
5570

@@ -104,12 +119,21 @@ class Pizzas extends Component {
104119
<DigitLayout.Column marginVertical={"16px"}>
105120
<ItemsContainer>{pizzaElements}</ItemsContainer>
106121
<hr />
107-
<DigitLayout.Row>
122+
<DigitLayout.Row justifyContent="space-between">
108123
<DigitText.Text
109124
text={
110125
"Total items: " + orderItems.length
111126
}
112127
/>
128+
<DigitDesign.CardButtons reverseDirection>
129+
<DigitButton
130+
disabled={this.props.orderItems.length == 0}
131+
primary
132+
outlined
133+
text="Copy names to clipboard"
134+
onClick={this.copyNamesToClipboard}
135+
/>
136+
</DigitDesign.CardButtons>
113137
</DigitLayout.Row>
114138
</DigitLayout.Column>
115139
)}

package-lock.json

Lines changed: 19 additions & 77 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)