mirror of
https://github.com/strapi/strapi.git
synced 2025-08-09 09:14:49 +00:00
fix: updated parts depending on lastname
This commit is contained in:
parent
6213d2dc7b
commit
5402ff323b
@ -9,12 +9,13 @@ import PluginsInitializer from '../PluginsInitializer';
|
||||
import RBACProvider from '../RBACProvider';
|
||||
import { fetchAppInfo, fetchCurrentUserPermissions, fetchStrapiLatestRelease } from './utils/api';
|
||||
import checkLatestStrapiVersion from './utils/checkLatestStrapiVersion';
|
||||
import { getFullName } from '../../utils';
|
||||
|
||||
const strapiVersion = packageJSON.version;
|
||||
|
||||
const AuthenticatedApp = () => {
|
||||
const userInfo = auth.getUserInfo();
|
||||
const userName = get(userInfo, 'username') || `${userInfo.firstname} ${userInfo.lastname}`;
|
||||
const userName = get(userInfo, 'username') || getFullName(userInfo.firstname, userInfo.lastname);
|
||||
const [userDisplayName, setUserDisplayName] = useState(userName);
|
||||
const { showReleaseNotification } = useConfigurations();
|
||||
const [
|
||||
|
@ -13,6 +13,7 @@ import { useHistory } from 'react-router-dom';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { usePluginsQueryParams } from '../../../hooks';
|
||||
import CellContent from '../CellContent';
|
||||
import { getFullName } from '../../../../utils';
|
||||
|
||||
const TableRows = ({
|
||||
canCreate,
|
||||
@ -69,7 +70,7 @@ const TableRows = ({
|
||||
id: 'app.component.table.select.one-entry',
|
||||
defaultMessage: `Select {target}`,
|
||||
},
|
||||
{ target: `${data.firstname} ${data.lastname}` }
|
||||
{ target: getFullName(data.firstname, data.lastname) }
|
||||
)}
|
||||
checked={isChecked}
|
||||
onChange={() => {
|
||||
|
@ -8,6 +8,7 @@ import { Flex } from '@strapi/design-system/Flex';
|
||||
import { Stack } from '@strapi/design-system/Stack';
|
||||
import { getTrad } from '../../../utils';
|
||||
import getUnits from './utils/getUnits';
|
||||
import { getFullName } from '../../../../utils';
|
||||
|
||||
const Informations = () => {
|
||||
const { formatMessage, formatRelativeTime } = useIntl();
|
||||
@ -17,7 +18,7 @@ const Informations = () => {
|
||||
const updatedByFirstname = initialData.updatedBy?.firstname || '';
|
||||
const updatedByLastname = initialData.updatedBy?.lastname || '';
|
||||
const updatedByUsername = initialData.updatedBy?.username;
|
||||
const updatedBy = updatedByUsername || `${updatedByFirstname} ${updatedByLastname}`;
|
||||
const updatedBy = updatedByUsername || getFullName(updatedByFirstname, updatedByLastname);
|
||||
const currentTime = useRef(Date.now());
|
||||
const timestamp = initialData[updatedAt]
|
||||
? new Date(initialData[updatedAt]).getTime()
|
||||
|
@ -33,6 +33,7 @@ import Check from '@strapi/icons/Check';
|
||||
import useLocalesProvider from '../../components/LocalesProvider/useLocalesProvider';
|
||||
import { fetchUser, putUser } from './utils/api';
|
||||
import schema from './utils/schema';
|
||||
import { getFullName } from '../../utils';
|
||||
|
||||
const PasswordInput = styled(TextInput)`
|
||||
::-ms-reveal {
|
||||
@ -87,7 +88,7 @@ const ProfilePage = () => {
|
||||
await queryClient.invalidateQueries('user');
|
||||
|
||||
auth.setUserInfo(data);
|
||||
const userDisplayName = data.username || `${data.firstname} ${data.lastname}`;
|
||||
const userDisplayName = data.username || getFullName(data.firstname, data.lastname);
|
||||
setUserDisplayName(userDisplayName);
|
||||
changeLocale(data.preferedLanguage);
|
||||
|
||||
@ -172,7 +173,7 @@ const ProfilePage = () => {
|
||||
return (
|
||||
<Form>
|
||||
<HeaderLayout
|
||||
title={data.username || `${data.firstname} ${data.lastname}`}
|
||||
title={data.username || getFullName(data.firstname, data.lastname)}
|
||||
primaryAction={
|
||||
<Button startIcon={<Check />} loading={isSubmitting} type="submit">
|
||||
{formatMessage({ id: 'form.button.save', defaultMessage: 'Save' })}
|
||||
|
@ -29,7 +29,7 @@ import { Stack } from '@strapi/design-system/Stack';
|
||||
import ArrowLeft from '@strapi/icons/ArrowLeft';
|
||||
import Check from '@strapi/icons/Check';
|
||||
import MagicLink from 'ee_else_ce/pages/SettingsPage/pages/Users/components/MagicLink';
|
||||
import { formatAPIErrors } from '../../../../../utils';
|
||||
import { formatAPIErrors, getFullName } from '../../../../../utils';
|
||||
import { fetchUser, putUser } from './utils/api';
|
||||
import layout from './utils/layout';
|
||||
import { editValidation } from '../utils/validations/users';
|
||||
@ -89,7 +89,7 @@ const EditPage = ({ canUpdate }) => {
|
||||
if (id.toString() === userInfos.id.toString()) {
|
||||
auth.setUserInfo(data);
|
||||
|
||||
const userDisplayName = get(body, 'username') || `${body.firstname} ${body.lastname}`;
|
||||
const userDisplayName = get(body, 'username') || getFullName(body.firstname, body.lastname);
|
||||
|
||||
setUserDisplayName(userDisplayName);
|
||||
}
|
||||
@ -131,7 +131,7 @@ const EditPage = ({ canUpdate }) => {
|
||||
}, {});
|
||||
|
||||
const headerLabelName =
|
||||
initialData.username || `${initialData.firstname} ${initialData.lastname}`;
|
||||
initialData.username || getFullName(initialData.firstname, initialData.lastname);
|
||||
|
||||
const title = formatMessage(headerLabel, { name: headerLabelName });
|
||||
|
||||
|
@ -11,6 +11,7 @@ import Trash from '@strapi/icons/Trash';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { stopPropagation, onRowClick } from '@strapi/helper-plugin';
|
||||
import { getFullName } from '../../../../../../../utils';
|
||||
|
||||
const TableRows = ({
|
||||
canDelete,
|
||||
@ -49,7 +50,7 @@ const TableRows = ({
|
||||
id: 'app.component.table.select.one-entry',
|
||||
defaultMessage: `Select {target}`,
|
||||
},
|
||||
{ target: `${data.firstname} ${data.lastname}` }
|
||||
{ target: getFullName(data.firstname, data.lastname) }
|
||||
)}
|
||||
checked={isChecked}
|
||||
onChange={() => {
|
||||
@ -77,7 +78,7 @@ const TableRows = ({
|
||||
onClick={() => push(`${pathname}/${data.id}`)}
|
||||
label={formatMessage(
|
||||
{ id: 'app.component.table.edit', defaultMessage: 'Edit {target}' },
|
||||
{ target: `${data.firstname} ${data.lastname}` }
|
||||
{ target: getFullName(data.firstname, data.lastname) }
|
||||
)}
|
||||
noBorder
|
||||
icon={<Pencil />}
|
||||
@ -89,7 +90,7 @@ const TableRows = ({
|
||||
onClick={() => onClickDelete(data.id)}
|
||||
label={formatMessage(
|
||||
{ id: 'app.component.table.delete', defaultMessage: 'Delete {target}' },
|
||||
{ target: `${data.firstname} ${data.lastname}` }
|
||||
{ target: getFullName(data.firstname, data.lastname) }
|
||||
)}
|
||||
noBorder
|
||||
icon={<Trash />}
|
||||
|
9
packages/core/admin/admin/src/utils/getFullName.js
Normal file
9
packages/core/admin/admin/src/utils/getFullName.js
Normal file
@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Get fullname from firstname+lastname joined with a space
|
||||
* Handle missing lastname
|
||||
* @param {string} firstname
|
||||
* @param {string} lastname
|
||||
*/
|
||||
export default (firstname, lastname = '') => {
|
||||
return [firstname, lastname].filter(e => e !== '').join(' ');
|
||||
};
|
@ -5,5 +5,5 @@ export { default as getAttributesToDisplay } from './getAttributesToDisplay';
|
||||
export { default as makeUniqueRoutes } from './makeUniqueRoutes';
|
||||
export { default as sortLinks } from './sortLinks';
|
||||
export { default as getExistingActions } from './getExistingActions';
|
||||
|
||||
export { default as getRequestUrl } from './getRequestUrl';
|
||||
export { default as getFullName } from './getFullName';
|
||||
|
Loading…
x
Reference in New Issue
Block a user