@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
27 lines (26 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.makePhone = exports.makeAsideWidth = void 0;
var utils_1 = require("@open-tender/utils");
var makeAsideWidth = function (deviceWidth, layout) {
var padding = (0, utils_1.pixelsToInt)(layout.padding);
var asideWidth = (0, utils_1.pixelsToInt)(layout.aside.width);
var buttonWidth = (0, utils_1.pixelsToInt)(layout.bigButton.width);
var remaining = deviceWidth - padding * 2 - asideWidth;
var count = Math.floor(remaining / buttonWidth);
return deviceWidth - count * buttonWidth - 2 * padding;
};
exports.makeAsideWidth = makeAsideWidth;
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;
};
exports.makePhone = makePhone;