mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-11-18 07:22:06 +00:00
Update packages
This commit is contained in:
@@ -6,38 +6,41 @@ import { collections, dbConnect } from "@/server/mongodb";
|
||||
import { TimeControl, tcMap } from "@/types";
|
||||
import { errorLog } from "@/utils/logger";
|
||||
|
||||
import { action } from "./safeAction";
|
||||
import { actionClient } from "./safeAction";
|
||||
|
||||
const inputSchema = z.object({
|
||||
ffeId: z.string(),
|
||||
});
|
||||
|
||||
export const getTournamentDetails = action(inputSchema, async (input) => {
|
||||
try {
|
||||
await dbConnect();
|
||||
const t = await collections.tournaments!.findOne({
|
||||
tournament_id: input.ffeId,
|
||||
});
|
||||
export const getTournamentDetails = actionClient
|
||||
.schema(inputSchema)
|
||||
.action(async (input) => {
|
||||
const { ffeId } = input.parsedInput;
|
||||
try {
|
||||
await dbConnect();
|
||||
const t = await collections.tournaments!.findOne({
|
||||
tournament_id: ffeId,
|
||||
});
|
||||
|
||||
if (t === null) {
|
||||
return null;
|
||||
if (t === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const timeControl = tcMap[t.time_control] ?? TimeControl.Other;
|
||||
|
||||
return {
|
||||
id: t._id.toString(),
|
||||
ffeId: t.tournament_id!,
|
||||
tournament: t.tournament,
|
||||
town: t.town,
|
||||
department: t.department,
|
||||
date: t.date,
|
||||
url: t.url,
|
||||
timeControl,
|
||||
status: t.status,
|
||||
};
|
||||
} catch (error) {
|
||||
errorLog(JSON.stringify(error, null, 2));
|
||||
throw error;
|
||||
}
|
||||
|
||||
const timeControl = tcMap[t.time_control] ?? TimeControl.Other;
|
||||
|
||||
return {
|
||||
id: t._id.toString(),
|
||||
ffeId: t.tournament_id!,
|
||||
tournament: t.tournament,
|
||||
town: t.town,
|
||||
department: t.department,
|
||||
date: t.date,
|
||||
url: t.url,
|
||||
timeControl,
|
||||
status: t.status,
|
||||
};
|
||||
} catch (error) {
|
||||
errorLog(JSON.stringify(error, null, 2));
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user