2023-04-03 19:38:03 +03:00
|
|
|
import {
|
|
|
|
SettingsCheckBox,
|
|
|
|
SettingsTextInput,
|
|
|
|
SettingsSelectInput,
|
2023-04-04 17:15:25 +03:00
|
|
|
SettingsSection,
|
2023-04-05 20:10:05 +03:00
|
|
|
setSetting,
|
2023-04-03 19:38:03 +03:00
|
|
|
} from "../components/settingsInputs";
|
2023-04-04 15:15:15 +03:00
|
|
|
import { reRenderPage } from "../components/utils";
|
|
|
|
import Locales from "../localisation/main";
|
2023-04-05 14:23:32 +03:00
|
|
|
import { ButtonWithIcon } from "../components/button";
|
|
|
|
import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
|
2023-04-04 15:15:15 +03:00
|
|
|
|
2023-04-03 17:03:01 +03:00
|
|
|
function Settings() {
|
|
|
|
return (
|
2023-04-04 17:15:25 +03:00
|
|
|
<div>
|
2023-04-03 17:03:01 +03:00
|
|
|
<h1 className="text-center lg:text-left leading-tight text-2xl font-bold">
|
2023-04-04 15:15:15 +03:00
|
|
|
{locals.Settings}
|
2023-04-03 17:03:01 +03:00
|
|
|
</h1>
|
|
|
|
|
2023-04-04 17:15:25 +03:00
|
|
|
<SettingsSection name={locals.User}>
|
|
|
|
<SettingsTextInput
|
|
|
|
placeholder={locals.Name}
|
|
|
|
label={locals.UserName}
|
|
|
|
settingName="userName"
|
|
|
|
/>
|
2023-04-03 19:38:03 +03:00
|
|
|
|
2023-04-04 17:15:25 +03:00
|
|
|
<SettingsTextInput
|
|
|
|
placeholder={locals.Url}
|
|
|
|
label={locals.PhotoUrl}
|
|
|
|
settingName="userPhoto"
|
|
|
|
/>
|
2023-04-03 19:38:03 +03:00
|
|
|
|
2023-04-04 17:15:25 +03:00
|
|
|
<SettingsTextInput
|
|
|
|
placeholder={locals.Status}
|
|
|
|
label={locals.UserStatus}
|
|
|
|
settingName="userStatus"
|
|
|
|
/>
|
|
|
|
</SettingsSection>
|
2023-04-03 19:38:03 +03:00
|
|
|
|
2023-04-04 17:15:25 +03:00
|
|
|
<SettingsSection name={locals.Notes}>
|
|
|
|
<SettingsCheckBox
|
|
|
|
label={locals.EditPreview}
|
|
|
|
title={locals.EditPreviewWarn}
|
|
|
|
settingName="editPreview"
|
|
|
|
/>
|
2023-04-03 19:38:03 +03:00
|
|
|
|
2023-04-04 17:15:25 +03:00
|
|
|
<SettingsCheckBox
|
|
|
|
label={locals.PublicNote}
|
|
|
|
title={locals.PublicNoteTitle}
|
|
|
|
settingName="publicNote"
|
|
|
|
/>
|
2023-04-03 19:38:03 +03:00
|
|
|
|
2023-04-04 17:15:25 +03:00
|
|
|
<SettingsCheckBox
|
|
|
|
label={locals.AdditionalFeatures}
|
|
|
|
settingName="additionalFeatures"
|
|
|
|
/>
|
2023-04-04 20:10:41 +03:00
|
|
|
|
|
|
|
<SettingsCheckBox label={locals.CollabEdit} settingName="CollabEdit" />
|
|
|
|
|
|
|
|
<SettingsTextInput
|
|
|
|
placeholder={locals.Password}
|
|
|
|
label={locals.CollabEditPassword}
|
|
|
|
settingName="CollabEditPassword"
|
2023-04-05 14:23:32 +03:00
|
|
|
onChange={() => {
|
2023-04-04 20:10:41 +03:00
|
|
|
window.alreadyConnected = false;
|
|
|
|
}}
|
|
|
|
/>
|
2023-04-04 17:15:25 +03:00
|
|
|
</SettingsSection>
|
2023-04-03 17:03:01 +03:00
|
|
|
|
2023-04-05 14:23:32 +03:00
|
|
|
<SettingsSection name={locals.Sync}>
|
|
|
|
<SettingsCheckBox
|
|
|
|
label={locals.BroadcastSync}
|
2023-04-05 14:46:25 +03:00
|
|
|
onClick={(e) => {
|
2023-04-05 14:23:32 +03:00
|
|
|
if (e.target.checked) {
|
2023-04-05 14:34:52 +03:00
|
|
|
socket.emit("joinRoom", settings.SyncPassword);
|
2023-04-05 14:23:32 +03:00
|
|
|
} else {
|
|
|
|
socket.emit("leaveRoom");
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<SettingsTextInput
|
|
|
|
placeholder={locals.Password}
|
|
|
|
label={locals.SyncPassword}
|
|
|
|
secret
|
|
|
|
settingName="SyncPassword"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<ButtonWithIcon
|
|
|
|
icon={ChevronDoubleRightIcon}
|
|
|
|
text={locals.SyncAll}
|
|
|
|
className="m-1"
|
|
|
|
w="w-full lg:w-96"
|
|
|
|
onClick={() => {
|
|
|
|
socket.emit("broadcastSync", {
|
|
|
|
data: {
|
|
|
|
settings: localStorage.getItem("settings"),
|
|
|
|
Notes: localStorage.getItem("Notes"),
|
|
|
|
NoteText: localStorage.getItem("NoteText"),
|
|
|
|
NoteName: localStorage.getItem("NoteName"),
|
|
|
|
},
|
2023-04-05 14:34:52 +03:00
|
|
|
room: settings.SyncPassword,
|
2023-04-05 14:23:32 +03:00
|
|
|
});
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</SettingsSection>
|
|
|
|
|
2023-04-04 17:15:25 +03:00
|
|
|
<SettingsSection name={locals.Interface}>
|
|
|
|
<SettingsSelectInput
|
|
|
|
label={locals.Language}
|
|
|
|
settingName="language"
|
|
|
|
options={[
|
|
|
|
{
|
|
|
|
value: "ru",
|
|
|
|
label: "Русский",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: "en",
|
|
|
|
label: "English (US)",
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
onChange={(e) => {
|
|
|
|
window.locals =
|
|
|
|
Locales[window.settings.language] ||
|
|
|
|
Locales[navigator.language] ||
|
|
|
|
Locales[navigator.userLanguage] ||
|
|
|
|
Locales.en;
|
2023-04-03 19:38:03 +03:00
|
|
|
|
2023-04-05 20:10:05 +03:00
|
|
|
setSetting("newNotes", false);
|
2023-04-04 17:15:25 +03:00
|
|
|
reRenderPage();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</SettingsSection>
|
2023-04-04 16:50:11 +03:00
|
|
|
|
2023-04-04 17:15:25 +03:00
|
|
|
<SettingsSection name={locals.ThirdPartyApi}>
|
|
|
|
<SettingsTextInput
|
|
|
|
placeholder={locals.Key}
|
|
|
|
label={locals.OpenAiKey}
|
|
|
|
settingName="openAiKey"
|
|
|
|
secret
|
|
|
|
/>
|
|
|
|
</SettingsSection>
|
2023-04-03 17:03:01 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Settings;
|