Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d9d34af

Browse files
authoredApr 25, 2025
Merge pull request #1047 from topcoder-platform/PM-590-fixes
PM-590 Add start date
2 parents 72c5744 + 369f68d commit d9d34af

File tree

9 files changed

+57
-17
lines changed

9 files changed

+57
-17
lines changed
 

‎src/apps/admin/src/lib/models/MobileTableColumn.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
import { TableColumn } from '~/libs/ui'
55

66
export interface MobileTableColumn<T> extends TableColumn<T> {
7-
readonly mobileType?: 'label'
7+
readonly mobileType?: 'label' | 'last-value'
88
}

‎src/apps/copilots/src/copilots.routes.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,19 @@ export const childRoutes = [
2323
route: '/',
2424
},
2525
{
26+
authRequired: true,
2627
element: <CopilotsRequests />,
2728
id: 'CopilotRequests',
2829
route: '/requests',
2930
},
3031
{
32+
authRequired: true,
3133
element: <CopilotsRequestForm />,
3234
id: 'CopilotRequestForm',
3335
route: '/requests/new',
3436
},
3537
{
38+
authRequired: true,
3639
element: <CopilotsRequests />,
3740
id: 'CopilotRequestDetails',
3841
route: '/requests/:requestId',
@@ -54,10 +57,8 @@ export const copilotRoutesMap = childRoutes.reduce((allRoutes, route) => (
5457

5558
export const copilotsRoutes: ReadonlyArray<PlatformRoute> = [
5659
{
57-
authRequired: true,
5860
children: [
5961
...childRoutes,
60-
6162
],
6263
domain: AppSubdomain.copilots,
6364
element: <CopilotsApp />,

‎src/apps/copilots/src/pages/copilot-opportunity-details/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { FC, useEffect, useState } from 'react'
22
import { useNavigate, useParams } from 'react-router-dom'
3+
import moment from 'moment'
34

45
import {
56
ContentLayout,
@@ -60,6 +61,17 @@ const CopilotOpportunityDetails: FC<{}> = () => {
6061
<span className={styles.infoValue}>{opportunity?.status}</span>
6162
</div>
6263
</div>
64+
<div className={styles.infoColumn}>
65+
<IconOutline.PlayIcon className={styles.icon} />
66+
<div className={styles.infoText}>
67+
<span className={styles.infoHeading}>Start Date</span>
68+
<span className={styles.infoValue}>
69+
{moment(opportunity?.startDate)
70+
.format('MMM D, YYYY')}
71+
72+
</span>
73+
</div>
74+
</div>
6375
<div className={styles.infoColumn}>
6476
<IconOutline.CalendarIcon className={styles.icon} />
6577
<div className={styles.infoText}>

‎src/apps/copilots/src/pages/copilot-opportunity-list/index.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,20 @@ import {
1313
import { CopilotOpportunity } from '../../models/CopilotOpportunity'
1414
import { copilotRoutesMap } from '../../copilots.routes'
1515
import { CopilotOpportunitiesResponse, useCopilotOpportunities } from '../../services/copilot-opportunities'
16+
import { ProjectTypeLabels } from '../../constants'
1617

1718
import styles from './styles.module.scss'
1819

1920
const tableColumns: TableColumn<CopilotOpportunity>[] = [
2021
{
2122
label: 'Title',
2223
propertyName: 'projectName',
23-
type: 'text',
24+
renderer: (copilotOpportunity: CopilotOpportunity) => (
25+
<div className={styles.title}>
26+
{copilotOpportunity.projectName}
27+
</div>
28+
),
29+
type: 'element',
2430
},
2531
{
2632
label: 'Status',
@@ -33,6 +39,7 @@ const tableColumns: TableColumn<CopilotOpportunity>[] = [
3339
type: 'element',
3440
},
3541
{
42+
isSortable: false,
3643
label: 'Skills Required',
3744
propertyName: 'skills',
3845
renderer: (copilotOpportunity: CopilotOpportunity) => (
@@ -49,7 +56,12 @@ const tableColumns: TableColumn<CopilotOpportunity>[] = [
4956
{
5057
label: 'Type',
5158
propertyName: 'type',
52-
type: 'text',
59+
renderer: (copilotOpportunity: CopilotOpportunity) => (
60+
<div className={styles.type}>
61+
{ProjectTypeLabels[copilotOpportunity.projectType]}
62+
</div>
63+
),
64+
type: 'element',
5365
},
5466
{
5567
label: 'Starting Date',
@@ -62,7 +74,7 @@ const tableColumns: TableColumn<CopilotOpportunity>[] = [
6274
type: 'text',
6375
},
6476
{
65-
label: 'Hours per week needed',
77+
label: 'Hours/Week',
6678
propertyName: 'numHoursPerWeek',
6779
type: 'number',
6880
},
@@ -80,7 +92,10 @@ const CopilotOpportunityList: FC<{}> = () => {
8092
data: opportunities, isValidating, size, setSize,
8193
}: CopilotOpportunitiesResponse = useCopilotOpportunities()
8294

83-
const tableData = useMemo(() => opportunities, [opportunities])
95+
const tableData = useMemo(() => opportunities.map(opportunity => ({
96+
...opportunity,
97+
type: ProjectTypeLabels[opportunity.projectType] ?? '',
98+
})), [opportunities])
8499

85100
function loadMore(): void {
86101
setSize(size + 1)
@@ -103,6 +118,7 @@ const CopilotOpportunityList: FC<{}> = () => {
103118
moreToLoad={isValidating || opportunities.length > 0}
104119
onLoadMoreClick={loadMore}
105120
onRowClick={handleRowClick}
121+
removeDefaultSort
106122
/>
107123
{opportunitiesLoading && (
108124
<LoadingSpinner overlay />

‎src/apps/copilots/src/pages/copilot-opportunity-list/styles.module.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.skillsContainer {
44
display: flex;
55
flex-wrap: wrap;
6+
overflow: auto;
67
gap: 8px;
78
}
89

@@ -11,7 +12,7 @@
1112
color: #333;
1213
padding: 4px 8px;
1314
border-radius: 10px;
14-
white-space: nowrap;
15+
white-space: break-spaces;
1516
font-size: 14px;
1617
}
1718

@@ -26,4 +27,8 @@
2627

2728
.activeStatus {
2829
color: green;
29-
}
30+
}
31+
32+
.type {
33+
white-space: nowrap;
34+
}

‎src/apps/copilots/src/services/copilot-opportunities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export type CopilotOpportunityResponse = SWRResponse<CopilotOpportunity, Copilot
7171
* @returns {CopilotOpportunityResponse} - The response containing the copilot request data.
7272
*/
7373
export const useCopilotOpportunity = (opportunityId?: string): CopilotOpportunityResponse => {
74-
const url = opportunityId ? buildUrl(`${baseUrl}/copilots/opportunities/${opportunityId}`) : undefined
74+
const url = opportunityId ? buildUrl(`${baseUrl}/copilot/opportunity/${opportunityId}`) : undefined
7575

7676
const fetcher = (urlp: string): Promise<CopilotOpportunity> => xhrGetAsync<CopilotOpportunity>(urlp)
7777
.then(copilotOpportunityFactory)

‎src/libs/ui/lib/components/table/Table.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ const Table: <T extends { [propertyName: string]: any }>(props: TableProps<T>) =
102102

103103
function toggleSort(fieldName: string): void {
104104

105+
const col = props.columns.find(c => c.propertyName === fieldName)
106+
107+
// if sortable is false, we return
108+
if (col?.isSortable === false) return
109+
105110
// if we don't have anything to sort by, we shouldn't be here
106111
if (!sort && !props.removeDefaultSort) {
107112
return
@@ -129,7 +134,7 @@ const Table: <T extends { [propertyName: string]: any }>(props: TableProps<T>) =
129134

130135
const headerRow: Array<JSX.Element> = displayColumns
131136
.map((col, index) => {
132-
const isSortable: boolean = !!col.propertyName
137+
const isSortable: boolean = !!col.propertyName && col.isSortable !== false
133138
const isCurrentlySorted: boolean = isSortable && col.propertyName === sort?.fieldName
134139
const colorClass: string = isCurrentlySorted ? 'black-100' : 'black-60'
135140
const sortableClass: string | undefined = isSortable ? styles.sortable : undefined
@@ -151,7 +156,7 @@ const Table: <T extends { [propertyName: string]: any }>(props: TableProps<T>) =
151156
</Tooltip>
152157
</div>
153158
)}
154-
{!props.disableSorting && (
159+
{!props.disableSorting && isSortable && (
155160
<TableSort
156161
iconClass={colorClass}
157162
isCurrentlySorted={isCurrentlySorted}

‎src/libs/ui/lib/components/table/table-column.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ export interface TableColumn<T> {
1111
readonly isExpand?: boolean
1212
readonly colSpan?: number
1313
readonly type: TableCellType
14+
readonly isSortable?: boolean
1415
}

‎src/libs/ui/lib/components/table/table-functions/table.functions.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ export function getSorted<T extends { [propertyName: string]: any }>(
5353

5454
if (sortColumn.type === 'date') {
5555
return sortedData
56-
.sort((a: T, b: T) => sortNumbers(
57-
(a[sort.fieldName] as Date).getTime(),
58-
(b[sort.fieldName] as Date).getTime(),
59-
sort.direction,
60-
))
56+
.sort((a: T, b: T) => {
57+
const aDate = new Date(a[sort.fieldName])
58+
const bDate = new Date(b[sort.fieldName])
59+
return sortNumbers(aDate.getTime(), bDate.getTime(), sort.direction)
60+
})
6161
}
6262

6363
return sortedData

0 commit comments

Comments
 (0)
Please sign in to comment.