export const deliveryFields = [ { label: "Adresa", control: { type: "text" } }, { label: "Mesto", control: { type: "text" } }, { label: "PSČ", control: { type: "text" } }, { label: "Štát", control: { type: "text" } }, ]; export const deliveryValues = ["Gunduličová 4", "Bratislava", "81105", ""]; export const inlineDateFields = [ { label: "Deň", control: { type: "text", width: "12ch" }, pattern: "[0-9]*", inputMode: "numeric", }, { label: "Mesiac", control: { type: "text", width: "12ch" }, pattern: "[0-9]*", inputMode: "numeric", }, { label: "Rok", control: { type: "text", width: "12ch" }, pattern: "[0-9]*", inputMode: "numeric", }, ]; export const separateMessages = [ { type: "error", fieldLabel: "Deň", text: `Políčko "Deň" je prázdne. Vypíšte "Deň".`, }, { type: "error", fieldLabel: "Mesiac", text: `Políčko "Mesiac" je prázdne. Vypíšte "Mesiac".`, }, ]; export const inlineErrorFields = inlineDateFields.map((f) => separateMessages.find((m) => m.type === "error" && m.fieldLabel === f.label) ? { ...f, control: { ...f.control, isInvalid: true } } : { ...f, control: { ...f.control, defaultValue: "2020", isValid: true } }, ); export const deliveryStateFields = deliveryFields .map((df, i) => ({ ...df, control: { ...df.control, defaultValue: deliveryValues[i], }, })) .map((df) => ({ ...df, ...(!df?.control?.defaultValue ? { messages: [ { type: "error", text: `Políčko "${df.label}" je prázdne. Vypíšte políčko "${df.label}".`, }, ], } : { control: { ...df.control, isValid: true, }, }), }));