up
This commit is contained in:
@@ -22,7 +22,7 @@ export function parsePlan(value: unknown): ScreenPlan {
|
||||
const steps = list.map((value, index) => {
|
||||
const field = `plan.steps[${index}]`
|
||||
const step = object(value, field)
|
||||
let mode: ScreenMode
|
||||
let mode: number
|
||||
try {
|
||||
mode = integer(
|
||||
typeof step.mode === 'string' && step.mode.startsWith('SCREEN_MODE_')
|
||||
@@ -31,7 +31,7 @@ export function parsePlan(value: unknown): ScreenPlan {
|
||||
1,
|
||||
8,
|
||||
`${field}.mode`,
|
||||
) as ScreenMode
|
||||
)
|
||||
} catch {
|
||||
throw new ResponseFieldError(
|
||||
`${field}.mode`,
|
||||
@@ -40,7 +40,11 @@ export function parsePlan(value: unknown): ScreenPlan {
|
||||
'Некорректный режим экрана',
|
||||
)
|
||||
}
|
||||
const content = text(step.text ?? '', `${field}.text`).trim()
|
||||
let content = text(step.text ?? '', `${field}.text`).trim()
|
||||
if (mode === 3 || mode === 5) {
|
||||
content = mode === 3 ? 'Успехов' : 'Спасибо за игру!'
|
||||
mode = 8
|
||||
}
|
||||
const label = text(step.timerLabel ?? '', `${field}.timerLabel`).trim()
|
||||
const seconds = integer(
|
||||
step.timerDurationSeconds ?? 0,
|
||||
@@ -63,7 +67,7 @@ export function parsePlan(value: unknown): ScreenPlan {
|
||||
'Укажите таймер от 1 до 86400 секунд и подпись до 200 байт',
|
||||
)
|
||||
return {
|
||||
mode,
|
||||
mode: mode as ScreenMode,
|
||||
text: content,
|
||||
timerLabel: mode === 7 ? label || 'Перерыв' : label,
|
||||
timerDurationSeconds: seconds,
|
||||
|
||||
Reference in New Issue
Block a user