Bernt Christian Egeland 7 месяцев назад
Родитель
Сommit
64cdb37ee0

+ 1 - 0
src/app/api/desktop/v1/board-assignments/route.ts

@@ -24,6 +24,7 @@ export async function POST(request: Request) {
 
       const assignment = await db.boardAssignment.create({
         data: {
+          ...(body.id ? { id: body.id } : {}),
           date: new Date(data.date),
           sortOrder: data.sortOrder,
           notes: data.notes,

+ 1 - 0
src/app/api/desktop/v1/customers/route.ts

@@ -74,6 +74,7 @@ export async function POST(request: Request) {
 
       const customer = await db.customer.create({
         data: {
+          ...(body.id ? { id: body.id } : {}),
           ...data,
           email: data.email || null,
           userId,

+ 1 - 0
src/app/api/desktop/v1/inspections/route.ts

@@ -34,6 +34,7 @@ export async function POST(request: Request) {
       const inspection = await db.$transaction(async (tx) => {
         const created = await tx.inspection.create({
           data: {
+            ...(body.id ? { id: body.id } : {}),
             vehicleId: data.vehicleId,
             templateId: data.templateId,
             mileage: data.mileage,

+ 1 - 0
src/app/api/desktop/v1/inventory/route.ts

@@ -13,6 +13,7 @@ export async function POST(request: Request) {
 
       const part = await db.inventoryPart.create({
         data: {
+          ...(body.id ? { id: body.id } : {}),
           ...data,
           partNumber: data.partNumber || undefined,
           description: data.description || undefined,

+ 1 - 0
src/app/api/desktop/v1/payments/route.ts

@@ -21,6 +21,7 @@ export async function POST(request: Request) {
 
       const payment = await db.payment.create({
         data: {
+          ...(body.id ? { id: body.id } : {}),
           serviceRecordId: data.serviceRecordId,
           amount: data.amount,
           date: new Date(data.date),

+ 1 - 0
src/app/api/desktop/v1/quotes/route.ts

@@ -36,6 +36,7 @@ export async function POST(request: Request) {
       const quote = await db.$transaction(async (tx) => {
         const created = await tx.quote.create({
           data: {
+            ...(body.id ? { id: body.id } : {}),
             ...quoteData,
             quoteNumber,
             userId,

+ 3 - 1
src/app/api/desktop/v1/sms/route.ts

@@ -9,7 +9,8 @@ export async function POST(request: Request) {
   return withDesktopAuth(
     request,
     async ({ organizationId }) => {
-      const { customerId, body: messageBody, relatedEntityType, relatedEntityId } = await request.json();
+      const rawBody = await request.json();
+      const { customerId, body: messageBody, relatedEntityType, relatedEntityId } = rawBody;
 
       if (!customerId || !messageBody) {
         return NextResponse.json({ error: "customerId and body are required" }, { status: 400 });
@@ -36,6 +37,7 @@ export async function POST(request: Request) {
       // Create message record
       const message = await db.smsMessage.create({
         data: {
+          ...(rawBody.id ? { id: rawBody.id } : {}),
           direction: "outbound",
           fromNumber,
           toNumber: customer.phone,

+ 6 - 1
src/app/api/desktop/v1/vehicles/[id]/notes/route.ts

@@ -72,7 +72,12 @@ export async function POST(
       const body = await request.json();
       const data = createNoteSchema.parse({ ...body, vehicleId: id });
 
-      const note = await db.note.create({ data });
+      const note = await db.note.create({
+        data: {
+          ...(body.id ? { id: body.id } : {}),
+          ...data,
+        },
+      });
       return NextResponse.json({ note }, { status: 201 });
     },
     {

+ 1 - 0
src/app/api/desktop/v1/vehicles/[id]/reminders/route.ts

@@ -26,6 +26,7 @@ export async function POST(
 
       const reminder = await db.reminder.create({
         data: {
+          ...(body.id ? { id: body.id } : {}),
           ...data,
           dueDate: data.dueDate ? new Date(data.dueDate) : null,
         },

+ 1 - 0
src/app/api/desktop/v1/vehicles/route.ts

@@ -72,6 +72,7 @@ export async function POST(request: Request) {
 
       const vehicle = await db.vehicle.create({
         data: {
+          ...(body.id ? { id: body.id } : {}),
           ...data,
           purchaseDate: data.purchaseDate ? new Date(data.purchaseDate) : null,
           customerId: data.customerId || null,

+ 1 - 0
src/app/api/desktop/v1/work-orders/route.ts

@@ -99,6 +99,7 @@ export async function POST(request: Request) {
       const workOrder = await db.$transaction(async (tx) => {
         const created = await tx.serviceRecord.create({
           data: {
+            ...(body.id ? { id: body.id } : {}),
             ...recordData,
             serviceDate: new Date(recordData.serviceDate),
           },