Files
luggage-list/src/utils/items.js
Space-Banane 0a8444700e
Some checks failed
Luggage List Build / build-web (push) Successful in 31s
Luggage List Build / build-android (push) Failing after 1m24s
Luggage List Build / release (push) Has been skipped
Full UI 180 & Overall improvements
2026-04-19 00:12:16 +02:00

28 lines
889 B
JavaScript

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();
}