fix: error when workflow id is empty

This commit is contained in:
Methapon2001 2024-12-10 09:12:47 +07:00
parent 78e39ae16e
commit d58d88c0d4

View file

@ -93,7 +93,7 @@ type ServiceUpdate = {
*/ */
installments?: number; installments?: number;
status?: "ACTIVE" | "INACTIVE"; status?: "ACTIVE" | "INACTIVE";
workflowId?: string; workflowId?: string | null;
work?: { work?: {
id?: string; id?: string;
name: string; name: string;
@ -309,6 +309,8 @@ export class ServiceController extends Controller {
update: { value: { increment: 1 } }, update: { value: { increment: 1 } },
}); });
if (!!payload.workflowId) payload.workflowId = undefined;
return tx.service.create({ return tx.service.create({
include: { include: {
work: { work: {
@ -402,6 +404,8 @@ export class ServiceController extends Controller {
} }
const record = await prisma.$transaction(async (tx) => { const record = await prisma.$transaction(async (tx) => {
if (payload.workflowId === "") payload.workflowId = undefined;
return await tx.service.update({ return await tx.service.update({
include: { include: {
createdBy: true, createdBy: true,