[feat] create own function for showName

This commit is contained in:
Tim Gröger 2024-10-11 08:08:53 +02:00
parent 3f4f8a5fd4
commit d8d89f0475
2 changed files with 19 additions and 0 deletions

View File

@ -29,3 +29,4 @@ const plugin: FG_Plugin.Plugin = {
export default plugin;
export { DisplayNameMode };
export * from './utils';

18
src/utils/index.ts Normal file
View File

@ -0,0 +1,18 @@
import { DisplayNameMode } from '../models';
import { useUserStore } from '@flaschengeist/api';
export function showName(user: FG.User) {
const userStore = useUserStore();
switch (userStore.userSettings.display_name) {
case DisplayNameMode.DISPLAYNAME:
return user.display_name;
case DisplayNameMode.FIRSTNAME:
return user.firstname;
case DisplayNameMode.LASTNAME:
return user.lastname;
case DisplayNameMode.FIRSTNAME_LASTNAME:
return `${user.firstname} ${user.lastname}`;
case DisplayNameMode.LASTNAME_FIRSTNAME:
return `${user.lastname}, ${user.firstname}`;
}
}