From 5996a49ee14f9fc92e4238587063a1712045cc7e Mon Sep 17 00:00:00 2001 From: hyrious Date: Mon, 19 Feb 2024 10:09:57 +0800 Subject: [PATCH] style(flat-components): update status text and join button - show "running" status by time instead of the actual status - show "join" instead of "start" room button - trivial style updates to invite modal and schedule room page --- .../EditRoomPage/EditRoomBody/index.tsx | 10 ++-- .../src/components/InviteModal/index.less | 3 +- .../src/components/InviteModal/index.tsx | 6 +- .../RoomDetailPage/RoomDetailFooter/index.tsx | 2 +- .../components/RoomStatusElement/index.tsx | 28 +++++---- packages/flat-i18n/locales/en.json | 1 + packages/flat-i18n/locales/zh-CN.json | 1 + .../MainRoomListPanel/MainRoomList.tsx | 59 ++++--------------- 8 files changed, 43 insertions(+), 67 deletions(-) diff --git a/packages/flat-components/src/components/EditRoomPage/EditRoomBody/index.tsx b/packages/flat-components/src/components/EditRoomPage/EditRoomBody/index.tsx index fb2bf292fed..5a800c154bb 100644 --- a/packages/flat-components/src/components/EditRoomPage/EditRoomBody/index.tsx +++ b/packages/flat-components/src/components/EditRoomPage/EditRoomBody/index.tsx @@ -96,7 +96,7 @@ export const EditRoomBody: React.FC = ({ const [isShowEditSubmitConfirm, showEditSubmitConfirm] = useState(false); const [isPeriodic, setIsPeriodic] = useState(false); - const showPmi = useMemo(() => !!pmi && !isPeriodic, [isPeriodic, pmi]); + const enablePmi = useMemo(() => !!pmi && !isPeriodic, [isPeriodic, pmi]); // @TODO: need to remove const [region] = useState(initialValues.region); @@ -172,16 +172,16 @@ export const EditRoomBody: React.FC = ({ nextPeriodicRoomEndTime, )} {renderEndTimePicker(t, form, nextPeriodicRoomEndTime)} - {showPmi && updateAutoPmiOn && ( + {updateAutoPmiOn && ( -
+
updateAutoPmiOn(!autoPmiOn)} > = ({ ? onlySuffixTimeFormat(endTime) : completeTimeFormat(endTime); - return `${formatBeginTime}~${formatEndTime}`; + return `${formatBeginTime} ~ ${formatEndTime}`; }, [beginTime, endTime]); const onCopyClicked = (): void => { @@ -97,7 +97,7 @@ export const InviteModal: React.FC = ({
{t("room-uuid")} - {formatInviteCode(uuid, inviteCode)} + {formatInviteCode(uuid, inviteCode)}
{formattedTimeRange && (
@@ -107,7 +107,7 @@ export const InviteModal: React.FC = ({ )}
{t("join-link")} - {joinLink} + {joinLink}
diff --git a/packages/flat-components/src/components/RoomDetailPage/RoomDetailFooter/index.tsx b/packages/flat-components/src/components/RoomDetailPage/RoomDetailFooter/index.tsx index e60e6ac1b1b..3924181b347 100644 --- a/packages/flat-components/src/components/RoomDetailPage/RoomDetailFooter/index.tsx +++ b/packages/flat-components/src/components/RoomDetailPage/RoomDetailFooter/index.tsx @@ -87,7 +87,7 @@ export const RoomDetailFooter = /* @__PURE__ */ observer( {t("invitation")} = { + running: "started", + stopped: "stopped", + upcoming: "idle", +}; + export const RoomStatusElement: React.FC = ({ room }) => { const t = useTranslate(); - switch (room.roomStatus) { - case RoomStatus.Started: - case RoomStatus.Paused: { - return {t("room-status.running")}; - } - case RoomStatus.Stopped: { - return {t("room-status.stopped")}; - } - default: { - return {t("room-status.upcoming")}; - } + + const now = Date.now(); + let status: "running" | "stopped" | "upcoming"; + if (room.beginTime && now < room.beginTime) { + status = "upcoming"; + } else if (room.roomStatus === RoomStatus.Stopped || (room.endTime && now > room.endTime)) { + status = "stopped"; + } else { + status = "running"; } + + return {t("room-status." + status)}; }; diff --git a/packages/flat-i18n/locales/en.json b/packages/flat-i18n/locales/en.json index 7a6647c4fa3..6940da6616d 100644 --- a/packages/flat-i18n/locales/en.json +++ b/packages/flat-i18n/locales/en.json @@ -323,6 +323,7 @@ "periodic-rooms-do-not-exist": "Periodic room does not exist", "periodic-rooms-have-ended": "Periodic room has ended", "periodic-sub-rooms-do-not-exist": "Periodic sub-room does not exist", + "periodic-cannot-use-pmi": "Periodic room cannot use PMI", "replay-does-not-exist": "Replay does not exist", "request-error": "Request error", "request-failed": "Request failed", diff --git a/packages/flat-i18n/locales/zh-CN.json b/packages/flat-i18n/locales/zh-CN.json index 8b7fa8d57c0..7d9c8d56252 100644 --- a/packages/flat-i18n/locales/zh-CN.json +++ b/packages/flat-i18n/locales/zh-CN.json @@ -333,6 +333,7 @@ "periodic-rooms-do-not-exist": "周期性房间不存在", "periodic-rooms-have-ended": "周期性房间已结束", "periodic-sub-rooms-do-not-exist": "周期性子房间不存在", + "periodic-cannot-use-pmi": "周期性房间不能使用个人房间号", "user-does-not-exist": "用户不存在", "user-room-list-is-not-empty": "用户房间列表不为空", "user-already-binding": "用户已绑定", diff --git a/packages/flat-pages/src/HomePage/MainRoomListPanel/MainRoomList.tsx b/packages/flat-pages/src/HomePage/MainRoomListPanel/MainRoomList.tsx index 0c0caea9a01..421293553ea 100644 --- a/packages/flat-pages/src/HomePage/MainRoomListPanel/MainRoomList.tsx +++ b/packages/flat-pages/src/HomePage/MainRoomListPanel/MainRoomList.tsx @@ -81,53 +81,20 @@ export const MainRoomList = observer(function MainRoomList({ const primaryAction = ( roomStatus?: RoomStatus, ): RoomListItemPrimaryAction<"replay" | "join" | "begin"> | null => { - let primaryAction: RoomListItemPrimaryAction< - "replay" | "join" | "begin" - > | null; - switch (roomStatus) { - case RoomStatus.Idle: { - const isCreator = room.ownerUUID === globalStore.userUUID; - primaryAction = isCreator - ? { - key: "begin", - text: t("begin"), - type: "primary", - } - : { - key: "join", - text: t("join"), - type: "primary", - }; - break; - } - case RoomStatus.Started: - case RoomStatus.Paused: { - primaryAction = { - key: "join", - text: t("join"), - type: "primary", - }; - break; - } - case RoomStatus.Stopped: { - primaryAction = room.hasRecord - ? { - key: "replay", - text: t("replay"), - } - : null; - break; - } - default: { - primaryAction = { - key: "begin", - text: t("begin"), - type: "primary", - }; - break; - } + if (roomStatus === RoomStatus.Stopped) { + return room.hasRecord + ? { + key: "replay", + text: t("replay"), + } + : null; + } else { + return { + key: "join", + text: t("join"), + type: "primary", + }; } - return primaryAction; }; return (