add bool to int mapping
This commit is contained in:
@@ -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)
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user