Skip to content

[PROD RELEASE] - profile app & fixes#1494

Open
kkartunov wants to merge 20 commits intomasterfrom
dev
Open

[PROD RELEASE] - profile app & fixes#1494
kkartunov wants to merge 20 commits intomasterfrom
dev

Conversation

@kkartunov
Copy link
Collaborator

@kkartunov kkartunov commented Feb 26, 2026

@kkartunov kkartunov requested a review from jmgasper as a code owner February 26, 2026 06:55

const canEdit: boolean = props.authProfile?.handle === props.profile.handle

const { profile }: ProfileContextData = useContext(profileContext)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The useContext hook is used to access profileContext, but there is no check to ensure that profile is defined before accessing its properties. This could lead to runtime errors if profile is undefined. Consider adding a null check or default value.


const canSeeDetailedAddressIcon = canEdit || isAdminOrTM

const tooltipContent = useMemo(() => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The tooltipContent is conditionally rendered based on hasDetailedAddress, but it is possible for address to be undefined, which would cause trim to throw an error. Ensure that address is defined before attempting to access its properties.

[countryLookup],
)

const existingAddress = props.profile.addresses ? props.profile.addresses[0] : {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Consider using optional chaining (props.profile.addresses?.[0]) to access the first address. This can prevent potential runtime errors if addresses is undefined.


const existingAddress = props.profile.addresses ? props.profile.addresses[0] : {}

const [formValues, setFormValues]: [any, Dispatch<any>] = useState({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
The formValues state is initialized with any type. Consider defining a specific type for formValues to improve type safety and maintainability.

const [isFormChanged, setIsFormChanged]: [boolean, Dispatch<SetStateAction<boolean>>]
= useState<boolean>(false)
const handleFormValueChange = useCallback(
(key: string) => (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>): void => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The handleFormValueChange function uses formValues from the outer scope, which can lead to stale state issues. Consider using a functional state update to ensure the latest state is used.

...props.profile.addresses ? omit(props.profile.addresses[0], OMIT_ADDRESS_KEYS_ON_UPDATE) : {},
if (!validate()) return

setIsSaving(true)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The setIsSaving(true) call should be placed after the validate() check to avoid setting the saving state unnecessarily when validation fails.

toast.success('Your location has been updated.', { position: toast.POSITION.BOTTOM_RIGHT })
props.onSave()
})
.catch((error: any) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 maintainability]
Consider handling specific error types in the catch block to provide more informative error messages to the user.

.catch(() => {
toast.error('Failed to update phone numbers.', { position: toast.POSITION.BOTTOM_RIGHT })
.catch(error => {
const apiMessage

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The variable apiMessage is declared without an initializer. This could lead to a ReferenceError if error?.message is undefined. Consider initializing apiMessage directly with the conditional expression.

), [memberStats, props.profile, tcoQualifications, tcoTrips, tcoWins])

if (!memberStats?.challenges && !tcoWins && !tcoQualifications) {
if (!memberStats?.challenges && !tcoWins && !tcoQualifications && !memberBadges?.rows.length) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The condition !memberBadges?.rows.length assumes memberBadges is defined. If memberBadges is undefined, this will throw an error. Consider using !memberBadges || !memberBadges.rows.length to safely handle cases where memberBadges might be undefined.

fix(PM-4004, PM-4005): Fix tools page in account settings
type='text'
error={formErrors.serviceProviderName}
dirty
forceUpdateValue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The forceUpdateValue prop is added to the InputText component, but it's unclear what its purpose is without additional context. Ensure that this prop is necessary and correctly implemented in the InputText component to avoid unexpected behavior.

name='softwareName'
label='Software Name *'
value={selectedSoftwareName}
forceUpdateValue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The forceUpdateValue prop is being added to the InputText component. Ensure that this prop is necessary and correctly handled within the InputText component. If this prop is not defined or used within InputText, it could lead to unexpected behavior.

type='text'
error={formErrors.subscriptionName}
dirty
forceUpdateValue

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The forceUpdateValue prop is added to the InputText component. Ensure that this prop is necessary and correctly implemented in the InputText component. If it is not handled properly, it could lead to unexpected behavior or performance issues.

}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isLoading])
}, [isLoading, props.open])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
Adding props.open to the dependency array of useCallback can lead to unnecessary re-creations of the handleClose function if props.open changes frequently. Consider whether props.open is necessary for the logic inside handleClose, and if not, it might be better to remove it from the dependencies to avoid potential performance issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants