firtname and lastname before username
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
export const buildFullName = ({ firstName, lastName, displayName } = {}) => {
|
||||
const first =
|
||||
typeof firstName === "string" && firstName.trim().length > 0
|
||||
? firstName.trim()
|
||||
: "";
|
||||
const last =
|
||||
typeof lastName === "string" && lastName.trim().length > 0
|
||||
? lastName.trim()
|
||||
: "";
|
||||
const nameFromParts = [first, last].filter(Boolean).join(" ").trim();
|
||||
if (nameFromParts) return nameFromParts;
|
||||
|
||||
const fallbackDisplay =
|
||||
typeof displayName === "string" && displayName.trim().length > 0
|
||||
? displayName.trim()
|
||||
: "";
|
||||
return fallbackDisplay || null;
|
||||
};
|
||||
|
||||
export const getArtistDisplayName = (source, fallback = "") => {
|
||||
if (!source) return fallback;
|
||||
const rawUserName =
|
||||
typeof source?.userName === "string" ? source.userName.trim() : "";
|
||||
if (rawUserName) return rawUserName;
|
||||
|
||||
const nameFromParts = buildFullName({
|
||||
firstName: source?.firstName,
|
||||
lastName: source?.lastName,
|
||||
displayName: source?.displayName,
|
||||
});
|
||||
|
||||
if (nameFromParts) return nameFromParts;
|
||||
return fallback;
|
||||
};
|
||||
|
||||
export const getUserPreferredArtistName = (user) => {
|
||||
const display = getArtistDisplayName(user, "");
|
||||
return display || null;
|
||||
};
|
||||
Reference in New Issue
Block a user