daphnis/components/(customization)/nameplatecustomization/actions.ts
2024-07-28 01:16:27 -04:00

48 lines
1.1 KiB
TypeScript

"use server";
import { getAuth } from "@/auth/queries/getauth";
import { artemis, daphnis } from "@/lib/prisma";
import type * as Prisma from "@prisma/client";
// type ChuniScorePlaylog = Prisma.PrismaClient;
// type ChuniStaticMusic = Prisma.PrismaClient;
export async function getCurrentNameplate() {
const { user } = await getAuth();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
}
const currentNameplate = await artemis.chuni_profile_data.findMany({
where: {
user: user.UserId,
},
select: {
nameplateId: true,
},
});
return currentNameplate;
}
export async function getNamePlates() {
const { user } = await getAuth();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
}
const AllNameplates = await artemis.cozynet_chuni_static_nameplate.findMany({
select: {
id: true,
str: true,
sortName: true,
category: true,
imagePath: true,
rareType: true,
netOpenName: true,
},
});
return AllNameplates;
}