From fe7d7ce274559dfa6b41c184e64eb70ecaec0acd Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Sun, 24 Jul 2022 19:06:56 +0200 Subject: [PATCH] Translate SettingsPage --- frontend/src/pages/SettingsPage.tsx | 270 +++++++++++++++------------- frontend/src/translations/de.yaml | 42 +++++ frontend/src/translations/en.yaml | 43 +++++ 3 files changed, 235 insertions(+), 120 deletions(-) diff --git a/frontend/src/pages/SettingsPage.tsx b/frontend/src/pages/SettingsPage.tsx index 8399ff1..c0b9bb5 100644 --- a/frontend/src/pages/SettingsPage.tsx +++ b/frontend/src/pages/SettingsPage.tsx @@ -1,178 +1,208 @@ -import React from 'react' -import {connect} from 'react-redux' -import {Message, Icon, Grid, Form, Button, TextArea, Ref, Input, Header, Divider, Popup} from 'semantic-ui-react' -import {useForm} from 'react-hook-form' +import React from "react"; +import { connect } from "react-redux"; +import { + Message, + Icon, + Grid, + Form, + Button, + TextArea, + Ref, + Input, + Header, + Divider, + Popup, +} from "semantic-ui-react"; +import { useForm } from "react-hook-form"; +import Markdown from "react-markdown"; +import { useTranslation } from "react-i18next"; -import {setLogin} from 'reducers/login' -import {Page, Stats} from 'components' -import api from 'api' -import {findInput} from 'utils' -import {useConfig} from 'config' +import { setLogin } from "reducers/login"; +import { Page, Stats } from "components"; +import api from "api"; +import { findInput } from "utils"; +import { useConfig } from "config"; -const SettingsPage = connect((state) => ({login: state.login}), {setLogin})(function SettingsPage({login, setLogin}) { - const {register, handleSubmit} = useForm() - const [loading, setLoading] = React.useState(false) - const [errors, setErrors] = React.useState(null) +const SettingsPage = connect((state) => ({ login: state.login }), { setLogin })( + function SettingsPage({ login, setLogin }) { + const { t } = useTranslation(); + const { register, handleSubmit } = useForm(); + const [loading, setLoading] = React.useState(false); + const [errors, setErrors] = React.useState(null); - const onSave = React.useCallback( - async (changes) => { - setLoading(true) - setErrors(null) + const onSave = React.useCallback( + async (changes) => { + setLoading(true); + setErrors(null); + try { + const response = await api.put("/user", { body: changes }); + setLogin(response); + } catch (err) { + setErrors(err.errors); + } finally { + setLoading(false); + } + }, + [setLoading, setLogin, setErrors] + ); + + const onGenerateNewKey = React.useCallback(async () => { + setLoading(true); + setErrors(null); try { - const response = await api.put('/user', {body: changes}) - setLogin(response) + const response = await api.put("/user", { + body: { updateApiKey: true }, + }); + setLogin(response); } catch (err) { - setErrors(err.errors) + setErrors(err.errors); } finally { - setLoading(false) + setLoading(false); } - }, - [setLoading, setLogin, setErrors] - ) + }, [setLoading, setLogin, setErrors]); - const onGenerateNewKey = React.useCallback(async () => { - setLoading(true) - setErrors(null) - try { - const response = await api.put('/user', {body: {updateApiKey: true}}) - setLogin(response) - } catch (err) { - setErrors(err.errors) - } finally { - setLoading(false) - } - }, [setLoading, setLogin, setErrors]) + return ( + + + + +
{t("SettingsPage.profile.title")}
- return ( - - - - -
My profile
+ {t("SettingsPage.profile.publicNotice")} - All of this information is public. - -
- - - - - - -