@nexusui/components
Version:
These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.
2 lines (1 loc) • 661 B
JavaScript
import t from"lodash/groupBy";import{useMemo as e}from"react";const r=(r,o)=>({groupedNotifications:e((()=>(t=>(Object.keys(t).forEach((e=>{const r=t[e].reduce(((t,e)=>{const{productName:r,user:o,status:a}=e,n=o?`${r}-user`:"error"===a||"warning"===a?`${r}-critical`:`${r}-noncritical`;return t[n]?t[n].nestedNotifications.push(e):t[n]={...e,nestedNotifications:[]},t}),{});t[e]=Object.values(r)})),t))(t(r,(t=>{const e=new Date(t.createTime),r=new Date,a=new Date(r);return a.setDate(a.getDate()-1),e.toDateString()===r.toDateString()?o("today"):e.toDateString()===a.toDateString()?o("yesterday"):o("older")})))),[r,o])});export{r as useGroupedNotifications};