-
Notifications
You must be signed in to change notification settings - Fork 13
PM-590 Add start date #1047
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PM-590 Add start date #1047
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,20 @@ 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' | ||
|
||
const tableColumns: TableColumn<CopilotOpportunity>[] = [ | ||
{ | ||
label: 'Title', | ||
propertyName: 'projectName', | ||
type: 'text', | ||
renderer: (copilotOpportunity: CopilotOpportunity) => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SuggestionConsider using a more descriptive element or adding a class to the |
||
<div className={styles.title}> | ||
{copilotOpportunity.projectName} | ||
</div> | ||
), | ||
type: 'element', | ||
}, | ||
{ | ||
label: 'Status', | ||
|
@@ -33,6 +39,7 @@ const tableColumns: TableColumn<CopilotOpportunity>[] = [ | |
type: 'element', | ||
}, | ||
{ | ||
isSortable: false, | ||
label: 'Skills Required', | ||
propertyName: 'skills', | ||
renderer: (copilotOpportunity: CopilotOpportunity) => ( | ||
|
@@ -49,7 +56,12 @@ const tableColumns: TableColumn<CopilotOpportunity>[] = [ | |
{ | ||
label: 'Type', | ||
propertyName: 'type', | ||
type: 'text', | ||
renderer: (copilotOpportunity: CopilotOpportunity) => ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider handling cases where |
||
<div className={styles.type}> | ||
{ProjectTypeLabels[copilotOpportunity.projectType]} | ||
</div> | ||
), | ||
type: 'element', | ||
}, | ||
{ | ||
label: 'Starting Date', | ||
|
@@ -62,7 +74,7 @@ const tableColumns: TableColumn<CopilotOpportunity>[] = [ | |
type: 'text', | ||
}, | ||
{ | ||
label: 'Hours per week needed', | ||
label: 'Hours/Week', | ||
propertyName: 'numHoursPerWeek', | ||
type: 'number', | ||
}, | ||
|
@@ -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] ?? '', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider providing a default value or handling the case where |
||
})), [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 && ( | ||
<LoadingSpinner overlay /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
.skillsContainer { | ||
display: flex; | ||
flex-wrap: wrap; | ||
overflow: auto; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Combining |
||
gap: 8px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The removal of |
||
} | ||
|
||
|
@@ -11,7 +12,7 @@ | |
color: #333; | ||
padding: 4px 8px; | ||
border-radius: 10px; | ||
white-space: nowrap; | ||
white-space: break-spaces; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing |
||
font-size: 14px; | ||
} | ||
|
||
|
@@ -26,4 +27,8 @@ | |
|
||
.activeStatus { | ||
color: green; | ||
} | ||
} | ||
|
||
.type { | ||
white-space: nowrap; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,11 @@ const Table: <T extends { [propertyName: string]: any }>(props: TableProps<T>) = | |
|
||
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: <T extends { [propertyName: string]: any }>(props: TableProps<T>) = | |
|
||
const headerRow: Array<JSX.Element> = displayColumns | ||
.map((col, index) => { | ||
const isSortable: boolean = !!col.propertyName | ||
const isSortable: boolean = !!col.propertyName && col.isSortable !== false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The condition |
||
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: <T extends { [propertyName: string]: any }>(props: TableProps<T>) = | |
</Tooltip> | ||
</div> | ||
)} | ||
{!props.disableSorting && ( | ||
{!props.disableSorting && isSortable && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The addition of |
||
<TableSort | ||
iconClass={colorClass} | ||
isCurrentlySorted={isCurrentlySorted} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,11 +53,11 @@ export function getSorted<T extends { [propertyName: string]: any }>( | |
|
||
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]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding error handling for invalid date strings. Using |
||
const bDate = new Date(b[sort.fieldName]) | ||
return sortNumbers(aDate.getTime(), bDate.getTime(), sort.direction) | ||
}) | ||
} | ||
|
||
return sortedData | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a fallback or default value for
opportunity?.startDate
in case it is undefined or null to prevent potential runtime errors.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@himaniraghav3 checked this - looks like moment will intialize with current datetime in case of undefined startDate.
We fine with that?