refactor: setting overview
This commit is contained in:
@@ -2,6 +2,7 @@ import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import Radio from '../../../common/component/styled/Radio';
|
||||
import { Theme } from '../../../types/common';
|
||||
import SettingBlock from './SettingBlock';
|
||||
|
||||
// type Props = {}
|
||||
|
||||
@@ -19,15 +20,10 @@ const DarkMode = () => {
|
||||
} else {
|
||||
const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
document.documentElement.classList.add(isDark ? "dark" : 'light');
|
||||
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="text-sm">
|
||||
<p className="dark:text-gray-100 font-semibold">{t("overview.theme.title")}</p>
|
||||
<p className="flex justify-between w-full text-gray-400 mb-2">
|
||||
{t("overview.theme.desc")}
|
||||
</p>
|
||||
<SettingBlock title={t("overview.theme.title")} desc={t("overview.theme.desc")}>
|
||||
<Radio
|
||||
options={[t("overview.theme.auto"), t("overview.theme.dark"), t("overview.theme.light")]}
|
||||
values={['auto', 'dark', 'light']}
|
||||
@@ -36,7 +32,7 @@ const DarkMode = () => {
|
||||
handleThemeToggle(v);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</SettingBlock>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// import React from 'react'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import { useGetFrontendUrlQuery, useUpdateFrontendUrlMutation } from '../../../app/services/server';
|
||||
import StyledInput from "../../../common/component/styled/Input";
|
||||
import StyledButton from "../../../common/component/styled/Button";
|
||||
import { ChangeEvent, useState, useEffect } from 'react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import SettingBlock from './SettingBlock';
|
||||
// type Props = {}
|
||||
|
||||
const Index = () => {
|
||||
@@ -32,16 +33,12 @@ const Index = () => {
|
||||
}, [getUrlSuccess, data]);
|
||||
// if(!fetch)
|
||||
return (
|
||||
<div className="text-sm">
|
||||
<p className="dark:text-gray-100 font-semibold">{t("overview.url.title")}</p>
|
||||
<p className="flex justify-between w-full text-gray-400">
|
||||
{t("overview.url.desc")}
|
||||
</p>
|
||||
<SettingBlock title={t("overview.url.title")} desc={t("overview.url.desc")}>
|
||||
<div className="flex items-center gap-4 mt-2">
|
||||
<StyledInput placeholder='frontend url' value={url} onChange={handleChange} />
|
||||
<StyledButton disabled={!url || isLoading} className='' onClick={handleUpdate}> {ct("action.update")}</StyledButton>
|
||||
</div>
|
||||
</div>
|
||||
</SettingBlock>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// import React from 'react'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import StyledRadio from "../../../common/component/styled/Radio";
|
||||
import SettingBlock from './SettingBlock';
|
||||
|
||||
// type Props = {}
|
||||
|
||||
@@ -10,11 +11,7 @@ const Index = () => {
|
||||
i18n.changeLanguage(v);
|
||||
};
|
||||
return (
|
||||
<div className="text-sm">
|
||||
<p className="dark:text-gray-100 font-semibold">{t("overview.lang.title")}</p>
|
||||
<p className="flex justify-between w-full text-gray-400 mb-2">
|
||||
{t("overview.lang.desc")}
|
||||
</p>
|
||||
<SettingBlock title={t("overview.lang.title")} desc={t("overview.lang.desc")}>
|
||||
<StyledRadio
|
||||
options={[t("overview.lang.en"), t("overview.lang.zh"), t("overview.lang.jp"), t("overview.lang.tr")]}
|
||||
values={["en", "zh", "jp", "tr"]}
|
||||
@@ -25,7 +22,7 @@ const Index = () => {
|
||||
handleGuestToggle(v);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</SettingBlock>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useEffect } from 'react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import StyledRadio from "../../../common/component/styled/Radio";
|
||||
import { useAppSelector } from '../../../app/store';
|
||||
import SettingBlock from './SettingBlock';
|
||||
// type Props = {}
|
||||
|
||||
const Index = () => {
|
||||
@@ -24,20 +25,14 @@ const Index = () => {
|
||||
};
|
||||
// if (!loadSuccess) return null;
|
||||
return (
|
||||
<div className="text-sm">
|
||||
<p className="dark:text-gray-100 font-semibold">{t("title")}</p>
|
||||
<p className="flex justify-between w-full text-gray-400 mb-2">
|
||||
<span className="txt">
|
||||
{t("desc")}
|
||||
</span>
|
||||
</p>
|
||||
<SettingBlock title={t("title")} desc={t('desc')} >
|
||||
<StyledRadio
|
||||
options={[t("enable"), t("disable")]}
|
||||
values={["true", "false"]}
|
||||
value={`${currStatus}`}
|
||||
onChange={handleToggle}
|
||||
/>
|
||||
</div>
|
||||
</SettingBlock>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ const Index = () => {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex flex-col items-start gap-6 mb-16">
|
||||
<div className="flex flex-col items-start gap-6 mb-3">
|
||||
<div className="w-full flex flex-col items-start gap-2">
|
||||
<Label className='dark:text-gray-100' htmlFor="name">{t("overview.name")}</Label>
|
||||
<Input
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
|
||||
type Props = {
|
||||
title: string,
|
||||
desc: string,
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
const SettingBlock = ({ title, desc, children }: Props) => {
|
||||
return (
|
||||
<div className="text-sm">
|
||||
<p className="text-gray-600 dark:text-gray-100 font-semibold">{title}</p>
|
||||
<p className="flex justify-between w-full text-gray-400 mb-2 text-xs">
|
||||
{desc}
|
||||
</p>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingBlock;
|
||||
@@ -1,6 +1,7 @@
|
||||
// import React from 'react'
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import StyledRadio from "../../../common/component/styled/Radio";
|
||||
import SettingBlock from './SettingBlock';
|
||||
|
||||
// type Props = {}
|
||||
|
||||
@@ -10,11 +11,7 @@ const Index = () => {
|
||||
i18n.changeLanguage(v);
|
||||
};
|
||||
return (
|
||||
<div className="text-sm">
|
||||
<p className="dark:text-gray-100 font-semibold">{t("overview.lang.title")}</p>
|
||||
<p className="flex justify-between w-full text-gray-400 mb-2">
|
||||
{t("overview.lang.desc")}
|
||||
</p>
|
||||
<SettingBlock title={t("overview.lang.title")} desc={t("overview.lang.desc")}>
|
||||
<StyledRadio
|
||||
options={[t("overview.lang.en"), t("overview.lang.zh"), t("overview.lang.jp"), t("overview.lang.tr")]}
|
||||
values={["en", "zh", "jp", "tr"]}
|
||||
@@ -25,7 +22,7 @@ const Index = () => {
|
||||
handleGuestToggle(v);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</SettingBlock>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ const Index = () => {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex flex-col items-start gap-6 mb-16">
|
||||
<div className="flex flex-col items-start gap-6 mb-3">
|
||||
<div className="w-full flex flex-col items-start gap-2">
|
||||
<Label className='dark:text-gray-100' htmlFor="name">{t("overview.name")}</Label>
|
||||
<Input
|
||||
|
||||
Reference in New Issue
Block a user