source: frontend/src/components/functions.jsx@ badbc79

Last change on this file since badbc79 was badbc79, checked in by Luka Cheshlarov <luka.cheshlarov@…>, 20 months ago

Initial commit

  • Property mode set to 100644
File size: 603 bytes
Line 
1import moment from "moment";
2
3export const truncate = (str, truncateLength = 10, strLength = 15) => {
4 return str.length > strLength ? str.substring(0, truncateLength) + "..." : str;
5}
6
7export const formatDate = (isoDateString) => {
8 return moment(isoDateString).format('DD.MM.YYYY HH:mm');
9};
10
11export const calculateTotalPrice = (narackaMenuItems) => {
12 let totalPrice = 0;
13
14 if (!narackaMenuItems) {
15 return totalPrice;
16 }
17
18 for (const narackaMenu of narackaMenuItems) {
19 totalPrice += narackaMenu?.quantity * narackaMenu.menuItem?.cena;
20 }
21 return totalPrice;
22};
Note: See TracBrowser for help on using the repository browser.