mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
fix: errors on saving transactions
This commit is contained in:
@@ -16,7 +16,7 @@ export const fieldsToJsonSchema = (fields: Field[]) => {
|
||||
...schemaProperties,
|
||||
items: {
|
||||
type: "array",
|
||||
description: "Included items or products in the transaction which have own name and price",
|
||||
description: "Separate items, products or transactions in the file which have own name and price or sum. Find all items!",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: schemaProperties,
|
||||
|
||||
@@ -5,7 +5,7 @@ import { uploadFilesAction } from "@/app/(app)/files/actions"
|
||||
import { uploadTransactionFilesAction } from "@/app/(app)/transactions/actions"
|
||||
import { AlertCircle, CloudUpload, Loader2 } from "lucide-react"
|
||||
import { useParams, useRouter } from "next/navigation"
|
||||
import { startTransition, useCallback, useEffect, useRef, useState } from "react"
|
||||
import { useCallback, useEffect, useRef, useState } from "react"
|
||||
|
||||
export default function ScreenDropArea({ children }: { children: React.ReactNode }) {
|
||||
const router = useRouter()
|
||||
@@ -77,7 +77,6 @@ export default function ScreenDropArea({ children }: { children: React.ReactNode
|
||||
formData.append("files", files[i])
|
||||
}
|
||||
|
||||
startTransition(async () => {
|
||||
const result = transactionId
|
||||
? await uploadTransactionFilesAction(formData)
|
||||
: await uploadFilesAction(formData)
|
||||
@@ -91,12 +90,11 @@ export default function ScreenDropArea({ children }: { children: React.ReactNode
|
||||
} else {
|
||||
setUploadError(result.error ? result.error : "Something went wrong...")
|
||||
}
|
||||
setIsUploading(false)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error("Upload error:", error)
|
||||
setIsUploading(false)
|
||||
setUploadError(error instanceof Error ? error.message : "Something went wrong...")
|
||||
} finally {
|
||||
setIsUploading(false)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -13,9 +13,9 @@ export type TransactionData = {
|
||||
convertedTotal?: number | null
|
||||
convertedCurrencyCode?: string | null
|
||||
type?: string | null
|
||||
items?: TransactionData[] | null
|
||||
items?: TransactionData[] | undefined
|
||||
note?: string | null
|
||||
files?: string[] | null
|
||||
files?: string[] | undefined
|
||||
extra?: Record<string, unknown>
|
||||
categoryCode?: string | null
|
||||
projectCode?: string | null
|
||||
@@ -135,10 +135,8 @@ export const createTransaction = async (userId: string, data: TransactionData):
|
||||
...standard,
|
||||
extra: extra,
|
||||
items: data.items as Prisma.InputJsonValue,
|
||||
user: {
|
||||
connect: { id: userId }
|
||||
}
|
||||
} as Prisma.TransactionCreateInput,
|
||||
userId,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -151,7 +149,7 @@ export const updateTransaction = async (id: string, userId: string, data: Transa
|
||||
...standard,
|
||||
extra: extra,
|
||||
items: data.items ? data.items as Prisma.InputJsonValue : [],
|
||||
} as Prisma.TransactionUpdateInput,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user