esolutionsone / timesheet-app

A button component for logging to and representing entries on a timesheet table
1 stars 1 forks source link

Fix: App breaks when no weekly entries #151

Closed blingusblongus closed 1 year ago

blingusblongus commented 1 year ago

Instead of checking first index at the leaf level, implement a pattern that filters at the level, and passes state down.

This avoids undefined issues when entries[0] doesn't exist, and reduces the number of checks we need to do to one.

blingusblongus commented 1 year ago

now checking from view level based on inDraftState = entries.filter(entry => entry.status !== 'draft') (checking whether any weekly entries are not drafts)