mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-05-13 13:17:45 +00:00
Compare commits
2 commits
97f0fda25c
...
e81f054e3a
| Author | SHA1 | Date | |
|---|---|---|---|
| e81f054e3a | |||
| ce1c7a667a |
3 changed files with 23 additions and 3 deletions
|
|
@ -9,6 +9,7 @@ import { Icon } from "@iconify/react";
|
||||||
import LikeButton from "../../like-button";
|
import LikeButton from "../../like-button";
|
||||||
import { useStore } from "@nanostores/react";
|
import { useStore } from "@nanostores/react";
|
||||||
import { session } from "../../../session";
|
import { session } from "../../../session";
|
||||||
|
import Carousel from "../../carousel";
|
||||||
|
|
||||||
interface ApiResponse {
|
interface ApiResponse {
|
||||||
totalCount: number;
|
totalCount: number;
|
||||||
|
|
@ -79,7 +80,7 @@ export default function MiiList({ parentPage, userId }: Props) {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Link to={`/mii/${mii.id}`} className="overflow-hidden rounded-xl bg-zinc-300 shrink-0">
|
{parentPage !== "admin" ? <Link to={`/mii/${mii.id}`} className="overflow-hidden rounded-xl bg-zinc-300 shrink-0">
|
||||||
<img
|
<img
|
||||||
src={`${import.meta.env.VITE_API_URL}/mii/${mii.id}/image?type=mii`}
|
src={`${import.meta.env.VITE_API_URL}/mii/${mii.id}/image?type=mii`}
|
||||||
width={240}
|
width={240}
|
||||||
|
|
@ -87,7 +88,13 @@ export default function MiiList({ parentPage, userId }: Props) {
|
||||||
alt="mii image"
|
alt="mii image"
|
||||||
className="w-full h-auto aspect-3/2 object-contain"
|
className="w-full h-auto aspect-3/2 object-contain"
|
||||||
/>
|
/>
|
||||||
</Link>
|
</Link> : <Carousel
|
||||||
|
images={[
|
||||||
|
`${import.meta.env.VITE_API_URL}/mii/${mii.id}/image?type=mii`,
|
||||||
|
...(mii.platform === "THREE_DS" ? [`${import.meta.env.VITE_API_URL}/mii/${mii.id}/image?type=qr-code`] : [`${import.meta.env.VITE_API_URL}/mii/${mii.id}/image?type=features`]),
|
||||||
|
...Array.from({ length: mii.imageCount }, (_, index) => `${import.meta.env.VITE_API_URL}/mii/${mii.id}/image?type=image${index}`),
|
||||||
|
]}
|
||||||
|
/>}
|
||||||
|
|
||||||
<div className="p-4 flex flex-col gap-1 h-full">
|
<div className="p-4 flex flex-col gap-1 h-full">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
|
|
@ -134,7 +141,7 @@ export default function MiiList({ parentPage, userId }: Props) {
|
||||||
<div className="flex gap-1 text-3xl justify-center">
|
<div className="flex gap-1 text-3xl justify-center">
|
||||||
<button
|
<button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
await fetch(`/api/admin/accept-mii?id=${mii.id}`, { method: "PATCH" });
|
await fetch(`${import.meta.env.VITE_API_URL}/api/admin/accept-mii?id=${mii.id}`, { method: "PATCH", credentials: "include" });
|
||||||
}}
|
}}
|
||||||
className="cursor-pointer text-zinc-400 hover:text-green-500 transition-colors p-1 bg-white rounded-md shadow-sm border border-zinc-200 hover:border-green-500"
|
className="cursor-pointer text-zinc-400 hover:text-green-500 transition-colors p-1 bg-white rounded-md shadow-sm border border-zinc-200 hover:border-green-500"
|
||||||
title="Accept Mii"
|
title="Accept Mii"
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import ProfileLayout from "./pages/profile/layout.tsx";
|
||||||
import ProfileLikesPage from "./pages/profile/likes.tsx";
|
import ProfileLikesPage from "./pages/profile/likes.tsx";
|
||||||
import ReportMiiPage from "./pages/report/mii.tsx";
|
import ReportMiiPage from "./pages/report/mii.tsx";
|
||||||
import ReportUserPage from "./pages/report/user.tsx";
|
import ReportUserPage from "./pages/report/user.tsx";
|
||||||
|
import AdminPage from "./pages/admin.tsx";
|
||||||
|
|
||||||
createRoot(document.getElementById("root")!).render(
|
createRoot(document.getElementById("root")!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
|
|
@ -43,6 +44,7 @@ createRoot(document.getElementById("root")!).render(
|
||||||
<Route path="/out" element={<LinkOutPage />} />
|
<Route path="/out" element={<LinkOutPage />} />
|
||||||
<Route path="/privacy" element={<PrivacyPage />} />
|
<Route path="/privacy" element={<PrivacyPage />} />
|
||||||
<Route path="/terms-of-service" element={<TermsOfServicePage />} />
|
<Route path="/terms-of-service" element={<TermsOfServicePage />} />
|
||||||
|
<Route path="/admin" element={<AdminPage />} />
|
||||||
<Route path="*" element={<NotFoundPage />} />
|
<Route path="*" element={<NotFoundPage />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
|
||||||
11
frontend/src/pages/admin.tsx
Normal file
11
frontend/src/pages/admin.tsx
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { useStore } from "@nanostores/react";
|
||||||
|
import MiiList from "../components/mii/list";
|
||||||
|
import { session } from "../session";
|
||||||
|
import { Navigate } from "react-router";
|
||||||
|
|
||||||
|
export default function AdminPage() {
|
||||||
|
const $session = useStore(session);
|
||||||
|
if ($session === undefined) return <div className="p-6 text-center">Loading...</div>;
|
||||||
|
if ($session === null || ($session && Number($session?.user?.id) !== 1)) return <Navigate to="/404" replace />;
|
||||||
|
return <MiiList parentPage="admin" />;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue