This commit is contained in:
Ivan Rezchikov
2026-07-28 17:05:45 +03:00
parent e826e7b099
commit e234407a17
30 changed files with 1873 additions and 74 deletions
+24
View File
@@ -102,4 +102,28 @@ export async function getActiveCitizenship(userId: string) {
return prisma.citizenship.findFirst({
where: { userId, revokedAt: null },
});
}
// Used by the acts appointment picker - only active citizens are eligible
// to hold a position.
export async function searchActiveCitizenships(query: string) {
const q = query.trim();
if (!q) return [];
return prisma.citizenship.findMany({
where: {
revokedAt: null,
user: {
OR: [
{ firstName: { contains: q, mode: "insensitive" } },
{ secondName: { contains: q, mode: "insensitive" } },
],
},
},
select: {
id: true,
user: { select: { firstName: true, secondName: true } },
},
take: 10,
});
}