This commit is contained in:
MuslemRahimi 2024-10-11 15:18:03 +02:00
parent 18103177a5
commit e13b2a6538

View File

@ -266,6 +266,8 @@ async function handleChangeValue(value) {
allRows = [...allRows];
ruleOfList = [...ruleOfList];
const priorityItems = new Set(['AI Score', 'Revenue', 'Net Income', 'Free Cash Flow']);
allRows = allRows
?.filter(item => checkedItems.has(item.name) || !checkedItems.has(item.name))
?.sort((a, b) => {
@ -275,10 +277,24 @@ async function handleChangeValue(value) {
// Sort checked items first
if (isAChecked !== isBChecked) return isAChecked ? -1 : 1;
// Sort alphabetically if both are checked or both are unchecked
// Check if the user is not Pro
if (data?.user?.tier !== 'Pro') {
// Check if both items are priority items
const isAPriority = priorityItems.has(a.name);
const isBPriority = priorityItems.has(b.name);
// If both are priority items or both are not, sort alphabetically
if (isAPriority === isBPriority) return a.name.localeCompare(b.name);
// Move priority items to the bottom
return isAPriority ? 1 : -1;
}
// If the user is Pro, sort alphabetically
return a.name.localeCompare(b.name);
});
}