From 795574b026e5c80a56237b63f7b84f8be380ab1a Mon Sep 17 00:00:00 2001 From: aatbip Date: Tue, 6 Feb 2024 15:58:42 +0545 Subject: [PATCH] fix bugs --- src/app/manage/page.tsx | 8 ++++---- src/components/table/Table.tsx | 26 +++++++++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/app/manage/page.tsx b/src/app/manage/page.tsx index f91f8e4..77b09d8 100644 --- a/src/app/manage/page.tsx +++ b/src/app/manage/page.tsx @@ -51,10 +51,10 @@ export default async function ManagePage({ searchParams }: { searchParams: { tok const settings = await getSettings({ token, portalId }).then((s) => s.profileLinks); const customFieldAccess = await getCustomFieldAccess({ token, portalId }); // static for now, will be dynamic later after some API decisions are made - // const clientId = 'a583a0d0-de70-4d14-8bb1-0aacf7424e2c'; - // const companyId = '52eb75a9-2790-4e37-aa7a-c13f7bc3aa91'; - const clientId = '2b37da9b-73b9-4c28-b7ac-144cf39cb13b'; - const companyId = 'b5b3883c-f3e7-40e2-98e8-4f4b195ba98e'; + const clientId = 'a583a0d0-de70-4d14-8bb1-0aacf7424e2c'; + const companyId = '52eb75a9-2790-4e37-aa7a-c13f7bc3aa91'; + // const clientId = '2b37da9b-73b9-4c28-b7ac-144cf39cb13b'; + // const companyId = 'b5b3883c-f3e7-40e2-98e8-4f4b195ba98e'; const client = await getClient(clientId, token); return ( diff --git a/src/components/table/Table.tsx b/src/components/table/Table.tsx index 56bb5fa..6237de2 100644 --- a/src/components/table/Table.tsx +++ b/src/components/table/Table.tsx @@ -31,15 +31,27 @@ export const TableCore = () => { return 0; }; - const comparatorTypeII = (valueA: any, valueB: any) => { - if (valueA.row[valueA.key].value < valueB.row[valueB.key].value) { - return -1; - } - if (valueA.row[valueA.key].value > valueB.row[valueB.key].value) { - return 1; + const comparatorTypeII = (valueA: any, valueB: any, nodeA: any, nodeB: any, isInverted: any) => { + const _valueA = valueA.row[valueA.key].value; + const _valueB = valueB.row[valueB.key].value; + if (_valueA === null && _valueB === null) { + return 0; // Both are considered equal + } else if (_valueA === null) { + return isInverted ? -1 : 1; // Null comes before a non-null string/number + } else if (_valueB === null) { + return isInverted ? 1 : -1; // Non-null string/number comes before null } - return 0; + // Convert values to strings for consistent comparison + const stringA: any = String(_valueA); + const stringB: any = String(_valueB); + + // Perform lexicographical comparison for strings, numeric comparison for numbers + if (!isNaN(stringA) && !isNaN(stringB)) { + return parseFloat(stringA) - parseFloat(stringB); + } else { + return stringA.localeCompare(stringB); + } }; useEffect(() => {