mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
i18n and html form validation
This commit is contained in:
parent
61c5fc3957
commit
ee094dd7af
3 changed files with 26 additions and 11 deletions
|
@ -228,13 +228,18 @@
|
||||||
"user_profile": {
|
"user_profile": {
|
||||||
"amount_hours": "{{amount}} hours",
|
"amount_hours": "{{amount}} hours",
|
||||||
"amount_minutes": "{{amount}} minutes",
|
"amount_minutes": "{{amount}} minutes",
|
||||||
"play_time": "Played for {{amount}}",
|
|
||||||
"last_time_played": "Last played {{period}}",
|
"last_time_played": "Last played {{period}}",
|
||||||
"sign_out": "Sign out",
|
"sign_out": "Sign out",
|
||||||
"activity": "Recent activity",
|
"activity": "Recent activity",
|
||||||
"library": "Library",
|
"library": "Library",
|
||||||
"total_play_time": "Total playtime: {{amount}}",
|
"total_play_time": "Total playtime: {{amount}}",
|
||||||
"no_recent_activity_title": "Hmmm… nothing here",
|
"no_recent_activity_title": "Hmmm… nothing here",
|
||||||
"no_recent_activity_description": "You haven't played any games recently. It's time to change that!"
|
"no_recent_activity_description": "You haven't played any games recently. It's time to change that!",
|
||||||
|
"display_name": "Display name",
|
||||||
|
"saving": "Saving",
|
||||||
|
"save": "Save",
|
||||||
|
"edit_profile": "Edit Profile",
|
||||||
|
"saved_successfully": "Saved successfully",
|
||||||
|
"try_again": "Please, try again"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,13 +229,18 @@
|
||||||
"user_profile": {
|
"user_profile": {
|
||||||
"amount_hours": "{{amount}} horas",
|
"amount_hours": "{{amount}} horas",
|
||||||
"amount_minutes": "{{amount}} minutos",
|
"amount_minutes": "{{amount}} minutos",
|
||||||
"play_time": "Jogado por {{amount}}",
|
|
||||||
"last_time_played": "Jogou {{period}}",
|
"last_time_played": "Jogou {{period}}",
|
||||||
"sign_out": "Sair da conta",
|
"sign_out": "Sair da conta",
|
||||||
"activity": "Atividade recente",
|
"activity": "Atividade recente",
|
||||||
"library": "Biblioteca",
|
"library": "Biblioteca",
|
||||||
"total_play_time": "Tempo total de jogo: {{amount}}",
|
"total_play_time": "Tempo total de jogo: {{amount}}",
|
||||||
"no_recent_activity_title": "Hmmm… nada por aqui",
|
"no_recent_activity_title": "Hmmm… nada por aqui",
|
||||||
"no_recent_activity_description": "Parece que você não jogou nada recentemente. Que tal começar agora?"
|
"no_recent_activity_description": "Parece que você não jogou nada recentemente. Que tal começar agora?",
|
||||||
|
"display_name": "Nome de exibição",
|
||||||
|
"saving": "Salvando…",
|
||||||
|
"save": "Salvar",
|
||||||
|
"edit_profile": "Editar Perfil",
|
||||||
|
"saved_successfully": "Salvo com sucesso",
|
||||||
|
"try_again": "Por favor, tente novamente"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { DeviceCameraIcon, PersonIcon } from "@primer/octicons-react";
|
||||||
import { SPACING_UNIT } from "@renderer/theme.css";
|
import { SPACING_UNIT } from "@renderer/theme.css";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import { useToast, useUserDetails } from "@renderer/hooks";
|
import { useToast, useUserDetails } from "@renderer/hooks";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export interface UserEditProfileModalProps {
|
export interface UserEditProfileModalProps {
|
||||||
userProfile: UserProfile;
|
userProfile: UserProfile;
|
||||||
|
@ -19,6 +20,8 @@ export const UserEditProfileModal = ({
|
||||||
onClose,
|
onClose,
|
||||||
updateUserProfile,
|
updateUserProfile,
|
||||||
}: UserEditProfileModalProps) => {
|
}: UserEditProfileModalProps) => {
|
||||||
|
const { t } = useTranslation("user_profile");
|
||||||
|
|
||||||
const [displayName, setDisplayName] = useState("");
|
const [displayName, setDisplayName] = useState("");
|
||||||
const [newImagePath, setNewImagePath] = useState<string | null>(null);
|
const [newImagePath, setNewImagePath] = useState<string | null>(null);
|
||||||
const [isSaving, setIsSaving] = useState(false);
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
@ -36,8 +39,8 @@ export const UserEditProfileModal = ({
|
||||||
properties: ["openFile"],
|
properties: ["openFile"],
|
||||||
filters: [
|
filters: [
|
||||||
{
|
{
|
||||||
name: "Profile image",
|
name: "Image",
|
||||||
extensions: ["jpg", "png", "gif", "webp", "jpeg"],
|
extensions: ["jpg", "jpeg", "png", "gif", "webp", "bmp"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
@ -58,11 +61,11 @@ export const UserEditProfileModal = ({
|
||||||
patchUser(displayName, newImagePath)
|
patchUser(displayName, newImagePath)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
await updateUserProfile();
|
await updateUserProfile();
|
||||||
showSuccessToast("Salvo com sucesso");
|
showSuccessToast(t("saved_successfully"));
|
||||||
cleanFormAndClose();
|
cleanFormAndClose();
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
showErrorToast("Tente novamente");
|
showErrorToast(t("try_again"));
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
setIsSaving(false);
|
setIsSaving(false);
|
||||||
|
@ -89,7 +92,7 @@ export const UserEditProfileModal = ({
|
||||||
<>
|
<>
|
||||||
<Modal
|
<Modal
|
||||||
visible={visible}
|
visible={visible}
|
||||||
title="Editar Perfil"
|
title={t("edit_profile")}
|
||||||
onClose={cleanFormAndClose}
|
onClose={cleanFormAndClose}
|
||||||
>
|
>
|
||||||
<form
|
<form
|
||||||
|
@ -123,8 +126,10 @@ export const UserEditProfileModal = ({
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
label="Nome de exibição"
|
label={t("display_name")}
|
||||||
value={displayName}
|
value={displayName}
|
||||||
|
required
|
||||||
|
minLength={3}
|
||||||
containerProps={{ style: { width: "100%" } }}
|
containerProps={{ style: { width: "100%" } }}
|
||||||
onChange={(e) => setDisplayName(e.target.value)}
|
onChange={(e) => setDisplayName(e.target.value)}
|
||||||
/>
|
/>
|
||||||
|
@ -133,7 +138,7 @@ export const UserEditProfileModal = ({
|
||||||
style={{ alignSelf: "end" }}
|
style={{ alignSelf: "end" }}
|
||||||
type="submit"
|
type="submit"
|
||||||
>
|
>
|
||||||
{isSaving ? "Salvando…" : "Salvar"}
|
{isSaving ? t("saving") : t("save")}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue