From 094877f0764bbf601d883936eb3a9e45681b9fe2 Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Wed, 23 Apr 2025 18:43:51 +0530 Subject: [PATCH 1/5] Add start date --- .../src/lib/models/MobileTableColumn.model.ts | 2 +- src/apps/copilots/src/copilots.routes.tsx | 5 +++-- .../pages/copilot-opportunity-details/index.tsx | 14 +++++++++++++- .../copilots/src/services/copilot-opportunities.ts | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/apps/admin/src/lib/models/MobileTableColumn.model.ts b/src/apps/admin/src/lib/models/MobileTableColumn.model.ts index 4f24b98a4..01229aa43 100644 --- a/src/apps/admin/src/lib/models/MobileTableColumn.model.ts +++ b/src/apps/admin/src/lib/models/MobileTableColumn.model.ts @@ -4,5 +4,5 @@ import { TableColumn } from '~/libs/ui' export interface MobileTableColumn extends TableColumn { - readonly mobileType?: 'label' + readonly mobileType?: 'label' | 'last-value' } diff --git a/src/apps/copilots/src/copilots.routes.tsx b/src/apps/copilots/src/copilots.routes.tsx index d06bd80ba..9d5921211 100644 --- a/src/apps/copilots/src/copilots.routes.tsx +++ b/src/apps/copilots/src/copilots.routes.tsx @@ -23,16 +23,19 @@ export const childRoutes = [ route: '/', }, { + authRequired: true, element: , id: 'CopilotRequests', route: '/requests', }, { + authRequired: true, element: , id: 'CopilotRequestForm', route: '/requests/new', }, { + authRequired: true, element: , id: 'CopilotRequestDetails', route: '/requests/:requestId', @@ -54,10 +57,8 @@ export const copilotRoutesMap = childRoutes.reduce((allRoutes, route) => ( export const copilotsRoutes: ReadonlyArray = [ { - authRequired: true, children: [ ...childRoutes, - ], domain: AppSubdomain.copilots, element: , diff --git a/src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx b/src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx index 4caffd9d5..779e2a04e 100644 --- a/src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx +++ b/src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx @@ -1,5 +1,6 @@ import { FC, useEffect, useState } from 'react' import { useNavigate, useParams } from 'react-router-dom' +import moment from 'moment' import { ContentLayout, @@ -29,7 +30,7 @@ const CopilotOpportunityDetails: FC<{}> = () => { if (!opportunity) { setShowNotFound(true) } - }, 2000) + }, 5000) return () => clearTimeout(timer) // Cleanup on unmount }, [opportunity]) @@ -60,6 +61,17 @@ const CopilotOpportunityDetails: FC<{}> = () => { {opportunity?.status} +
+ +
+ Start Date + + {moment(opportunity?.startDate) + .format('MMM D, YYYY')} + + +
+
diff --git a/src/apps/copilots/src/services/copilot-opportunities.ts b/src/apps/copilots/src/services/copilot-opportunities.ts index 718f0fb92..8cc72745a 100644 --- a/src/apps/copilots/src/services/copilot-opportunities.ts +++ b/src/apps/copilots/src/services/copilot-opportunities.ts @@ -71,7 +71,7 @@ export type CopilotOpportunityResponse = SWRResponse { - const url = opportunityId ? buildUrl(`${baseUrl}/copilots/opportunities/${opportunityId}`) : undefined + const url = opportunityId ? buildUrl(`${baseUrl}/copilot/opportunity/${opportunityId}`) : undefined const fetcher = (urlp: string): Promise => xhrGetAsync(urlp) .then(copilotOpportunityFactory) From 28a3742e546edba5a5c943665183d8c90a844cb5 Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Wed, 23 Apr 2025 18:48:18 +0530 Subject: [PATCH 2/5] Revert timeout --- .../copilots/src/pages/copilot-opportunity-details/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx b/src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx index 779e2a04e..9d1fd8b21 100644 --- a/src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx +++ b/src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx @@ -30,7 +30,7 @@ const CopilotOpportunityDetails: FC<{}> = () => { if (!opportunity) { setShowNotFound(true) } - }, 5000) + }, 2000) return () => clearTimeout(timer) // Cleanup on unmount }, [opportunity]) From d09c17b4c4be56c447af358d4cde4a2018b13f58 Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Thu, 24 Apr 2025 12:34:55 +0530 Subject: [PATCH 3/5] PM-589 Opportunity table fixes --- .../pages/copilot-opportunity-list/index.tsx | 22 ++++++++++++++++--- .../styles.module.scss | 8 ++++++- src/libs/ui/lib/components/table/Table.tsx | 9 ++++++-- .../components/table/table-column.model.ts | 1 + .../table/table-functions/table.functions.ts | 10 ++++----- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx b/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx index 927073d6d..75da7d429 100644 --- a/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx +++ b/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx @@ -13,6 +13,7 @@ import { import { CopilotOpportunity } from '../../models/CopilotOpportunity' import { copilotRoutesMap } from '../../copilots.routes' import { CopilotOpportunitiesResponse, useCopilotOpportunities } from '../../services/copilot-opportunities' +import { ProjectTypeLabels } from '../../constants' import styles from './styles.module.scss' @@ -20,7 +21,12 @@ const tableColumns: TableColumn[] = [ { label: 'Title', propertyName: 'projectName', - type: 'text', + renderer: (copilotOpportunity: CopilotOpportunity) => ( +
+ {copilotOpportunity.projectName} +
+ ), + type: 'element', }, { label: 'Status', @@ -33,6 +39,7 @@ const tableColumns: TableColumn[] = [ type: 'element', }, { + isSortable: false, label: 'Skills Required', propertyName: 'skills', renderer: (copilotOpportunity: CopilotOpportunity) => ( @@ -49,7 +56,12 @@ const tableColumns: TableColumn[] = [ { label: 'Type', propertyName: 'type', - type: 'text', + renderer: (copilotOpportunity: CopilotOpportunity) => ( +
+ {ProjectTypeLabels[copilotOpportunity.projectType]} +
+ ), + type: 'element', }, { label: 'Starting Date', @@ -80,7 +92,10 @@ const CopilotOpportunityList: FC<{}> = () => { data: opportunities, isValidating, size, setSize, }: CopilotOpportunitiesResponse = useCopilotOpportunities() - const tableData = useMemo(() => opportunities, [opportunities]) + const tableData = useMemo(() => opportunities.map(opportunity => ({ + ...opportunity, + type: ProjectTypeLabels[opportunity.projectType] ?? '', + })), [opportunities]) function loadMore(): void { setSize(size + 1) @@ -103,6 +118,7 @@ const CopilotOpportunityList: FC<{}> = () => { moreToLoad={isValidating || opportunities.length > 0} onLoadMoreClick={loadMore} onRowClick={handleRowClick} + removeDefaultSort /> {opportunitiesLoading && ( diff --git a/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss b/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss index 64dbfeba1..ab55fc55c 100644 --- a/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss +++ b/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss @@ -3,6 +3,8 @@ .skillsContainer { display: flex; flex-wrap: wrap; + overflow-x: auto; + overflow-y: hidden; gap: 8px; } @@ -26,4 +28,8 @@ .activeStatus { color: green; -} \ No newline at end of file +} + +.type { + white-space: nowrap; +} diff --git a/src/libs/ui/lib/components/table/Table.tsx b/src/libs/ui/lib/components/table/Table.tsx index 161d72d58..0b34849ac 100644 --- a/src/libs/ui/lib/components/table/Table.tsx +++ b/src/libs/ui/lib/components/table/Table.tsx @@ -102,6 +102,11 @@ const Table: (props: TableProps) = function toggleSort(fieldName: string): void { + const col = props.columns.find(c => c.propertyName === fieldName) + + // if sortable is false, we return + if (!col?.isSortable === false) return + // if we don't have anything to sort by, we shouldn't be here if (!sort && !props.removeDefaultSort) { return @@ -129,7 +134,7 @@ const Table: (props: TableProps) = const headerRow: Array = displayColumns .map((col, index) => { - const isSortable: boolean = !!col.propertyName + const isSortable: boolean = !!col.propertyName && col.isSortable !== false const isCurrentlySorted: boolean = isSortable && col.propertyName === sort?.fieldName const colorClass: string = isCurrentlySorted ? 'black-100' : 'black-60' const sortableClass: string | undefined = isSortable ? styles.sortable : undefined @@ -151,7 +156,7 @@ const Table: (props: TableProps) =
)} - {!props.disableSorting && ( + {!props.disableSorting && isSortable && ( { readonly isExpand?: boolean readonly colSpan?: number readonly type: TableCellType + readonly isSortable?: boolean } diff --git a/src/libs/ui/lib/components/table/table-functions/table.functions.ts b/src/libs/ui/lib/components/table/table-functions/table.functions.ts index 4aacef0d8..6c98b2857 100644 --- a/src/libs/ui/lib/components/table/table-functions/table.functions.ts +++ b/src/libs/ui/lib/components/table/table-functions/table.functions.ts @@ -53,11 +53,11 @@ export function getSorted( if (sortColumn.type === 'date') { return sortedData - .sort((a: T, b: T) => sortNumbers( - (a[sort.fieldName] as Date).getTime(), - (b[sort.fieldName] as Date).getTime(), - sort.direction, - )) + .sort((a: T, b: T) => { + const aDate = new Date(a[sort.fieldName]) + const bDate = new Date(b[sort.fieldName]) + return sortNumbers(aDate.getTime(), bDate.getTime(), sort.direction) + }) } return sortedData From e3a2cbe43803186611d9085bdc2c8b20193280f9 Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Thu, 24 Apr 2025 16:13:59 +0530 Subject: [PATCH 4/5] bot review fixes --- .../copilots/src/pages/copilot-opportunity-list/index.tsx | 2 +- .../src/pages/copilot-opportunity-list/styles.module.scss | 4 ++-- src/libs/ui/lib/components/table/Table.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx b/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx index 75da7d429..5fa24d0eb 100644 --- a/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx +++ b/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx @@ -22,7 +22,7 @@ const tableColumns: TableColumn[] = [ label: 'Title', propertyName: 'projectName', renderer: (copilotOpportunity: CopilotOpportunity) => ( -
+
{copilotOpportunity.projectName}
), diff --git a/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss b/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss index ab55fc55c..1d0738e9a 100644 --- a/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss +++ b/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss @@ -3,8 +3,8 @@ .skillsContainer { display: flex; flex-wrap: wrap; - overflow-x: auto; - overflow-y: hidden; + overflow: auto; + max-width: 300px; gap: 8px; } diff --git a/src/libs/ui/lib/components/table/Table.tsx b/src/libs/ui/lib/components/table/Table.tsx index 0b34849ac..af302b8b1 100644 --- a/src/libs/ui/lib/components/table/Table.tsx +++ b/src/libs/ui/lib/components/table/Table.tsx @@ -105,7 +105,7 @@ const Table: (props: TableProps) = const col = props.columns.find(c => c.propertyName === fieldName) // if sortable is false, we return - if (!col?.isSortable === false) return + if (col?.isSortable === false) return // if we don't have anything to sort by, we shouldn't be here if (!sort && !props.removeDefaultSort) { From 369f68ddaa15753e151241b524c526e7fe8f5765 Mon Sep 17 00:00:00 2001 From: himaniraghav3 Date: Fri, 25 Apr 2025 21:19:10 +0530 Subject: [PATCH 5/5] Fix skill pills --- src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx | 2 +- .../src/pages/copilot-opportunity-list/styles.module.scss | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx b/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx index 5fa24d0eb..9db5aa8bf 100644 --- a/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx +++ b/src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx @@ -74,7 +74,7 @@ const tableColumns: TableColumn[] = [ type: 'text', }, { - label: 'Hours per week needed', + label: 'Hours/Week', propertyName: 'numHoursPerWeek', type: 'number', }, diff --git a/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss b/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss index 1d0738e9a..c52c395ac 100644 --- a/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss +++ b/src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss @@ -4,7 +4,6 @@ display: flex; flex-wrap: wrap; overflow: auto; - max-width: 300px; gap: 8px; } @@ -13,7 +12,7 @@ color: #333; padding: 4px 8px; border-radius: 10px; - white-space: nowrap; + white-space: break-spaces; font-size: 14px; }