|
|
@@ -48,14 +48,22 @@ export async function createImport(data: {
|
|
|
}
|
|
|
|
|
|
// Get all imports for the current user
|
|
|
-export async function getImports(userId?: string) {
|
|
|
+export async function getImports(userId?: string, layoutId?: number) {
|
|
|
try {
|
|
|
+ const whereClause: any = {};
|
|
|
+
|
|
|
+ if (userId) {
|
|
|
+ whereClause.fileId = {
|
|
|
+ not: null,
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ if (typeof layoutId === 'number') {
|
|
|
+ whereClause.layoutId = layoutId;
|
|
|
+ }
|
|
|
+
|
|
|
const imports = await prisma.import.findMany({
|
|
|
- where: userId ? {
|
|
|
- fileId: {
|
|
|
- not: null,
|
|
|
- },
|
|
|
- } : {},
|
|
|
+ where: whereClause,
|
|
|
include: {
|
|
|
layout: true,
|
|
|
},
|