forked from PolarisPyra/daphnis
added diff name and setup skeleton for top recent plays
This commit is contained in:
parent
a2f5febb60
commit
ad12f07cde
@ -13,6 +13,16 @@ import { getSystemVoices } from "@/components/(customization)/systemvoicecustomi
|
||||
import { SystemVoiceCustomization } from "@/components/(customization)/systemvoicecustomization/page";
|
||||
import { MapIconCustomization } from "@/components/(customization)/mapiconcustomization/page";
|
||||
import { getMapIcons } from "@/components/(customization)/mapiconcustomization/actions";
|
||||
import { ChunithmRecentPlays } from "@/components/RecentChunithmScores/page";
|
||||
import { getUserRecentPlays } from "@/components/RecentChunithmScores/action";
|
||||
|
||||
|
||||
const getChuniRecent = async () => {
|
||||
const recentRating = await getUserRecentPlays();
|
||||
return { recentRating };
|
||||
};
|
||||
|
||||
|
||||
|
||||
const getAvatarHeadAccessories = async () => {
|
||||
const avatarParts = await getAllAvatarParts(2); // head
|
||||
@ -69,6 +79,8 @@ const Page = async () => {
|
||||
const AllStaticNameplates = await getAllNameplates();
|
||||
const AllSystemVoices = await getAllSystemVoices();
|
||||
const AllMapIcons = await getAllMapIcons();
|
||||
const RecentChuniPlays = await getChuniRecent();
|
||||
|
||||
|
||||
return (
|
||||
<div className="p-10">
|
||||
@ -76,6 +88,8 @@ const Page = async () => {
|
||||
<TabsList>
|
||||
<TabsTrigger value="scores">Scores</TabsTrigger>
|
||||
<TabsTrigger value="customize">Customize</TabsTrigger>
|
||||
<TabsTrigger value="RecentPlays">Top / Recent Plays</TabsTrigger>
|
||||
|
||||
</TabsList>
|
||||
<TabsContent value="scores">
|
||||
<ChunithmScorePlaylog />
|
||||
@ -110,6 +124,9 @@ const Page = async () => {
|
||||
</div>
|
||||
<div></div>
|
||||
</TabsContent>
|
||||
<TabsContent value="RecentPlays">
|
||||
<ChunithmRecentPlays chuniProfileRecentPlays={RecentChuniPlays}/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
|
@ -118,6 +118,7 @@ export async function getSongsWithTitles(userId: number) {
|
||||
title: staticInfo?.title || "Unknown Title",
|
||||
artist: staticInfo?.artist || "Unknown Artist",
|
||||
genre: staticInfo?.genre || "Unknown Genre",
|
||||
chartId: staticInfo?.chartId || "Unknown chartId",
|
||||
level: staticInfo?.level || "Unknown Level",
|
||||
chartlevel: song.level || "Unknown Level",
|
||||
playCount: song.musicId !== null ? playCountMap[song.musicId] || 0 : 0,
|
||||
|
@ -31,14 +31,14 @@ import { z } from "zod";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { toast } from "../../ui/use-toast";
|
||||
import { updateAvatarParts } from "./actions";
|
||||
type chunithm_avatar = chuni_static_avatar;
|
||||
|
||||
|
||||
const getAvatarTextureSrc = (id: number | undefined) => {
|
||||
if (id === undefined) return "";
|
||||
return `avatarAccessory/CHU_UI_Avatar_Tex_0${id}.png`;
|
||||
};
|
||||
|
||||
import { updateAvatarParts } from "./actions";
|
||||
type chunithm_avatar = chuni_static_avatar;
|
||||
}
|
||||
|
||||
type AvatarSelectionProps = {
|
||||
avatarHeadSelectionData: {
|
||||
|
35
components/RecentChunithmScores/action.ts
Normal file
35
components/RecentChunithmScores/action.ts
Normal file
@ -0,0 +1,35 @@
|
||||
"use server";
|
||||
|
||||
import { getAuth } from "@/auth/queries/getauth";
|
||||
import { supportedVersionNumber } from "@/lib/helpers";
|
||||
import { artemis } from "@/lib/prisma";
|
||||
|
||||
export async function getUserRecentPlays() {
|
||||
const { user } = await getAuth();
|
||||
|
||||
if (!user || !user.accessCode) {
|
||||
throw new Error("User is not authenticated or accessCode is missing");
|
||||
}
|
||||
|
||||
const userRatingBaseHotList = await artemis.chuni_profile_rating.findMany({
|
||||
where: {
|
||||
user: user.UserId,
|
||||
// userRatingBaseList recent 30 // userRatingBaseHotList recent 15
|
||||
type: "userRatingBaseList",
|
||||
version: supportedVersionNumber, // TODO: eventually change this so the user can set their own version
|
||||
},
|
||||
select: {
|
||||
score:true,
|
||||
difficultId: true,
|
||||
musicId: true,
|
||||
type:true,
|
||||
version: true,
|
||||
romVersionCode: true,
|
||||
id: true,
|
||||
index:true,
|
||||
user: true,
|
||||
|
||||
},
|
||||
});
|
||||
return userRatingBaseHotList;
|
||||
}
|
23
components/RecentChunithmScores/page.tsx
Normal file
23
components/RecentChunithmScores/page.tsx
Normal file
@ -0,0 +1,23 @@
|
||||
import { chuni_profile_rating, chuni_profile_recent_rating } from '@/prisma/schemas/artemis/generated/artemis';
|
||||
import React, { FC } from 'react';
|
||||
|
||||
type chunithm_recent = chuni_profile_rating
|
||||
|
||||
type ChunithmProfileRecentPlays = {
|
||||
chuniProfileRecentPlays: {
|
||||
recentRating: chunithm_recent[];
|
||||
};
|
||||
};
|
||||
|
||||
export const ChunithmRecentPlays: FC<ChunithmProfileRecentPlays> = ({ chuniProfileRecentPlays }) => {
|
||||
return (
|
||||
<div>
|
||||
{chuniProfileRecentPlays.recentRating.map((playersRecentRatingList, index) => (
|
||||
<div key={index}>
|
||||
{playersRecentRatingList.score}
|
||||
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
@ -18,7 +18,7 @@ import { generateShareToken } from "@/app/(sharing)/[token]/token";
|
||||
import { ArrowUpDown, MoreHorizontalIcon } from "lucide-react";
|
||||
import { chuni_score_playlog } from "@/prisma/schemas/artemis/generated/artemis";
|
||||
import { chuni_static_music } from "@/prisma/schemas/artemis/generated/artemis";
|
||||
import { getGrade } from "@/lib/helpers";
|
||||
import { getDifficultyText, getGrade } from "@/lib/helpers";
|
||||
import { Skeleton } from "../ui/skeleton";
|
||||
|
||||
type chunithm = chuni_score_playlog &
|
||||
@ -105,7 +105,13 @@ export const columns: ColumnDef<chunithm>[] = [
|
||||
{
|
||||
accessorKey: "difficulty",
|
||||
header: "Difficulty",
|
||||
cell: ({ row }) => <div className="font-medium">{row.original.level}</div>,
|
||||
cell: ({ row }) => (
|
||||
<div className="font-medium">
|
||||
{row.original.level}
|
||||
<br />
|
||||
{getDifficultyText(row.original.chartId)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "FC / AJ",
|
||||
|
@ -17,10 +17,10 @@ export const getDifficultyClass = (level: number) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getDifficultyText = (chartId: number) => {
|
||||
export const getDifficultyText = (chartId: number | null) => {
|
||||
switch (chartId) {
|
||||
case 0:
|
||||
return "EASY"; // Text for difficulty
|
||||
return "EASY";
|
||||
case 1:
|
||||
return "ADVANCE";
|
||||
case 2:
|
||||
@ -31,9 +31,12 @@ export const getDifficultyText = (chartId: number) => {
|
||||
return "ULTIMA";
|
||||
case 5:
|
||||
return "WORLDS END";
|
||||
default:
|
||||
return "UNKNOWN"; // Default text if chartId doesn't match any case
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export const getGrade = (score: number) => {
|
||||
if (score >= 1009000) return "SSS+";
|
||||
if (score >= 1007500 && score <= 1008999) return "SSS";
|
||||
|
Loading…
Reference in New Issue
Block a user