add references, chart improvement, fix scrollable combobox, fixed funnels

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-03-07 20:23:34 +01:00
parent 6a6ccfdb42
commit 6d5bfa4cbe
21 changed files with 454 additions and 114 deletions

View File

@@ -0,0 +1,50 @@
import type { Prisma, Reference } from '../prisma-client';
import { db } from '../prisma-client';
// import type { Report as DbReport } from '../prisma-client';
export type IServiceReference = Omit<Reference, 'project_id'> & {
projectId: string;
};
export function transform({
project_id,
...item
}: Reference): IServiceReference {
return {
...item,
projectId: project_id,
};
}
export async function getReferenceById(id: string) {
const reference = await db.reference.findUnique({
where: {
id,
},
});
if (!reference) {
return null;
}
return transform(reference);
}
export async function getReferences({
where,
take,
skip,
}: {
where: Prisma.ReferenceWhereInput;
take?: number;
skip?: number;
}) {
const references = await db.reference.findMany({
where,
take: take ?? 50,
skip,
});
return references.map(transform);
}