Skip to content

Commit

Permalink
Disable the pre-sales chat on the Cloud pricing page for the Holidays. (
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottprogrammer authored Dec 23, 2022
1 parent 517f22a commit d581895
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,28 @@ const isWithinAvailableChatDays = ( currentTime: Date ) => {
return utcWeekDay !== SUNDAY && utcWeekDay !== SATURDAY;
};

const isWithinShutdownDates = ( currentTime: Date ) => {
const startTime = new Date( Date.UTC( 2022, 11, 23 ) ); // Thu Dec 22 2022 19:00:00 (7:00pm) GMT-0500 (Eastern Standard Time)
const endTime = new Date( Date.UTC( 2023, 0, 2 ) ); // Sun Jan 01 2023 19:00:00 (7:00pm) GMT-0500 (Eastern Standard Time)
const currentDateUTC = new Date( currentTime.toUTCString() );
if ( currentDateUTC > startTime && currentDateUTC < endTime ) {
return true;
}
return false;
};

export const ZendeskPreSalesChat: React.VFC = () => {
const zendeskChatKey = config( 'zendesk_presales_chat_key' ) as keyof ConfigData;
const isLoggedIn = useSelector( isUserLoggedIn );

const shouldShowZendeskPresalesChat = useMemo( () => {
const currentTime = new Date();
if ( isWithinShutdownDates( currentTime ) ) {
return false;
}
const isEnglishLocale = ( config( 'english_locales' ) as string[] ).includes(
getLocaleSlug() ?? ''
);
const currentTime = new Date();

return config.isEnabled( 'jetpack/zendesk-chat-for-logged-in-users' )
? isEnglishLocale && isJetpackCloud() && isWithinAvailableChatDays( currentTime )
Expand Down

0 comments on commit d581895

Please sign in to comment.