feat(admin-images) : add standalone export generators
This commit is contained in:
@@ -6,6 +6,19 @@ import type { PublicGuide } from "@/lib/guides/queries";
|
||||
import { constellationChartRows } from "@/lib/guides/export-image";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export type ConstellationImageGuide = Pick<PublicGuide, "coverUrl"> & {
|
||||
character: Pick<PublicGuide["character"], "name" | "splashImageUrl">;
|
||||
};
|
||||
|
||||
export interface ConstellationImageGroup {
|
||||
note: string | null;
|
||||
rows: Array<{
|
||||
level: number;
|
||||
cumulativePercent: string;
|
||||
isGreat: boolean;
|
||||
}>;
|
||||
}
|
||||
|
||||
function percentage(value: number): string {
|
||||
return `${value.toLocaleString("en-US", { maximumFractionDigits: 2 })}%`;
|
||||
}
|
||||
@@ -14,8 +27,8 @@ export function ConstellationImage({
|
||||
guide,
|
||||
group,
|
||||
}: {
|
||||
guide: PublicGuide;
|
||||
group: PublicGuide["constellationGroups"][number];
|
||||
guide: ConstellationImageGuide;
|
||||
group: ConstellationImageGroup;
|
||||
}) {
|
||||
const rows = constellationChartRows(group.rows);
|
||||
const background = guide.character.splashImageUrl ?? guide.coverUrl;
|
||||
|
||||
@@ -37,6 +37,33 @@ import {
|
||||
} from "@/lib/guides/team-search";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export interface TeamExportData {
|
||||
title: string;
|
||||
rotationSeconds: string | number;
|
||||
combo: string;
|
||||
members: Array<{
|
||||
position: number;
|
||||
constellation: string;
|
||||
refinement: string;
|
||||
damage: string | number;
|
||||
character: {
|
||||
key: string;
|
||||
name: string;
|
||||
imageUrl: string;
|
||||
element: string | null;
|
||||
rarity: number | null;
|
||||
};
|
||||
weapon: {
|
||||
key: string;
|
||||
name: string;
|
||||
imageUrl: string;
|
||||
rarity: number | null;
|
||||
} | null;
|
||||
artifact: TeamArtifact | null;
|
||||
secondArtifact: TeamArtifact | null;
|
||||
}>;
|
||||
}
|
||||
|
||||
type Team = PublicGuide["teams"][number];
|
||||
const teamSearchTargetLabels: Record<TeamSearchTarget, string> = {
|
||||
all: "ทั้งหมด",
|
||||
@@ -179,7 +206,7 @@ export function TeamArtifactIcon({
|
||||
);
|
||||
}
|
||||
|
||||
function TeamExportImage({ team }: { team: Team }) {
|
||||
export function TeamExportImage({ team }: { team: TeamExportData }) {
|
||||
const total = team.members.reduce((sum, member) => sum + Number(member.damage), 0);
|
||||
const seconds = Number(team.rotationSeconds);
|
||||
return (
|
||||
|
||||
@@ -21,12 +21,26 @@ import {
|
||||
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
|
||||
import type { PublicGuide } from "@/lib/guides/queries";
|
||||
|
||||
type WeaponExportGuide = Pick<PublicGuide, "name" | "coverUrl"> & {
|
||||
export type WeaponExportGuide = Pick<PublicGuide, "name" | "coverUrl"> & {
|
||||
character: Pick<PublicGuide["character"], "name" | "splashImageUrl">;
|
||||
};
|
||||
|
||||
type WeaponGroup = PublicGuide["weaponGroups"][number];
|
||||
type DamageMetric = "overallPercent" | "personalPercent";
|
||||
export interface WeaponGroup {
|
||||
name: string | null;
|
||||
note: string | null;
|
||||
rows: Array<{
|
||||
id: string;
|
||||
refinement: string;
|
||||
overallPercent: string | null;
|
||||
personalPercent: string | null;
|
||||
note: string | null;
|
||||
weapon: {
|
||||
name: string;
|
||||
imageUrl: string;
|
||||
};
|
||||
}>;
|
||||
}
|
||||
export type DamageMetric = "overallPercent" | "personalPercent";
|
||||
|
||||
function formattedPercent(value: string | null): string {
|
||||
if (value === null) return "-%";
|
||||
|
||||
Reference in New Issue
Block a user