
export function settingsSelector(fn) {
	return (state) => {
		let unit = state && state.get && state.get("settings");
		unit = unit ? unit.toJS() : {};
		let s = {
			unit: unit.data,
			unitId: unit.unitId,
			i18n: unitI18n(unit.data),
			...fn(state)
		};
		return s;
	}
}


export function unitI18n(unit) {
	if (!unit) {
		unit = {};
	}

	return {
		dateFormat: unit.dateFormat || "MM/DD/YYYY",
		timeFormat: "hh:mm",

	 	thousandDelimiter: unit.thousandDelimiter || ",",
		decimalDelimiter: unit.decimalDelimiter || ".",
		decimalDigits: unit.decimalPrecission || 2,

		currencySymbolLeft: unit.currencyFormat != "right"
	}
}


