import type { Metadata } from "next"; import Link from "next/link"; import { redirect } from "next/navigation"; import { ActionForm, SubmitButton } from "@/components/forms"; import { PageHeader, Tag } from "@/components/status"; import { DateTime } from "@/components/time"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"; import { Input } from "@/components/ui/input"; import { NativeSelect, NativeSelectOption } from "@/components/ui/native-select"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; import { Textarea } from "@/components/ui/textarea"; import { api, getMe, unwrap, type ImportGrant } from "@/lib/api"; import { changeGrant, createGrant, requestProduct } from "./actions"; export const metadata: Metadata = { title: "Imports" }; const statusTone = { pending: "neutral", active: "online", declined: "danger", suspended: "danger", withdrawn: "neutral", } as const; const imvuPage = (id: number) => `https://www.imvu.com/shop/product.php?products_id=${id}`; export default async function Imports() { const me = await getMe(); if (!me) redirect("/signin?next=/imports"); const [account, offered, mine] = await Promise.all([ api.account.get().then(unwrap), api.imports.catalogs.get().then(unwrap), api.imports.grants.get().then(unwrap), ]); const asked = await Promise.all( account.links.map(async (l) => ({ link: l, requests: unwrap(await api.imports.requests.get({ query: { imvuCreator: l.imvuId } })).requests, })), ); const open = mine.grants.filter((g) => g.status !== "withdrawn" && g.status !== "declined"); const ended = mine.grants.filter((g) => g.status === "withdrawn" || g.status === "declined"); return (
First{" "} link your IMVU account , the one that made the products.
) : offered.catalogs.length === 0 ? (No catalog takes imports yet.
) : ({offered.consent.text}
{a.link.username}
{g.statusReason}
}{g.scope === "shop" ? `Your whole shop${g.exclude.length ? `, less ${g.exclude.length} left out` : ""}.` : `${g.products.length} chosen product${g.products.length === 1 ? "" : "s"}.`}{" "} {g.listed ? "Listed." : "Unlisted."}
{g.status === "suspended" ? (Withdraw it, then bring your products again to start over.
) : null}