-
Notifications
You must be signed in to change notification settings - Fork 13
[PROD RELEASE] - Reduce complexity #1027
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
base: master
Are you sure you want to change the base?
Conversation
…loyment-docs PM-462 - update urls
PM-505 Fix default values on onboarding form
PM-505 Fix QA feedback
PM-553: fix breadcrumb url
PM-579 Add copilot request UI
PM-579 Change Restricted route logic
PM-579 Make buttons in form responsive
PM-579 QR feedback on copilot request form
V5 challenge management
|
||
const onApplied: () => void = useCallback(() => { | ||
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}/applications`) | ||
mutate(`${copilotBaseUrl}/copilots/opportunity/${opportunityId}`) |
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 error handling for the mutate
function to ensure that any issues during the mutation process are properly managed. This will help in maintaining the robustness of the application.
isCopilot | ||
&& copilotApplications | ||
&& copilotApplications.length === 0 | ||
&& opportunity?.status === 'active' ? applyCopilotOpportunityButton : undefined |
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 using optional chaining (?.
) for opportunity?.status
to avoid potential runtime errors if opportunity
is undefined.
&& copilotApplications.length === 0 | ||
&& opportunity?.status === 'active' ? applyCopilotOpportunityButton : undefined | ||
} | ||
infoComponent={(isCopilot && !(copilotApplications |
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.
The condition for infoComponent
is complex and could benefit from being extracted into a well-named variable or function to improve readability.
<span | ||
className={styles.appliedText} | ||
> | ||
{`Applied on ${textFormatDateLocaleShortString(new Date(application.createdAt))}`} |
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.
Ensure that textFormatDateLocaleShortString
handles invalid dates gracefully, as application.createdAt
might not always be a valid date string.
|
||
.textCaps { | ||
text-transform: capitalize; | ||
} |
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.
It is recommended to ensure that files end with a newline character to avoid potential issues with some tools and systems that expect a newline at the end of files.
* @param request | ||
* @returns | ||
*/ | ||
export const applyCopilotOpportunity = async (opportunityId: number, request?: { |
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.
The request
parameter is now optional, but the function implementation does not handle the case where request
might be undefined
. Consider adding a check to handle this scenario to avoid potential runtime errors.
@@ -54,7 +54,6 @@ | |||
|
|||
.react-responsive-modal-closeButton { | |||
top: $sp-5; | |||
padding: $sp-1; | |||
border-radius: 50%; |
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.
Removing the padding from the .react-responsive-modal-closeButton
might affect the button's click area and visual appearance. Consider verifying the impact on usability and design consistency across different screen sizes and devices.
feat(PM-580): added assign action to applications list
opportunityId: string, | ||
handle?: string, | ||
userId: number, | ||
status: CopilotApplicationStatus, |
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 default value for the status
property to ensure that all instances of CopilotApplication
have a defined status. This can help prevent potential issues where the status might be unintentionally left undefined.
import styles from './styles.module.scss' | ||
|
||
const CopilotApplicationAction = (copilotApplication: CopilotApplication): JSX.Element => { | ||
const { opportunityId }: {opportunityId?: string} = useParams<{ opportunityId?: string }>() |
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 PropTypes or TypeScript interfaces to ensure that the copilotApplication
prop is validated and has the expected shape.
} | ||
}, [opportunityId, copilotApplication]) | ||
return ( | ||
<div onClick={onClick} className={styles.actionWrapper}> |
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.
Using onClick
on a div
can be problematic for accessibility. Consider using a button
element or adding appropriate ARIA roles and keyboard event handlers to ensure the component is accessible.
}, | ||
{ | ||
label: 'Actions', | ||
propertyName: '', |
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.
The propertyName
is currently an empty string. If this is intentional, consider adding a brief explanation in the documentation or code comments to clarify its purpose. If not, ensure that the correct property name is provided.
* @returns | ||
*/ | ||
export const assignCopilotOpportunity = async ( | ||
opportunityId: string, |
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 using consistent parameter types for opportunityId
across functions. In applyCopilotOpportunity
, opportunityId
is a number
, while in assignCopilotOpportunity
, it is a string
. This inconsistency may lead to confusion or errors.
fix(PM-580): dont show action button when invite is inprogress
|
||
const CopilotApplicationAction = ( | ||
copilotApplication: CopilotApplication, | ||
allCopilotApplications: CopilotApplication[], |
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 renaming allCopilotApplications
to copilotApplications
for consistency and clarity, as the prefix 'all' might be redundant.
): JSX.Element => { | ||
const { opportunityId }: {opportunityId?: string} = useParams<{ opportunityId?: string }>() | ||
const isInvited = useMemo( | ||
() => allCopilotApplications.findIndex(item => item.status === CopilotApplicationStatus.INVITED) > -1, |
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.
The use of findIndex
here is to check for the existence of an invited application. Consider using some
instead for better readability: allCopilotApplications.some(item => item.status === CopilotApplicationStatus.INVITED)
.
} | ||
|
||
{ | ||
!isInvited && copilotApplication.status === CopilotApplicationStatus.PENDING && ( |
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 check to ensure isInvited
is defined and of the expected type before using it in the condition. This can help prevent potential runtime errors if isInvited
is undefined or not a boolean.
<TableRow | ||
key={getKey(index)} | ||
data={sorted} | ||
allRows={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 renaming allRows
to a more descriptive name that indicates its purpose or contents, as sortedData
is already used and might cause confusion.
@@ -11,63 +15,97 @@ interface TableCellProps<T> { | |||
readonly data: T | |||
readonly index: number | |||
readonly propertyName?: string | |||
readonly renderer?: (data: T) => JSX.Element | undefined | |||
readonly className?: string | |||
readonly renderer?: (data: T, allRows?: ReadonlyArray<T>) => JSX.Element | undefined |
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.
The renderer
function signature has been updated to include an optional allRows
parameter. Ensure that all implementations of this function are updated accordingly to handle this new parameter, even if it's not used.
readonly showExpandIndicator?: boolean | ||
readonly isExpanded?: boolean | ||
readonly colSpan?: number | ||
allRows?: ReadonlyArray<T> |
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.
The allRows
property has been added to the TableCellProps
interface. Verify that this property is correctly passed and utilized in the component logic where necessary.
case 'action': | ||
case 'element': | ||
case 'numberElement': | ||
data = props.renderer?.(props.data, props.allRows) |
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.
The renderer
function now takes an additional argument props.allRows
. Ensure that all implementations of renderer
are updated to handle this new parameter appropriately, and verify that it does not introduce any unintended side effects.
{...col} | ||
data={props.data} | ||
index={props.index} | ||
allRows={props.allRows} |
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 verifying if allRows
is necessary for the component's functionality. If it is not used within the component, it might be better to remove it to reduce complexity.
fix(PM-580): return if already invited
[allCopilotApplications], | ||
) | ||
const onClick = useCallback(async () => { | ||
if (copilotApplication.status !== CopilotApplicationStatus.PENDING || isInvited) { |
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.
The condition copilotApplication.status !== CopilotApplicationStatus.PENDING || isInvited
may cause the function to return early if isInvited
is true, regardless of the copilotApplication.status
. Ensure this logic aligns with the intended behavior, as it changes the original condition which only checked copilotApplication.status
. Consider if additional checks or restructuring are needed to maintain the desired functionality.
fix(PM-580): show invite button only for active projects
) | ||
} | ||
{activeTab === CopilotDetailsTabViews.details && <OpportunityDetails opportunity={opportunity} />} | ||
{activeTab === CopilotDetailsTabViews.applications && isAdminOrPM && opportunity && ( |
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 checking if opportunity
is defined earlier in the logic to avoid repeating this check in multiple places. This could help reduce complexity and improve readability.
if ( | ||
copilotApplication.status !== CopilotApplicationStatus.PENDING | ||
|| isInvited | ||
|| copilotApplication.opportunityStatus !== 'active' |
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 using a constant or enum for the string 'active'
to avoid magic strings and improve maintainability.
Includes work on: