[chore] Settings refactor 2: the re-refactoring-ing (#2866)

* [chore] Bit more refactoring of settings panel

* fix up some remaining things

* groovy baby yeah!

* remove unused Suspense
This commit is contained in:
tobi 2024-04-25 18:24:24 +02:00 committed by GitHub
commit aecf74951c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 1360 additions and 958 deletions

View file

@ -19,8 +19,14 @@
import React from "react";
import { Link } from "wouter";
import { AdminAccount } from "../../../lib/types/account";
export default function Username({ user, link = true }) {
interface UsernameProps {
user: AdminAccount;
link?: string;
}
export default function Username({ user, link }: UsernameProps) {
let className = "user";
let isLocal = user.domain == null;
@ -36,19 +42,25 @@ export default function Username({ user, link = true }) {
? { fa: "fa-home", info: "Local user" }
: { fa: "fa-external-link-square", info: "Remote user" };
let Element: any = "div";
let href: any = null;
if (link) {
Element = Link;
href = `/settings/admin/accounts/${user.id}`;
}
return (
<Element className={className} to={href}>
const content = (
<>
<span className="acct">@{user.account.acct}</span>
<i className={`fa fa-fw ${icon.fa}`} aria-hidden="true" title={icon.info} />
<span className="sr-only">{icon.info}</span>
</Element>
</>
);
if (link) {
return (
<Link className={className} to={link}>
{content}
</Link>
);
} else {
return (
<div className={className}>
{content}
</div>
);
}
}