mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
format code
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useNavigate } from "react-router";
|
import { useNavigate } from "react-router";
|
||||||
import {
|
import { MdOutlineComment } from "react-icons/md";
|
||||||
MdOutlineComment,
|
|
||||||
} from "react-icons/md";
|
|
||||||
import { Comment } from "../network/models";
|
import { Comment } from "../network/models";
|
||||||
import { network } from "../network/network";
|
import { network } from "../network/network";
|
||||||
import Badge from "./badge";
|
import Badge from "./badge";
|
||||||
|
@@ -46,7 +46,7 @@ export default function CommentPage() {
|
|||||||
|
|
||||||
const onUpdated = useCallback(() => {
|
const onUpdated = useCallback(() => {
|
||||||
setComment(null);
|
setComment(null);
|
||||||
const id = parseInt(commentId || "0");
|
const id = parseInt(commentId || "0");
|
||||||
if (isNaN(id) || id <= 0) {
|
if (isNaN(id) || id <= 0) {
|
||||||
showToast({
|
showToast({
|
||||||
message: t("Invalid comment ID"),
|
message: t("Invalid comment ID"),
|
||||||
@@ -116,11 +116,11 @@ export default function CommentPage() {
|
|||||||
<CommentContent content={comment.content} />
|
<CommentContent content={comment.content} />
|
||||||
</article>
|
</article>
|
||||||
{app.user?.id === comment.user.id && (
|
{app.user?.id === comment.user.id && (
|
||||||
<div className="flex flex-row justify-end mt-2">
|
<div className="flex flex-row justify-end mt-2">
|
||||||
<EditCommentDialog comment={comment} onUpdated={onUpdated} />
|
<EditCommentDialog comment={comment} onUpdated={onUpdated} />
|
||||||
<DeleteCommentDialog commentId={comment.id} onUpdated={onDeleted} />
|
<DeleteCommentDialog commentId={comment.id} onUpdated={onDeleted} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="h-4" />
|
<div className="h-4" />
|
||||||
<div className="border-t border-base-300" />
|
<div className="border-t border-base-300" />
|
||||||
<div className="h-4" />
|
<div className="h-4" />
|
||||||
@@ -282,7 +282,6 @@ function CommentsList({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function EditCommentDialog({
|
function EditCommentDialog({
|
||||||
comment,
|
comment,
|
||||||
onUpdated,
|
onUpdated,
|
||||||
@@ -460,4 +459,4 @@ function DeleteCommentDialog({
|
|||||||
</dialog>
|
</dialog>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,8 @@ import Markdown from "react-markdown";
|
|||||||
import "../markdown.css";
|
import "../markdown.css";
|
||||||
import Loading from "../components/loading.tsx";
|
import Loading from "../components/loading.tsx";
|
||||||
import {
|
import {
|
||||||
MdAdd, MdOutlineArchive,
|
MdAdd,
|
||||||
|
MdOutlineArchive,
|
||||||
MdOutlineArticle,
|
MdOutlineArticle,
|
||||||
MdOutlineComment,
|
MdOutlineComment,
|
||||||
MdOutlineDataset,
|
MdOutlineDataset,
|
||||||
|
@@ -8,7 +8,11 @@ import Loading from "../components/loading";
|
|||||||
import Pagination from "../components/pagination";
|
import Pagination from "../components/pagination";
|
||||||
import { CommentTile } from "../components/comment_tile.tsx";
|
import { CommentTile } from "../components/comment_tile.tsx";
|
||||||
import Badge from "../components/badge.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";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export default function UserPage() {
|
export default function UserPage() {
|
||||||
@@ -69,7 +73,10 @@ export default function UserPage() {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<UserCard user={user!} />
|
<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
|
<div
|
||||||
role="tab"
|
role="tab"
|
||||||
className={`tab ${page === 0 ? "tab-active" : ""} `}
|
className={`tab ${page === 0 ? "tab-active" : ""} `}
|
||||||
@@ -97,42 +104,51 @@ export default function UserPage() {
|
|||||||
function UserCard({ user }: { user: User }) {
|
function UserCard({ user }: { user: User }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const statistics = <p className="mt-2">
|
const statistics = (
|
||||||
<Badge className="badge-soft badge-primary badge-lg m-1">
|
<p className="mt-2">
|
||||||
<MdOutlinePhotoAlbum size={18} />
|
<Badge className="badge-soft badge-primary badge-lg m-1">
|
||||||
<span className="ml-1 text-sm">{t("Resources")} {user.resources_count}</span>
|
<MdOutlinePhotoAlbum size={18} />
|
||||||
</Badge>
|
<span className="ml-1 text-sm">
|
||||||
<Badge className="badge-soft badge-secondary badge-lg m-1">
|
{t("Resources")} {user.resources_count}
|
||||||
<MdOutlineArchive size={18} />
|
</span>
|
||||||
<span className="ml-1 text-sm">{t('Files')} {user.files_count}</span>
|
</Badge>
|
||||||
</Badge>
|
<Badge className="badge-soft badge-secondary badge-lg m-1">
|
||||||
<Badge className="badge-soft badge-accent badge-lg m-1">
|
<MdOutlineArchive size={18} />
|
||||||
<MdOutlineComment size={18} />
|
<span className="ml-1 text-sm">
|
||||||
<span className="ml-1 text-sm">{t("Comments")} {user.comments_count}</span>
|
{t("Files")} {user.files_count}
|
||||||
</Badge>
|
</span>
|
||||||
</p>
|
</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() !== "";
|
const haveBio = user.bio.trim() !== "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={"flex m-4 items-center"}>
|
<div className={"flex m-4 items-center"}>
|
||||||
<div className={"avatar py-2"}>
|
<div className={"avatar py-2"}>
|
||||||
<div className="w-24 rounded-full ring-2 ring-offset-2 ring-primary ring-offset-base-100">
|
<div className="w-24 rounded-full ring-2 ring-offset-2 ring-primary ring-offset-base-100">
|
||||||
<img alt={"avatar"} src={network.getUserAvatar(user)} />
|
<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>
|
</div>
|
||||||
<div className="w-6"></div>
|
{haveBio && <div className="mb-2 mx-2">{statistics}</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>}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user