#
vincentlu
10 小时以前 c65a357fc8b907af755e1ef6a2c201e31eb71e94
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
export const DIRECTION_OPTIONS = [
    { id: 0, labelKey: 'page.integrationRecord.enums.direction.none' },
    { id: 1, labelKey: 'page.integrationRecord.enums.direction.inbound' },
    { id: 2, labelKey: 'page.integrationRecord.enums.direction.outbound' },
];
 
export const buildDirectionChoices = (translate) =>
    DIRECTION_OPTIONS.map(option => ({
        id: option.id,
        name: translate(option.labelKey),
    }));
 
export const getDirectionLabel = (translate, value) => {
    if (value === null || value === undefined) {
        return '';
    }
    const numericValue = typeof value === 'number' ? value : Number(value);
    if (Number.isNaN(numericValue)) {
        return '';
    }
    const option = DIRECTION_OPTIONS.find(opt => opt.id === numericValue);
    if (!option) {
        return '';
    }
    return translate(option.labelKey);
};