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

This commit is contained in:
2026-03-23 23:05:03 -03:00
parent bd1a5bc21c
commit 9ca98d96db

View File

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