forked from forcedotcom/commerce-on-lightning-components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
31 lines (29 loc) · 898 Bytes
/
utils.js
File metadata and controls
31 lines (29 loc) · 898 Bytes
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
27
28
29
30
31
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* For full license text, see the LICENSE file in the repo
* root or https://opensource.org/licenses/apache-2-0/
*/
/**
* @typedef {import('./searchSortMenu').SortRuleData} SortRuleData
*/
/**
* @typedef {import('./searchSortMenu').LabelValuePair} LabelValuePair
*/
/**
* Computes a list of (normalized) sort menu options from the given sort rules.
* @param {SortRuleData[]} [sortRules] The list of sort rules
* @returns {LabelValuePair[]} The list of sort options
*/
export function computeSortOptions(sortRules) {
return Array.isArray(sortRules)
? sortRules.map((item) => {
const { sortRuleId, label } = item;
return {
value: sortRuleId,
label: label,
};
})
: [];
}