Fixed up getInitials helper

This commit is contained in:
Simon Backx 2022-07-06 09:28:05 +02:00
parent 9e445b8307
commit 5479993c96
2 changed files with 4 additions and 13 deletions

View File

@ -25,7 +25,7 @@ class Comment extends React.Component {
getInitials() {
const comment = this.props.comment;
return this.getInitials(comment.member.name);
return getInitials(comment.member.name);
}
render() {
@ -39,7 +39,7 @@ class Comment extends React.Component {
<div className="flex mb-2 space-x-4 justify-start items-center">
<figure className="relative w-10 h-10">
<div className="flex justify-center items-center w-10 h-10 rounded-full bg-black">
<p className="text-white font-sans font-semibold">{ getInitials() }</p>
<p className="text-white font-sans font-semibold">{ this.getInitials() }</p>
</div>
<img className="absolute top-0 left-0 w-10 h-10 rounded-full" src={comment.member.avatar_image} alt="Avatar"/>
</figure>

View File

@ -1,5 +1,6 @@
import React from 'react';
import AppContext from '../AppContext';
import {getInitials} from '../utils/helpers';
class Form extends React.Component {
static contextType = AppContext;
@ -54,17 +55,7 @@ class Form extends React.Component {
if (!this.context.member || !this.context.member.name) {
return '';
}
const parts = this.context.member.name.split(' ');
if (parts.length === 0) {
return '';
}
if (parts.length === 1) {
return parts[0].substring(0, 1);
}
return parts[0].substring(0, 1) + parts[parts.length - 1].substring(0, 1);
return getInitials(this.context.member.name);
}
render() {