import type { BackupSchedule } from "~/client/lib/types"; import { cronToFormValues } from "../../lib/cron-utils"; import type { InternalFormValues } from "./types"; export const parseMultilineEntries = (value?: string) => value ? value .split("\n") .map((entry) => entry.trim()) .filter(Boolean) : []; export const backupScheduleToFormValues = (schedule?: BackupSchedule): InternalFormValues | undefined => { if (!schedule) { return undefined; } const cronValues = cronToFormValues(schedule.cronExpression ?? "0 * * * *"); return { name: schedule.name, repositoryId: schedule.repository.shortId, includePaths: schedule.includePaths?.length ? schedule.includePaths : undefined, includePatterns: schedule.includePatterns?.length ? schedule.includePatterns.join("\n") : undefined, excludePatternsText: schedule.excludePatterns?.join("\n") || undefined, excludeIfPresentText: schedule.excludeIfPresent?.join("\n") || undefined, oneFileSystem: schedule.oneFileSystem ?? false, customResticParamsText: schedule.customResticParams?.join("\n") ?? "", ...cronValues, ...schedule.retentionPolicy, }; };