@josmangarsal/pragmatic-scheduler
Version:
React resource scheduler
48 lines (47 loc) • 1.92 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSchedulerViewConfig = void 0;
var react_1 = require("react");
var defaults_1 = require("../constants/defaults");
var useSchedulerViewConfig = function (_a) {
var _b = _a.daysToDisplay, daysToDisplay = _b === void 0 ? 3 : _b, _c = _a.interval, interval = _c === void 0 ? 2 : _c, _d = _a.prevDays, prevDays = _d === void 0 ? 0 : _d;
var config = (0, react_1.useMemo)(function () {
var currentConfig = __assign({}, defaults_1.defaultConfig);
currentConfig.daysToDisplay = daysToDisplay;
if (currentConfig.daysToDisplay >= 6) {
currentConfig.divisionParts = 1;
}
switch (interval) {
case 0.25: // 15 minutes
// currentConfig.divisionWidth = 160 / 2;
break;
case 24: // 1 day
currentConfig.divisionWidth = 160 * 2;
break;
case 24 * 7: // 1 week
currentConfig.divisionWidth = 160 * 4;
break;
default:
}
currentConfig.previousDaysToDisplay = prevDays;
currentConfig.daysToDisplay += currentConfig.previousDaysToDisplay;
currentConfig.unAssignedRows = 0;
return currentConfig;
}, [daysToDisplay, interval, prevDays]);
return {
currentInterval: interval,
config: config,
};
};
exports.useSchedulerViewConfig = useSchedulerViewConfig;