feat(frontend): add flags to user page

This commit is contained in:
sam 2024-09-29 20:24:47 +02:00
parent f539902711
commit dc18ab60d2
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
10 changed files with 68 additions and 5 deletions

View file

@ -0,0 +1,32 @@
import { Pronoun } from "~/lib/api/user";
import { Link } from "@remix-run/react";
export default function PronounLink({ pronoun }: { pronoun: Pronoun }) {
let displayText: string;
if (pronoun.display_text) displayText = pronoun.display_text;
else {
const split = pronoun.value.split("/");
if (split.length === 5) displayText = split.splice(0, 2).join("/");
else displayText = pronoun.value;
}
let link: string;
const linkBase = pronoun.value
.split("/")
.map((value) => encodeURIComponent(value))
.join("/");
if (pronoun.display_text) {
link = `${linkBase},${encodeURIComponent(pronoun.display_text)}`;
} else {
link = linkBase;
}
return pronoun.value.split("/").length === 5 ? (
<Link className="text-reset" to={`/pronouns/${link}`}>
{displayText}
</Link>
) : (
<>{displayText}</>
);
}