2 Commits

Author SHA1 Message Date
5b8698cf81 add bool to int mapping 2025-10-14 00:30:57 +02:00
69a3836f13 fix wrong type 2025-10-14 00:23:43 +02:00
3 changed files with 15 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
interface RecentSession {
id: number;
id: string;
date: string;
type: string;
track: string;

View File

@@ -17,6 +17,7 @@ import type {
EventRules,
ServerSettings
} from '@/lib/schemas/config';
import { boolToInt } from '@/lib/utils';
export async function updateConfigurationAction(serverId: string, formData: FormData) {
try {
@@ -198,14 +199,14 @@ export async function updateEventRulesAction(serverId: string, formData: FormDat
driverStintTimeSec: parseInt(formData.get('driverStintTimeSec') as string),
mandatoryPitstopCount: parseInt(formData.get('mandatoryPitstopCount') as string),
maxTotalDrivingTime: parseInt(formData.get('maxTotalDrivingTime') as string),
isRefuellingAllowedInRace: formData.get('isRefuellingAllowedInRace') === 'true',
isRefuellingTimeFixed: formData.get('isRefuellingTimeFixed') === 'true',
isRefuellingAllowedInRace: boolToInt(formData.get('isRefuellingAllowedInRace') === 'true'),
isRefuellingTimeFixed: boolToInt(formData.get('isRefuellingTimeFixed') === 'true'),
isMandatoryPitstopRefuellingRequired:
formData.get('isMandatoryPitstopRefuellingRequired') === 'true',
boolToInt(formData.get('isMandatoryPitstopRefuellingRequired') === 'true'),
isMandatoryPitstopTyreChangeRequired:
formData.get('isMandatoryPitstopTyreChangeRequired') === 'true',
boolToInt(formData.get('isMandatoryPitstopTyreChangeRequired') === 'true'),
isMandatoryPitstopSwapDriverRequired:
formData.get('isMandatoryPitstopSwapDriverRequired') === 'true',
boolToInt(formData.get('isMandatoryPitstopSwapDriverRequired') === 'true'),
tyreSetCount: parseInt(formData.get('tyreSetCount') as string)
};

View File

@@ -4,3 +4,11 @@ import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function boolToInt(val: boolean) {
return val ? 1 : 0;
}
export function intToBool(val: number) {
return !!val
}