Skip to content

Commit

Permalink
Merge pull request #132 from daithihearn/enhancement/format-names
Browse files Browse the repository at this point in the history
Formatting user names
  • Loading branch information
daithihearn authored Feb 26, 2023
2 parents 6fcbfc1 + 5541d05 commit db3bded
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "5.3.1",
"version": "5.3.2",
"description": "React frontend for the Cards 110",
"author": "Daithi Hearn",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"short_name": "Cards 110",
"name": "Cards 110",
"version": "5.3.1",
"version": "5.3.2",
"icons": [
{
"src": "./assets/favicon.png",
Expand Down
3 changes: 2 additions & 1 deletion src/components/GameStats/PlayerSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getMyProfile } from "../../caches/MyProfileSlice"
import { getPlayerProfiles } from "../../caches/PlayerProfilesSlice"
import { PlayerProfile } from "../../model/Player"
import StatsService from "../../services/StatsService"
import { FormatName } from "../../utils/FormattingUtils"

const PlayerSwitcher: React.FC = () => {
const dispatch = useAppDispatch()
Expand Down Expand Up @@ -70,7 +71,7 @@ const PlayerSwitcher: React.FC = () => {
<DropdownItem
key={p.id}
onClick={() => setCurrentPlayer(p)}>
{p.name}
{FormatName(p.name)}
</DropdownItem>
)
})}
Expand Down
2 changes: 0 additions & 2 deletions src/components/Leaderboard/DoublesLeaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ const DoublesLeaderboard = () => {

const columns: TableColumn<DoublesLeaderboardItem>[] = [
{
name: "Player 1",
cell: row => (
<>
<div>
Expand Down Expand Up @@ -137,7 +136,6 @@ const DoublesLeaderboard = () => {
),
},
{
name: "Player 2",
cell: row => (
<div>
<img
Expand Down
1 change: 0 additions & 1 deletion src/components/Leaderboard/SinglesLeaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ const SinglesLeaderboard = () => {
const columns: TableColumn<LeaderboardItem>[] = useMemo(
() => [
{
name: "Avatar",
cell: row => (
<img alt={row.name} src={row.picture} className="avatar" />
),
Expand Down
2 changes: 2 additions & 0 deletions src/components/StartNewGame/StartNewGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useSnackbar } from "notistack"
import { customStyles } from "../Tables/CustomStyles"
import parseError from "../../utils/ErrorUtils"
import moment from "moment"
import { FormatName } from "../../utils/FormattingUtils"

const StartNewGame = () => {
const dispatch = useAppDispatch()
Expand Down Expand Up @@ -94,6 +95,7 @@ const StartNewGame = () => {
{
name: "Player",
selector: row => row.name,
format: row => FormatName(row.name),
sortable: true,
},
{
Expand Down
10 changes: 10 additions & 0 deletions src/utils/FormattingUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const FormatName = (name: string) =>
name
.split(" ")
.map(word =>
word.length < 3
? word
: word.charAt(0).toUpperCase() +
word.slice(1).toLocaleLowerCase(),
)
.join(" ")

0 comments on commit db3bded

Please sign in to comment.