strings
This commit is contained in:
1 parent
c4ab56095e
commit
197e075ba1
5 files changed
+88
-46
No files matched your search
@@ -1,10 +1,16 @@
|
|||||||
import { Stack, MenuItem } from "@mui/material";
|
import { Stack, Typography, IconButton, Divider } from "@mui/material";
|
||||||
import { useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { ConfigBox, BasePage, Breadcrumb } from "@/Components/v2/design-elements";
|
import { ConfigBox, BasePage, Breadcrumb } from "@/Components/v2/design-elements";
|
||||||
import { TextField, Button, Select } from "@/Components/v2/inputs";
|
import { TextField, Button, Autocomplete } from "@/Components/v2/inputs";
|
||||||
import { UserRoles } from "@/Types/User";
|
import { UserRoles } from "@/Types/User";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
import { Trash2 } from "lucide-react";
|
||||||
|
|
||||||
|
interface RoleOption {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
const EditUserPage = () => {
|
const EditUserPage = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -17,6 +23,17 @@ const EditUserPage = () => {
|
|||||||
|
|
||||||
const editableRoles = UserRoles.filter((role) => role !== "superadmin");
|
const editableRoles = UserRoles.filter((role) => role !== "superadmin");
|
||||||
|
|
||||||
|
const roleOptions: RoleOption[] = editableRoles.map((role) => ({
|
||||||
|
id: role,
|
||||||
|
name: t(`common.auth.roles.${role}`),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const selectedRoles = roleOptions.filter((r) => roles.includes(r.id));
|
||||||
|
|
||||||
|
const handleRemoveRole = (roleToRemove: string) => {
|
||||||
|
setRoles(roles.filter((role) => role !== roleToRemove));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BasePage>
|
<BasePage>
|
||||||
<Breadcrumb breadcrumbOverride={[t("menu.team"), t("editUserPage.title")]} />
|
<Breadcrumb breadcrumbOverride={[t("menu.team"), t("editUserPage.title")]} />
|
||||||
@@ -50,25 +67,47 @@ const EditUserPage = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<ConfigBox
|
<ConfigBox
|
||||||
title={t("editUserPage.form.role")}
|
title={t("pages.editUser.form.roles.title")}
|
||||||
subtitle={t("pages.account.team.invite.role.placeholder")}
|
subtitle={t("pages.editUser.form.roles.description")}
|
||||||
rightContent={
|
rightContent={
|
||||||
<Select
|
<Stack spacing={theme.spacing(4)}>
|
||||||
multiple
|
<Autocomplete
|
||||||
value={roles}
|
fieldLabel={t("common.form.role.option.label")}
|
||||||
onChange={(e) => setRoles(e.target.value as string[])}
|
multiple
|
||||||
placeholder={t("pages.account.team.invite.role.placeholder")}
|
options={roleOptions}
|
||||||
sx={{ minWidth: 200 }}
|
value={selectedRoles}
|
||||||
>
|
getOptionLabel={(option) => option.name}
|
||||||
{editableRoles.map((role) => (
|
onChange={(_: unknown, newValue: RoleOption[]) => {
|
||||||
<MenuItem
|
setRoles(newValue.map((r) => r.id));
|
||||||
key={role}
|
}}
|
||||||
value={role}
|
isOptionEqualToValue={(option, value) => option.id === value.id}
|
||||||
|
/>
|
||||||
|
{selectedRoles.length > 0 && (
|
||||||
|
<Stack
|
||||||
|
flex={1}
|
||||||
|
width="100%"
|
||||||
>
|
>
|
||||||
{t(`common.auth.roles.${role}`)}
|
{selectedRoles.map((role, index) => (
|
||||||
</MenuItem>
|
<Stack
|
||||||
))}
|
direction="row"
|
||||||
</Select>
|
alignItems="center"
|
||||||
|
key={role.id}
|
||||||
|
width="100%"
|
||||||
|
>
|
||||||
|
<Typography flexGrow={1}>{role.name}</Typography>
|
||||||
|
<IconButton
|
||||||
|
size="small"
|
||||||
|
onClick={() => handleRemoveRole(role.id)}
|
||||||
|
aria-label="Remove role"
|
||||||
|
>
|
||||||
|
<Trash2 size={16} />
|
||||||
|
</IconButton>
|
||||||
|
{index < selectedRoles.length - 1 && <Divider />}
|
||||||
|
</Stack>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -90,8 +90,8 @@ export const TabProfile = () => {
|
|||||||
render={({ field, fieldState }) => (
|
render={({ field, fieldState }) => (
|
||||||
<TextField
|
<TextField
|
||||||
{...field}
|
{...field}
|
||||||
fieldLabel={t("pages.account.form.name.option.firstName.label")}
|
fieldLabel={t("common.form.name.option.firstName.label")}
|
||||||
placeholder={t("pages.account.form.name.option.firstName.placeholder")}
|
placeholder={t("common.form.name.option.firstName.placeholder")}
|
||||||
autoComplete="given-name"
|
autoComplete="given-name"
|
||||||
error={!!fieldState.error}
|
error={!!fieldState.error}
|
||||||
helperText={fieldState.error?.message ?? ""}
|
helperText={fieldState.error?.message ?? ""}
|
||||||
@@ -104,8 +104,8 @@ export const TabProfile = () => {
|
|||||||
render={({ field, fieldState }) => (
|
render={({ field, fieldState }) => (
|
||||||
<TextField
|
<TextField
|
||||||
{...field}
|
{...field}
|
||||||
fieldLabel={t("pages.account.form.name.option.lastName.label")}
|
fieldLabel={t("common.form.name.option.lastName.label")}
|
||||||
placeholder={t("pages.account.form.name.option.lastName.placeholder")}
|
placeholder={t("common.form.name.option.lastName.placeholder")}
|
||||||
autoComplete="family-name"
|
autoComplete="family-name"
|
||||||
error={!!fieldState.error}
|
error={!!fieldState.error}
|
||||||
helperText={fieldState.error?.message ?? ""}
|
helperText={fieldState.error?.message ?? ""}
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ export const AddTeamMemberDialog = ({
|
|||||||
render={({ field, fieldState }) => (
|
render={({ field, fieldState }) => (
|
||||||
<TextField
|
<TextField
|
||||||
{...field}
|
{...field}
|
||||||
fieldLabel={t("pages.auth.register.form.option.name.label")}
|
fieldLabel={t("common.form.name.option.firstName.label")}
|
||||||
placeholder={t("pages.auth.register.form.option.name.placeholder")}
|
placeholder={t("common.form.name.option.firstName.placeholder")}
|
||||||
error={!!fieldState.error}
|
error={!!fieldState.error}
|
||||||
helperText={fieldState.error?.message ?? ""}
|
helperText={fieldState.error?.message ?? ""}
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -105,8 +105,8 @@ export const AddTeamMemberDialog = ({
|
|||||||
render={({ field, fieldState }) => (
|
render={({ field, fieldState }) => (
|
||||||
<TextField
|
<TextField
|
||||||
{...field}
|
{...field}
|
||||||
fieldLabel={t("pages.auth.register.form.option.surname.label")}
|
fieldLabel={t("common.form.name.option.lastName.label")}
|
||||||
placeholder={t("pages.auth.register.form.option.surname.placeholder")}
|
placeholder={t("common.form.name.option.lastName.placeholder")}
|
||||||
error={!!fieldState.error}
|
error={!!fieldState.error}
|
||||||
helperText={fieldState.error?.message ?? ""}
|
helperText={fieldState.error?.message ?? ""}
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -119,8 +119,8 @@ export const AddTeamMemberDialog = ({
|
|||||||
render={({ field, fieldState }) => (
|
render={({ field, fieldState }) => (
|
||||||
<TextField
|
<TextField
|
||||||
{...field}
|
{...field}
|
||||||
fieldLabel={t("pages.auth.common.form.option.email.label")}
|
fieldLabel={t("common.form.email.option.email.label")}
|
||||||
placeholder={t("pages.auth.common.form.option.email.placeholder")}
|
placeholder={t("common.form.email.option.email.placeholder")}
|
||||||
type="email"
|
type="email"
|
||||||
error={!!fieldState.error}
|
error={!!fieldState.error}
|
||||||
helperText={fieldState.error?.message ?? ""}
|
helperText={fieldState.error?.message ?? ""}
|
||||||
@@ -136,8 +136,7 @@ export const AddTeamMemberDialog = ({
|
|||||||
{...field}
|
{...field}
|
||||||
value={field.value[0] ?? "user"}
|
value={field.value[0] ?? "user"}
|
||||||
onChange={(e) => field.onChange([e.target.value])}
|
onChange={(e) => field.onChange([e.target.value])}
|
||||||
fieldLabel={t("pages.account.team.invite.role.label")}
|
fieldLabel={t("common.form.role.option.role.label")}
|
||||||
placeholder={t("pages.account.team.invite.role.placeholder")}
|
|
||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
{roleOptions.map((option) => (
|
{roleOptions.map((option) => (
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ export const InviteTeamMemberDialog = ({
|
|||||||
render={({ field, fieldState }) => (
|
render={({ field, fieldState }) => (
|
||||||
<TextField
|
<TextField
|
||||||
{...field}
|
{...field}
|
||||||
fieldLabel={t("pages.account.team.invite.email.label")}
|
fieldLabel={t("common.form.email.option.email.label")}
|
||||||
placeholder={t("pages.account.team.invite.email.placeholder")}
|
placeholder={t("common.form.email.option.email.placeholder")}
|
||||||
type="email"
|
type="email"
|
||||||
fullWidth
|
fullWidth
|
||||||
error={!!fieldState.error}
|
error={!!fieldState.error}
|
||||||
@@ -122,8 +122,7 @@ export const InviteTeamMemberDialog = ({
|
|||||||
{...field}
|
{...field}
|
||||||
value={Array.isArray(value) ? (value[0] ?? "") : ""}
|
value={Array.isArray(value) ? (value[0] ?? "") : ""}
|
||||||
onChange={(e) => onChange([e.target.value as UserRole])}
|
onChange={(e) => onChange([e.target.value as UserRole])}
|
||||||
fieldLabel={t("pages.account.team.invite.role.label")}
|
fieldLabel={t("common.form.role.option.role.label")}
|
||||||
placeholder={t("pages.account.team.invite.role.placeholder")}
|
|
||||||
fullWidth
|
fullWidth
|
||||||
error={!!fieldState.error}
|
error={!!fieldState.error}
|
||||||
>
|
>
|
||||||
|
|||||||
+16
-11
@@ -238,6 +238,13 @@
|
|||||||
"responseTime": "Response time"
|
"responseTime": "Response time"
|
||||||
},
|
},
|
||||||
"form": {
|
"form": {
|
||||||
|
"role": {
|
||||||
|
"option": {
|
||||||
|
"role": {
|
||||||
|
"label": "Roles"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"option": {
|
"option": {
|
||||||
"firstName": {
|
"firstName": {
|
||||||
@@ -544,17 +551,7 @@
|
|||||||
"form": {
|
"form": {
|
||||||
"name": {
|
"name": {
|
||||||
"title": "Name",
|
"title": "Name",
|
||||||
"description": "Update your personal information",
|
"description": "Update your personal information"
|
||||||
"option": {
|
|
||||||
"firstName": {
|
|
||||||
"label": "First name",
|
|
||||||
"placeholder": "Enter your first name"
|
|
||||||
},
|
|
||||||
"lastName": {
|
|
||||||
"label": "Last name",
|
|
||||||
"placeholder": "Enter your last name"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"photo": {
|
"photo": {
|
||||||
"title": "Profile photo",
|
"title": "Profile photo",
|
||||||
@@ -822,6 +819,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"editUser": {
|
||||||
|
"form": {
|
||||||
|
"roles": {
|
||||||
|
"title": "Roles",
|
||||||
|
"description": "Assign roles to the user. Multiple roles can be selected."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"incidents": {
|
"incidents": {
|
||||||
"dialog": {
|
"dialog": {
|
||||||
"details": {
|
"details": {
|
||||||
|
|||||||
Reference in new issue
Block a user