fix: TypeScript error in import route - cast item to access id #6

Merged
darroyo merged 1 commits from develop into main 2026-03-24 02:05:46 +00:00

View File

@@ -105,21 +105,22 @@ export async function POST(req: NextRequest) {
const createdAt = parseDate((item as { createdAt?: string }).createdAt)
const updatedAt = parseDate((item as { updatedAt?: string }).updatedAt)
const itemWithId = item as { id?: string }
if (item.id) {
const existing = await tx.note.findUnique({ where: { id: item.id } })
if (itemWithId.id) {
const existing = await tx.note.findUnique({ where: { id: itemWithId.id } })
if (existing) {
await tx.note.update({
where: { id: item.id },
where: { id: itemWithId.id },
data: { ...noteData, createdAt, updatedAt },
})
await tx.noteTag.deleteMany({ where: { noteId: item.id } })
await tx.noteTag.deleteMany({ where: { noteId: itemWithId.id } })
processed++
} else {
await tx.note.create({
data: {
...noteData,
id: item.id,
id: itemWithId.id,
createdAt,
updatedAt,
creationSource: 'import',
@@ -150,8 +151,8 @@ export async function POST(req: NextRequest) {
processed++
}
const noteId = item.id
? (await tx.note.findUnique({ where: { id: item.id } }))?.id
const noteId = itemWithId.id
? (await tx.note.findUnique({ where: { id: itemWithId.id } }))?.id
: (await tx.note.findFirst({ where: { title: item.title } }))?.id
if (noteId && tags.length > 0) {