Full UI 180 & Overall improvements
This commit is contained in:
27
src/utils/items.js
Normal file
27
src/utils/items.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import { ITEM_PLACEMENTS } from '../constants';
|
||||
|
||||
export function toPlacementFormState(rawPlacement = 'suitcase') {
|
||||
const placement = `${rawPlacement || ''}`.trim() || 'suitcase';
|
||||
const hasPresetPlacement = ITEM_PLACEMENTS.includes(placement);
|
||||
|
||||
return {
|
||||
placement: hasPresetPlacement ? placement : 'other',
|
||||
placementCustom: hasPresetPlacement || placement === 'other' ? '' : placement,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolvePlacementValue(placement = '', placementCustom = '') {
|
||||
const normalizedPlacement = `${placement || ''}`.trim();
|
||||
if (!normalizedPlacement) return '';
|
||||
|
||||
if (normalizedPlacement === 'other') {
|
||||
return `${placementCustom || ''}`.trim();
|
||||
}
|
||||
|
||||
return normalizedPlacement;
|
||||
}
|
||||
|
||||
export function withPlacementCustomFallback(currentCustom = '', fallback = '') {
|
||||
const custom = `${currentCustom || ''}`.trim();
|
||||
return custom || `${fallback || ''}`.trim();
|
||||
}
|
||||
Reference in New Issue
Block a user