chore: add all the code from original repo

This commit is contained in:
Riccardo
2024-05-23 16:55:29 +02:00
parent d8f9a215eb
commit 85d66215a7
66 changed files with 16668 additions and 122 deletions

View File

@@ -0,0 +1,48 @@
'use server';
import { Items } from '../../../../../data/types';
import prisma from '../../../../../prisma/prisma';
interface ItemsTableActionProps {
take: number;
profile: string | undefined;
}
export async function ItemsTableAction({
take,
profile
}: ItemsTableActionProps) {
if (!profile) {
return [] as Items;
}
try {
const items = await prisma.item.findMany({
where: {
profileId: profile
},
orderBy: {
createdAt: 'desc'
},
include: {
Tag: {
select: {
name: true
}
}
},
take
});
const itemsWithTag = items.map((item) => {
return {
...item,
tag: item?.Tag?.name
};
});
return itemsWithTag as Items;
} catch (error) {
throw new Error('Failed to find items');
}
}