Кеняка
Кеняка
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
But thank you anyway, you gave me a push in what direction I need to think
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
all this with nulls, no checks were needed. It was only necessary to apply drag&drop to another container
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
In general, I figured out the problem. It consisted in the fact that I called the function twice, applying Drag&Drop directly to the parent and child elements simultaneously
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
Ok, I got it, thanks for the help
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
I also call the component once in layout.tsx
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
perhaps, since I call this function in other files although I checked and made a separate function for this action, it apparently also ran twice
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
although this was noticeable on the site itself
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
No description
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
No description
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
No description
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
I did a debug, all data and values ​​from the client are sent correctly
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
rest in mutation
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity()

if (!identity) {
throw new Error("Not authenticated")
}

const { id, ...rest } = args

const existingDocument = await ctx.db.get(args.id)

if (!existingDocument) {
throw new Error("Document not found")
}

if (existingDocument.userId !== args.userId) {
throw new Error("Unauthorized")
}

const document = await ctx.db.patch(args.id, {
...rest,
parentDocument: rest.parentDocument === null ? undefined : rest.parentDocument
})

return document
}
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity()

if (!identity) {
throw new Error("Not authenticated")
}

const { id, ...rest } = args

const existingDocument = await ctx.db.get(args.id)

if (!existingDocument) {
throw new Error("Document not found")
}

if (existingDocument.userId !== args.userId) {
throw new Error("Unauthorized")
}

const document = await ctx.db.patch(args.id, {
...rest,
parentDocument: rest.parentDocument === null ? undefined : rest.parentDocument
})

return document
}
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
const handleDrop = (event: React.DragEvent<HTMLDivElement>) => {
event.preventDefault();
const draggedId = event.dataTransfer.getData("text/plain");

if (draggedId) {
const promise = update({
id: draggedId as Id<"documents">,
userId: orgId,
parentDocument: null, // in other code it’s the same thing, only here it’s not null, but an id variable with type Id
lastEditor: user?.username as string
});

toast.promise(promise, {
loading: "Перемещаем...",
success: "Заметка успешно перемещена!",
error: "Не удалось переместить заметку"
})
}
};
const handleDrop = (event: React.DragEvent<HTMLDivElement>) => {
event.preventDefault();
const draggedId = event.dataTransfer.getData("text/plain");

if (draggedId) {
const promise = update({
id: draggedId as Id<"documents">,
userId: orgId,
parentDocument: null, // in other code it’s the same thing, only here it’s not null, but an id variable with type Id
lastEditor: user?.username as string
});

toast.promise(promise, {
loading: "Перемещаем...",
success: "Заметка успешно перемещена!",
error: "Не удалось переместить заметку"
})
}
};
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
.
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
Well, my object takes two types (already three): Id<"documents"> | undefined | null after what I added, if I pass null, then everything is ok and it removes the values ​​​​in the database and puts undefined but if I pass Id<"documents"> then it does not change the value in the database
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
No description
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
I convey it like this
parentDocument: null
parentDocument: null
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
i did like this by adding an additional null type, but now if i pass values ​​with type Id<"..."> then it does not change undefined to Id
parentDocument: v.optional(v.union(v.id("documents"), v.null()))
parentDocument: v.optional(v.union(v.id("documents"), v.null()))
const document = await ctx.db.patch(args.id, {
...rest,
parentDocument: rest.parentDocument === null ? undefined : rest.parentDocument
})
const document = await ctx.db.patch(args.id, {
...rest,
parentDocument: rest.parentDocument === null ? undefined : rest.parentDocument
})
57 replies
CCConvex Community
Created by Кеняка on 12/31/2024 in #support-community
object is not accepted undefined
I'll try now
57 replies