Updating data

This is my server component:
export default async function Collection() {
const session = await getAuthSession();
const icons = await prisma.icon
.findMany({
where: {
userId: session?.user?.id!,
},
select: {
id: true,
prompt: true,
finalPrompt: true,
createdAt: true,
},
})
.then((x) =>
x.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
);

return (
<div className="flex justify-center">
<div className="max-w-xl w-full text-center">
<h1 className="text-4xl font-extrabold mb-10">Your Collection</h1>
<IconList initialIcons={icons} />
</div>
</div>
);
}
export default async function Collection() {
const session = await getAuthSession();
const icons = await prisma.icon
.findMany({
where: {
userId: session?.user?.id!,
},
select: {
id: true,
prompt: true,
finalPrompt: true,
createdAt: true,
},
})
.then((x) =>
x.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime())
);

return (
<div className="flex justify-center">
<div className="max-w-xl w-full text-center">
<h1 className="text-4xl font-extrabold mb-10">Your Collection</h1>
<IconList initialIcons={icons} />
</div>
</div>
);
}
In my api route I add a new icon, how do I update it in this component?
0 Replies
No replies yetBe the first to reply to this messageJoin