From a95eaa5c46ccb44913ab59b11b9ff0b238d683c8 Mon Sep 17 00:00:00 2001 From: "Japheth Louie M. Gofredo" <83058948+japhethLG@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:55:04 +0800 Subject: [PATCH] fix: Announcement is not reflecting the latest announcement (#2477) # Description Add a sort logic for product announcements. Remove "Good Night" when the user logs in at night. Fixes #2476 [#250](https://github.com/zesty-io/accounts-ui/issues/250) ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) # How Has This Been Tested? - [x] Manual Test # Screenshots / Screen recording Please add screenshots or recording if applicable Before: ![image](https://github.com/user-attachments/assets/ca977a94-786b-4219-9522-4ecddbbac870) After: ![image](https://github.com/user-attachments/assets/a76aeac6-8961-4e56-9b16-bba34f2a968a) --- .../accounts/dashboard/ui/ZInstancesContainer.js | 6 ++---- src/pages/login/index.js | 10 +++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/accounts/dashboard/ui/ZInstancesContainer.js b/src/components/accounts/dashboard/ui/ZInstancesContainer.js index 48f358685..63ec39ff3 100644 --- a/src/components/accounts/dashboard/ui/ZInstancesContainer.js +++ b/src/components/accounts/dashboard/ui/ZInstancesContainer.js @@ -12,11 +12,9 @@ const ZInstancesContainer = ({ }) => { const dayTime = () => { const hour = new Date().getHours(); - if (hour >= 5 && hour <= 12) return 'Good Morning, '; + if (hour >= 0 && hour <= 12) return 'Good Morning, '; else if (hour > 12 && hour <= 17) return 'Good Afternoon, '; - else if (hour > 17 && hour <= 21) return 'Good Evening, '; - else if ((hour > 21 && hour <= 23) || (hour >= 0 && hour <= 4)) - return 'Good Night, '; + else if (hour > 17 && hour <= 23) return 'Good Evening, '; }; return ( <> diff --git a/src/pages/login/index.js b/src/pages/login/index.js index 365518cd2..62d5cab91 100644 --- a/src/pages/login/index.js +++ b/src/pages/login/index.js @@ -15,7 +15,15 @@ const site = 'https://www.zesty.io'; const Login = (props) => { const router = useRouter(); - const content = props.data.data[0].content; + const content = + props.data.data + .sort( + (a, b) => + new Date(b.content.start_date_and_time) - + new Date(a.content.start_date_and_time), + ) + .map((item) => item.content)[0] || null; + const loginContent = props.loginData.data[0].content; const ogimage = content?.feature_image?.data[0]?.url;