chore: clean up code formatting and remove unnecessary whitespace across multiple files for improved readability

This commit is contained in:
Julien Froidefond
2025-12-05 11:05:14 +01:00
parent b3157fffbd
commit 71d850c985
65 changed files with 347 additions and 505 deletions

View File

@@ -77,19 +77,19 @@ export interface ResolvedCollaborator {
// Resolve collaborator string to user - try email first, then name
export async function resolveCollaborator(collaborator: string): Promise<ResolvedCollaborator> {
const trimmed = collaborator.trim();
// 1. Try email match first
if (isEmail(trimmed)) {
const user = await prisma.user.findUnique({
where: { email: trimmed.toLowerCase() },
select: { id: true, email: true, name: true },
});
if (user) {
return { raw: collaborator, matchedUser: user };
}
}
// 2. Fallback: try matching by name (case-insensitive via raw query for SQLite)
// SQLite LIKE is case-insensitive by default for ASCII
const users = await prisma.user.findMany({
@@ -98,12 +98,10 @@ export async function resolveCollaborator(collaborator: string): Promise<Resolve
},
select: { id: true, email: true, name: true },
});
const normalizedSearch = trimmed.toLowerCase();
const userByName = users.find(
(u) => u.name?.toLowerCase() === normalizedSearch
) || null;
const userByName = users.find((u) => u.name?.toLowerCase() === normalizedSearch) || null;
return { raw: collaborator, matchedUser: userByName };
}
@@ -248,4 +246,3 @@ export async function getAllUsersWithStats(): Promise<UserWithStats[]> {
return usersWithMotivators;
}

View File

@@ -49,7 +49,11 @@ export async function getMotivatorSessionsByUserId(userId: string) {
]);
// Mark owned sessions and merge with shared
const ownedWithRole = owned.map((s) => ({ ...s, isOwner: true as const, role: 'OWNER' as const }));
const ownedWithRole = owned.map((s) => ({
...s,
isOwner: true as const,
role: 'OWNER' as const,
}));
const sharedWithRole = shared.map((s) => ({
...s.session,
isOwner: false as const,
@@ -200,10 +204,7 @@ export async function updateMotivatorCard(
});
}
export async function reorderMotivatorCards(
sessionId: string,
cardIds: string[]
) {
export async function reorderMotivatorCards(sessionId: string, cardIds: string[]) {
const updates = cardIds.map((id, index) =>
prisma.motivatorCard.update({
where: { id },
@@ -350,4 +351,3 @@ export async function getLatestMotivatorEventTimestamp(sessionId: string) {
});
return event?.createdAt;
}

View File

@@ -51,7 +51,11 @@ export async function getSessionsByUserId(userId: string) {
]);
// Mark owned sessions and merge with shared
const ownedWithRole = owned.map((s) => ({ ...s, isOwner: true as const, role: 'OWNER' as const }));
const ownedWithRole = owned.map((s) => ({
...s,
isOwner: true as const,
role: 'OWNER' as const,
}));
const sharedWithRole = shared.map((s) => ({
...s.session,
isOwner: false as const,
@@ -248,11 +252,7 @@ export async function reorderSwotItems(
return prisma.$transaction(updates);
}
export async function moveSwotItem(
itemId: string,
newCategory: SwotCategory,
newOrder: number
) {
export async function moveSwotItem(itemId: string, newCategory: SwotCategory, newOrder: number) {
return prisma.swotItem.update({
where: { id: itemId },
data: {
@@ -464,4 +464,3 @@ export async function getLatestEventTimestamp(sessionId: string) {
});
return event?.createdAt;
}