diff --git a/front_end/src/app/(main)/questions/[id]/components/sidebar/sidebar_question_info.tsx b/front_end/src/app/(main)/questions/[id]/components/sidebar/sidebar_question_info.tsx index 1e93059f59..3a5329d60a 100644 --- a/front_end/src/app/(main)/questions/[id]/components/sidebar/sidebar_question_info.tsx +++ b/front_end/src/app/(main)/questions/[id]/components/sidebar/sidebar_question_info.tsx @@ -13,6 +13,7 @@ const SidebarQuestionInfo: FC = ({ postData }) => { const locale = useLocale(); const t = useTranslations(); + const isUpcoming = new Date(postData.open_time).getTime() > Date.now(); return (
@@ -30,11 +31,13 @@ const SidebarQuestionInfo: FC = ({ postData }) => {
- {t("opened")}: + {t(isUpcoming ? "opens" : "opened")}: - {postData.published_at && - formatDate(locale, new Date(postData.published_at))} + {formatDate( + locale, + new Date(isUpcoming ? postData.open_time : postData.published_at) + )}
diff --git a/front_end/src/components/post_status/index.tsx b/front_end/src/components/post_status/index.tsx index 6a1dc28ef8..86c542b653 100644 --- a/front_end/src/components/post_status/index.tsx +++ b/front_end/src/components/post_status/index.tsx @@ -14,7 +14,7 @@ type Props = { const PostStatus: FC = ({ resolution, post }) => { const t = useTranslations(); const locale = useLocale(); - const { status, scheduled_close_time, scheduled_resolve_time } = post; + const { status, scheduled_close_time, scheduled_resolve_time, open_time } = post; const statusInfo = useMemo(() => { if (status === PostStatusEnum.CLOSED) { @@ -22,6 +22,14 @@ const PostStatus: FC = ({ resolution, post }) => { } if (status === PostStatusEnum.APPROVED) { + if (new Date(open_time).getTime() > Date.now()) { + return [ + t("opens"), + formatRelativeDate(locale, new Date(open_time), { + short: true, + }), + ]; + } return [ t("closes"), formatRelativeDate(locale, new Date(scheduled_close_time), {