daphnis/components/(customization)/trophycustomization/actions.ts

45 lines
1015 B
TypeScript
Raw Normal View History

2024-07-23 20:15:27 +00:00
"use server";
import { getAuth } from "@/auth/queries/getauth";
import { artemis, daphnis } from "@/lib/prisma";
import type * as Prisma from "@prisma/client";
2024-07-26 17:19:37 +00:00
export async function getCurrentTrophies() {
const { user } = await getAuth();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
}
const avatarParts = await artemis.chuni_profile_data.findMany({
where: {
user: user.UserId,
},
select: {
2024-07-26 17:19:37 +00:00
trophyId: true,
},
});
return avatarParts;
}
2024-07-23 20:15:27 +00:00
2024-07-26 17:19:37 +00:00
export async function getTrophies() {
const { user } = await getAuth();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
}
2024-07-26 17:19:37 +00:00
const staticTrophies = await artemis.cozynet_chuni_static_trophies.findMany({
select: {
category: true,
2024-07-26 17:19:37 +00:00
netOpenName: true,
id: true,
str: true,
imagePath: true,
rareType: true,
sortName: true,
},
});
2024-07-26 17:19:37 +00:00
return staticTrophies;
}