Skip to content

Fix null handling for localToDate in TreeMapper Export component #2596

@coderabbitai

Description

@coderabbitai

Problem

The localToDate state variable in src/features/user/TreeMapper/Analytics/components/Export/index.tsx was changed from Date to Date | null but the code doesn't handle null values properly.

Issues to address

  1. Filename formatting: The saveAs function uses format(localToDate, 'dd-MMM-yy') which will throw an error if localToDate is null
  2. API request body: The export request body includes endDate: localToDate which may need null handling depending on API requirements

Suggested fixes

  1. Add conditional check before formatting: localToDate ? format(localToDate, 'dd-MMM-yy') : 'no-date'
  2. Handle null values in API request body appropriately

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions