alltrust / Reminder-App

Set reminders based importance. Search & filter through passed reminders
0 stars 0 forks source link

Reminder Refactoring #6

Closed sebastianserrano closed 2 years ago

sebastianserrano commented 2 years ago

User a more modular approach for:

https://github.com/alltrust/Reminder-App/blob/628a2d8c14e37277dc36ce95243ad413ef014cd7/src/components/LegendForReminders/LegendReminders.js#L23

  const isLowPriority = (reminder) => reminder.priority === "low" ||  reminder.priority === ""
  const isMidPriority = (reminder) => reminder.priority === "medium"
  const isHighPriority = (reminder) => reminder.priority === "high"

  const isReminderCompleted = (reminder) => reminder.completionStatus === false

  const lowPriorities = reminderData.map((reminder) => isLowPriority(reminder) && isReminderCompleted(reminder))
  const moderatePriorities = reminderData.map((reminder) => isMidPriority(reminder) && isReminderCompleted(reminder))
  const highPriorities = reminderData.map((reminder) => isHighPriority(reminder) && isReminderCompleted(reminder))

Notes

  1. The reminder is said to be done when the completionStatus is false? Thats a bit confusing if thats correct. Why not something more descriptive like completed. If you want to use a boolean then rename it to something like isCompleted
alltrust commented 2 years ago

The reminder is said to be done when the completionStatus is true.

sebastianserrano commented 2 years ago

Check my other comment regarding completionStatus.

Also, you can refactor what I wrote even further to have fewer lines