mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: implement week start day setting
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { Button, Textarea } from "@mui/joy";
|
||||
import { Button, Select, Textarea, Option, Divider } from "@mui/joy";
|
||||
import { useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { Link } from "react-router-dom";
|
||||
@ -25,27 +25,15 @@ const WorkspaceSection = () => {
|
||||
setWorkspaceGeneralSetting({ ...workspaceGeneralSetting, additionalStyle: value });
|
||||
};
|
||||
|
||||
const handleSaveAdditionalStyle = async () => {
|
||||
try {
|
||||
await workspaceSettingServiceClient.setWorkspaceSetting({
|
||||
setting: {
|
||||
name: `${workspaceSettingNamePrefix}${WorkspaceSettingKey.GENERAL}`,
|
||||
generalSetting: workspaceGeneralSetting,
|
||||
},
|
||||
});
|
||||
} catch (error: any) {
|
||||
toast.error(error.response.data.message);
|
||||
console.error(error);
|
||||
return;
|
||||
}
|
||||
toast.success(t("message.update-succeed"));
|
||||
};
|
||||
|
||||
const handleAdditionalScriptChanged = (value: string) => {
|
||||
setWorkspaceGeneralSetting({ ...workspaceGeneralSetting, additionalScript: value });
|
||||
};
|
||||
|
||||
const handleSaveAdditionalScript = async () => {
|
||||
const handleWeekStartDayOffsetChanged = (value: number) => {
|
||||
setWorkspaceGeneralSetting({ ...workspaceGeneralSetting, weekStartDayOffset: value });
|
||||
};
|
||||
|
||||
const handleSaveGeneralSetting = async () => {
|
||||
try {
|
||||
await workspaceSettingServiceClient.setWorkspaceSetting({
|
||||
setting: {
|
||||
@ -54,7 +42,7 @@ const WorkspaceSection = () => {
|
||||
},
|
||||
});
|
||||
} catch (error: any) {
|
||||
toast.error(error.response.data.message);
|
||||
toast.error(error.details);
|
||||
console.error(error);
|
||||
return;
|
||||
}
|
||||
@ -69,57 +57,70 @@ const WorkspaceSection = () => {
|
||||
{t("setting.system-section.server-name")}:{" "}
|
||||
<span className="font-mono font-bold">{workspaceGeneralSetting.customProfile?.title || "Memos"}</span>
|
||||
</div>
|
||||
<Button onClick={handleUpdateCustomizedProfileButtonClick}>{t("common.edit")}</Button>
|
||||
<Button variant="outlined" color="neutral" onClick={handleUpdateCustomizedProfileButtonClick}>
|
||||
{t("common.edit")}
|
||||
</Button>
|
||||
</div>
|
||||
<Divider />
|
||||
<p className="font-medium text-gray-700 dark:text-gray-500">General</p>
|
||||
<div className="space-y-2 border rounded-md py-2 px-3 dark:border-zinc-700">
|
||||
<div className="w-full flex flex-row justify-between items-center">
|
||||
<span>{t("setting.system-section.additional-style")}</span>
|
||||
<Button variant="outlined" color="neutral" onClick={handleSaveAdditionalStyle}>
|
||||
{t("common.save")}
|
||||
</Button>
|
||||
</div>
|
||||
<Textarea
|
||||
className="w-full"
|
||||
sx={{
|
||||
fontFamily: "monospace",
|
||||
fontSize: "14px",
|
||||
<div className="w-full flex flex-row justify-between items-center">
|
||||
<span>{t("setting.system-section.additional-style")}</span>
|
||||
</div>
|
||||
<Textarea
|
||||
className="w-full"
|
||||
sx={{
|
||||
fontFamily: "monospace",
|
||||
fontSize: "14px",
|
||||
}}
|
||||
minRows={2}
|
||||
maxRows={4}
|
||||
placeholder={t("setting.system-section.additional-style-placeholder")}
|
||||
value={workspaceGeneralSetting.additionalStyle}
|
||||
onChange={(event) => handleAdditionalStyleChanged(event.target.value)}
|
||||
/>
|
||||
<div className="w-full flex flex-row justify-between items-center">
|
||||
<span>{t("setting.system-section.additional-script")}</span>
|
||||
</div>
|
||||
<Textarea
|
||||
className="w-full"
|
||||
color="neutral"
|
||||
sx={{
|
||||
fontFamily: "monospace",
|
||||
fontSize: "14px",
|
||||
}}
|
||||
minRows={2}
|
||||
maxRows={4}
|
||||
placeholder={t("setting.system-section.additional-script-placeholder")}
|
||||
value={workspaceGeneralSetting.additionalScript}
|
||||
onChange={(event) => handleAdditionalScriptChanged(event.target.value)}
|
||||
/>
|
||||
<div className="w-full">
|
||||
<Link
|
||||
className="text-gray-500 text-sm flex flex-row justify-start items-center hover:underline hover:text-blue-600"
|
||||
to="https://usememos.com/docs/advanced-settings/custom-style-and-script"
|
||||
target="_blank"
|
||||
>
|
||||
{t("common.learn-more")}
|
||||
<Icon.ExternalLink className="inline w-4 h-auto ml-1" />
|
||||
</Link>
|
||||
</div>
|
||||
<div className="w-full flex flex-row justify-between items-center">
|
||||
<span className="truncate">{t("setting.preference-section.default-memo-visibility")}</span>
|
||||
<Select
|
||||
className="!min-w-fit"
|
||||
value={workspaceGeneralSetting.weekStartDayOffset}
|
||||
onChange={(_, weekStartDayOffset) => {
|
||||
handleWeekStartDayOffsetChanged(weekStartDayOffset || 0);
|
||||
}}
|
||||
minRows={2}
|
||||
maxRows={4}
|
||||
placeholder={t("setting.system-section.additional-style-placeholder")}
|
||||
value={workspaceGeneralSetting.additionalStyle}
|
||||
onChange={(event) => handleAdditionalStyleChanged(event.target.value)}
|
||||
/>
|
||||
<div className="w-full flex flex-row justify-between items-center">
|
||||
<span>{t("setting.system-section.additional-script")}</span>
|
||||
<Button variant="outlined" color="neutral" onClick={handleSaveAdditionalScript}>
|
||||
{t("common.save")}
|
||||
</Button>
|
||||
</div>
|
||||
<Textarea
|
||||
className="w-full"
|
||||
color="neutral"
|
||||
sx={{
|
||||
fontFamily: "monospace",
|
||||
fontSize: "14px",
|
||||
}}
|
||||
minRows={2}
|
||||
maxRows={4}
|
||||
placeholder={t("setting.system-section.additional-script-placeholder")}
|
||||
value={workspaceGeneralSetting.additionalScript}
|
||||
onChange={(event) => handleAdditionalScriptChanged(event.target.value)}
|
||||
/>
|
||||
<div className="w-full">
|
||||
<Link
|
||||
className="text-gray-500 text-sm flex flex-row justify-start items-center hover:underline hover:text-blue-600"
|
||||
to="https://usememos.com/docs/advanced-settings/custom-style-and-script"
|
||||
target="_blank"
|
||||
>
|
||||
{t("common.learn-more")}
|
||||
<Icon.ExternalLink className="inline w-4 h-auto ml-1" />
|
||||
</Link>
|
||||
</div>
|
||||
>
|
||||
<Option value={0}>Sunday</Option>
|
||||
<Option value={1}>Monday</Option>
|
||||
</Select>
|
||||
</div>
|
||||
<div>
|
||||
<Button variant="outlined" color="neutral" onClick={handleSaveGeneralSetting}>
|
||||
{t("common.save")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Reference in New Issue
Block a user