added update functions
This commit is contained in:
@ -1,11 +1,8 @@
|
||||
"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;
|
||||
import { supportedVersionNumber } from "@/lib/helpers";
|
||||
import { artemis } from "@/lib/prisma";
|
||||
|
||||
export async function getCurrentSystemVoice() {
|
||||
const { user } = await getAuth();
|
||||
@ -17,6 +14,7 @@ export async function getCurrentSystemVoice() {
|
||||
const currentSystemVoice = await artemis.chuni_profile_data.findMany({
|
||||
where: {
|
||||
user: user.UserId,
|
||||
version: supportedVersionNumber,
|
||||
},
|
||||
select: {
|
||||
voiceId: true,
|
||||
@ -25,6 +23,39 @@ export async function getCurrentSystemVoice() {
|
||||
return currentSystemVoice;
|
||||
}
|
||||
|
||||
export async function updatePlayerSystemVoiceId(voiceId: number) {
|
||||
const { user } = await getAuth();
|
||||
|
||||
if (!user || !user.accessCode) {
|
||||
throw new Error("User is not authenticated or accessCode is missing");
|
||||
}
|
||||
|
||||
if (voiceId === undefined) {
|
||||
throw new Error("nameplateId is required");
|
||||
}
|
||||
|
||||
try {
|
||||
const updatePlayerNameplate = await artemis.chuni_profile_data.update({
|
||||
where: {
|
||||
user_version: {
|
||||
user: user.UserId,
|
||||
version: supportedVersionNumber,
|
||||
},
|
||||
},
|
||||
data: {
|
||||
voiceId,
|
||||
},
|
||||
});
|
||||
|
||||
console.log(updatePlayerNameplate);
|
||||
|
||||
return updatePlayerNameplate;
|
||||
} catch (error) {
|
||||
console.error("Error updating nameplate:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getSystemVoices() {
|
||||
const { user } = await getAuth();
|
||||
|
||||
|
Reference in New Issue
Block a user