@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) • 804 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/groupBy"),t=require("react");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(e);exports.useGroupedNotifications=(e,r)=>({groupedNotifications:t.useMemo((()=>(e=>(Object.keys(e).forEach((t=>{const r=e[t].reduce(((e,t)=>{const{productName:r,user:o,status:a}=t,i=o?`${r}-user`:"error"===a||"warning"===a?`${r}-critical`:`${r}-noncritical`;return e[i]?e[i].nestedNotifications.push(t):e[i]={...t,nestedNotifications:[]},e}),{});e[t]=Object.values(r)})),e))(o.default(e,(e=>{const t=new Date(e.createTime),o=new Date,a=new Date(o);return a.setDate(a.getDate()-1),t.toDateString()===o.toDateString()?r("today"):t.toDateString()===a.toDateString()?r("yesterday"):r("older")})))),[e,r])});