Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(flat-pages): format pmi invitation #2061

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/flat-i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"periodic": "Periodic",
"today": "Today",
"tomorrow": "Tomorrow",
"pmi-invite-prefix": "{{userName}} invites you to join {{appName}} personal room",
"invite-begin-time": "Start time: {{time}}",
"invite-prefix": "{{userName}} invites you to join the {{appName}} room\n\nRoom theme: {{title}}",
"invite-suffix": "Room ID: {{uuid}}",
Expand Down
1 change: 1 addition & 0 deletions packages/flat-i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"all-loaded": "已全部加载",
"no-record": "暂无记录",
"no-room": "暂无房间",
"pmi-invite-prefix": "{{userName}} 邀请你加入 {{appName}} 个人房间",
"invite-prefix": "{{userName}} 邀请你加入 {{appName}} 房间\n房间主题:{{title}}\n",
"invite-begin-time": "开始时间:{{time}}\n",
"invite-suffix": "房间号:{{uuid}}",
Expand Down
27 changes: 23 additions & 4 deletions packages/flat-pages/src/HomePage/MainRoomMenu/CreateRoomBox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import "./CreateRoomBox.less";

import React, { useContext, useEffect, useRef, useState, KeyboardEvent, useCallback } from "react";
import { ClassPicker, HomePageHeroButton, PmiDesc, PmiExistTip, Region } from "flat-components";
import {
ClassPicker,
HomePageHeroButton,
PmiDesc,
PmiExistTip,
Region,
formatInviteCode,
} from "flat-components";
import { Input, Modal, Checkbox, Form, InputRef, Dropdown, message, Button } from "antd";
import { MoreOutlined } from "@ant-design/icons";
import { useTranslate } from "@netless/flat-i18n";
Expand All @@ -12,6 +19,7 @@ import { PreferencesStoreContext, GlobalStoreContext } from "../../components/St
import { RouteNameType, usePushHistory } from "../../utils/routes";
import { joinRoomHandler } from "../../utils/join-room-handler";
import { useSafePromise } from "../../utils/hooks/lifecycle";
import { FLAT_WEB_BASE_URL } from "../../constants/process";

interface CreateRoomFormValues {
roomTitle: string;
Expand Down Expand Up @@ -51,7 +59,7 @@ export const CreateRoomBox = observer<CreateRoomBoxProps>(function CreateRoomBox
roomType: RoomType.BigClass,
autoMicOn: preferencesStore.autoMicOn,
autoCameraOn: preferencesStore.autoCameraOn,
// if there exists pmi room, it will can not be selected
// if there exists pmi room, it can not be selected
pmi: preferencesStore.autoPmiOn && !globalStore.pmiRoomExist,
};

Expand Down Expand Up @@ -83,10 +91,21 @@ export const CreateRoomBox = observer<CreateRoomBoxProps>(function CreateRoomBox

const handleCopy = useCallback(
(text: string) => {
navigator.clipboard.writeText(text);
const copyText =
t("pmi-invite-prefix", {
userName: globalStore.userInfo?.name,
}) +
"\n" +
"\n" +
t("invite-suffix", { uuid: formatInviteCode("", text) }) +
"\n" +
"\n" +
t("invite-join-link", { link: `${FLAT_WEB_BASE_URL}/join/${text}` });

navigator.clipboard.writeText(copyText);
void message.success(t("copy-success"));
},
[t],
[globalStore.userInfo?.name, t],
);

const handleCreateRoom = (): void => {
Expand Down
2 changes: 1 addition & 1 deletion packages/flat-pages/src/UserScheduledPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const UserScheduledPage = observer(function UserScheduledPage() {
rate: 7,
endTime: addWeeks(scheduleBeginTime, 6),
},
// if there exists pmi room, it will can not be selected
// if there exists pmi room, it can not be selected
pmi: preferencesStore.autoPmiOn && !globalStore.pmiRoomExist,
};
});
Expand Down