Skip to content

Optional fields of Group interface not always checked for undefined/null before use #52

@tim-rohrer

Description

@tim-rohrer

Problem

The Group interface is defined as:

interface Group {
  _id: string
  name: string
  email?: string
  website?: string
  phone?: string
  notes?: string
}

There are multiple places in the codebase where optional properties of the Group interface (such as email, website, phone, notes) are used without explicit checks for undefined or null. This can lead to potential runtime errors or display of unintended values in the UI.

Example code usages

Some relevant usages include:

1. src/routes/group-info.tsx

  • Usage of groupInfo.email, groupInfo.notes, groupInfo.website in JSX render with conditional rendering, but some locations may not robustly check for null/undefined especially when passing values to nested components or functions.
  • View group-info.tsx

2. src/components/meetings/MeetingActions.tsx

  • Passing potentially undefined values for groupEmail and groupWebsite directly into EmailButton and WebsiteButton.
  • View MeetingActions.tsx

3. src/components/meetings/CalendarActions.tsx

  • Template string concatenation with optional fields, e.g. meeting.groupEmail, meeting.groupWebsite.
  • View CalendarActions.tsx

Suggested Solution

  • Audit all usages of Group optional properties throughout the codebase.
  • Add explicit checks for undefined or null before accessing or rendering these values.
  • Where appropriate, provide fallback text or omit sections in the UI if these values are not present.
  • Add TypeScript type guards or use optional chaining as needed.

References

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions