format code

This commit is contained in:
2025-07-09 18:11:33 +08:00
parent d84b8314e4
commit 0eb24eee2f
4 changed files with 56 additions and 42 deletions

View File

@@ -1,8 +1,6 @@
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router";
import {
MdOutlineComment,
} from "react-icons/md";
import { MdOutlineComment } from "react-icons/md";
import { Comment } from "../network/models";
import { network } from "../network/network";
import Badge from "./badge";

View File

@@ -46,7 +46,7 @@ export default function CommentPage() {
const onUpdated = useCallback(() => {
setComment(null);
const id = parseInt(commentId || "0");
const id = parseInt(commentId || "0");
if (isNaN(id) || id <= 0) {
showToast({
message: t("Invalid comment ID"),
@@ -116,11 +116,11 @@ export default function CommentPage() {
<CommentContent content={comment.content} />
</article>
{app.user?.id === comment.user.id && (
<div className="flex flex-row justify-end mt-2">
<EditCommentDialog comment={comment} onUpdated={onUpdated} />
<DeleteCommentDialog commentId={comment.id} onUpdated={onDeleted} />
</div>
)}
<div className="flex flex-row justify-end mt-2">
<EditCommentDialog comment={comment} onUpdated={onUpdated} />
<DeleteCommentDialog commentId={comment.id} onUpdated={onDeleted} />
</div>
)}
<div className="h-4" />
<div className="border-t border-base-300" />
<div className="h-4" />
@@ -282,7 +282,6 @@ function CommentsList({
);
}
function EditCommentDialog({
comment,
onUpdated,
@@ -460,4 +459,4 @@ function DeleteCommentDialog({
</dialog>
</>
);
}
}

View File

@@ -23,7 +23,8 @@ import Markdown from "react-markdown";
import "../markdown.css";
import Loading from "../components/loading.tsx";
import {
MdAdd, MdOutlineArchive,
MdAdd,
MdOutlineArchive,
MdOutlineArticle,
MdOutlineComment,
MdOutlineDataset,

View File

@@ -8,7 +8,11 @@ import Loading from "../components/loading";
import Pagination from "../components/pagination";
import { CommentTile } from "../components/comment_tile.tsx";
import Badge from "../components/badge.tsx";
import { MdOutlineArchive, MdOutlineComment, MdOutlinePhotoAlbum, MdPhotoAlbum } from "react-icons/md";
import {
MdOutlineArchive,
MdOutlineComment,
MdOutlinePhotoAlbum,
} from "react-icons/md";
import { useTranslation } from "react-i18next";
export default function UserPage() {
@@ -69,7 +73,10 @@ export default function UserPage() {
return (
<div>
<UserCard user={user!} />
<div role="tablist" className="border-b border-base-300 mx-2 flex tabs tabs-border">
<div
role="tablist"
className="border-b border-base-300 mx-2 flex tabs tabs-border"
>
<div
role="tab"
className={`tab ${page === 0 ? "tab-active" : ""} `}
@@ -97,42 +104,51 @@ export default function UserPage() {
function UserCard({ user }: { user: User }) {
const { t } = useTranslation();
const statistics = <p className="mt-2">
<Badge className="badge-soft badge-primary badge-lg m-1">
<MdOutlinePhotoAlbum size={18} />
<span className="ml-1 text-sm">{t("Resources")} {user.resources_count}</span>
</Badge>
<Badge className="badge-soft badge-secondary badge-lg m-1">
<MdOutlineArchive size={18} />
<span className="ml-1 text-sm">{t('Files')} {user.files_count}</span>
</Badge>
<Badge className="badge-soft badge-accent badge-lg m-1">
<MdOutlineComment size={18} />
<span className="ml-1 text-sm">{t("Comments")} {user.comments_count}</span>
</Badge>
</p>
const statistics = (
<p className="mt-2">
<Badge className="badge-soft badge-primary badge-lg m-1">
<MdOutlinePhotoAlbum size={18} />
<span className="ml-1 text-sm">
{t("Resources")} {user.resources_count}
</span>
</Badge>
<Badge className="badge-soft badge-secondary badge-lg m-1">
<MdOutlineArchive size={18} />
<span className="ml-1 text-sm">
{t("Files")} {user.files_count}
</span>
</Badge>
<Badge className="badge-soft badge-accent badge-lg m-1">
<MdOutlineComment size={18} />
<span className="ml-1 text-sm">
{t("Comments")} {user.comments_count}
</span>
</Badge>
</p>
);
const haveBio = user.bio.trim() !== "";
return (
<>
<div className={"flex m-4 items-center"}>
<div className={"avatar py-2"}>
<div className="w-24 rounded-full ring-2 ring-offset-2 ring-primary ring-offset-base-100">
<img alt={"avatar"} src={network.getUserAvatar(user)} />
<div className={"avatar py-2"}>
<div className="w-24 rounded-full ring-2 ring-offset-2 ring-primary ring-offset-base-100">
<img alt={"avatar"} src={network.getUserAvatar(user)} />
</div>
</div>
<div className="w-6"></div>
<div>
<h1 className="text-2xl font-bold">{user.username}</h1>
<div className="h-4"></div>
{haveBio ? (
<p className="text-sm text-base-content/80">{user.bio.trim()}</p>
) : (
statistics
)}
</div>
</div>
<div className="w-6"></div>
<div>
<h1 className="text-2xl font-bold">{user.username}</h1>
<div className="h-4"></div>
{haveBio ? (
<p className="text-sm text-base-content/80">{user.bio.trim()}</p>
): statistics}
</div>
</div>
{ haveBio && <div className="mb-2 mx-2">{statistics}</div>}
{haveBio && <div className="mb-2 mx-2">{statistics}</div>}
</>
);
}