@open-tender/store
Version:
A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API
22 lines (21 loc) • 808 B
JavaScript
import { pixelsToInt } from '@open-tender/utils';
export var makeAsideWidth = function (deviceWidth, layout) {
var padding = pixelsToInt(layout.padding);
var asideWidth = pixelsToInt(layout.aside.width);
var buttonWidth = pixelsToInt(layout.bigButton.width);
var remaining = deviceWidth - padding * 2 - asideWidth;
var count = Math.floor(remaining / buttonWidth);
return deviceWidth - count * buttonWidth - 2 * padding;
};
export var makePhone = function (phone) {
if (!phone)
return '';
var p = phone.replace(/\D/g, '');
if (p.length > 6) {
return "".concat(p.slice(0, 3), "-").concat(p.slice(3, 6), "-").concat(p.slice(6, 10));
}
else if (p.length > 3) {
return "".concat(p.slice(0, 3), "-").concat(p.slice(3, 6));
}
return p;
};