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

48 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-07-26 18:08:36 +00:00
"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");
}
2024-07-28 05:16:27 +00:00
const currentNameplate = await artemis.chuni_profile_data.findMany({
2024-07-26 18:08:36 +00:00
where: {
user: user.UserId,
},
select: {
nameplateId: true,
},
});
2024-07-28 05:16:27 +00:00
return currentNameplate;
2024-07-26 18:08:36 +00:00
}
export async function getNamePlates() {
const { user } = await getAuth();
if (!user || !user.accessCode) {
throw new Error("User is not authenticated or accessCode is missing");
}
2024-07-28 05:16:27 +00:00
const AllNameplates = await artemis.cozynet_chuni_static_nameplate.findMany({
2024-07-26 18:08:36 +00:00
select: {
id: true,
str: true,
sortName: true,
category: true,
imagePath: true,
rareType: true,
netOpenName: true,
},
});
2024-07-28 05:16:27 +00:00
return AllNameplates;
2024-07-26 18:08:36 +00:00
}