import { jsx as _jsx } from "react/jsx-runtime";
import { useComponentTelemetry } from '../../../../lib/telemetry/index.js';
import { createIsoDate } from '../../../../lib/dates.js';
import { useCreateClimateSettingSchedule } from '../../../../lib/seam/thermostats/climate-setting-schedules/use-create-climate-setting-schedule.js';
import { ClimateSettingScheduleForm, } from '../../../../lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js';
export function CreateClimateSettingScheduleForm({ className, onBack, }) {
    useComponentTelemetry('CreateClimateSettingScheduleForm');
    const { submit, isSubmitting } = useSubmitCreateClimateSettingSchedule(onBack);
    return (_jsx(ClimateSettingScheduleForm, { className: className, onBack: onBack, onSubmit: submit, isSubmitting: isSubmitting }));
}
function useSubmitCreateClimateSettingSchedule(onSuccess) {
    const { mutate, isLoading: isSubmitting } = useCreateClimateSettingSchedule();
    const submit = (data) => {
        const { name, deviceId, startDate, endDate, timezone, climateSetting } = data;
        if (isSubmitting) {
            return;
        }
        mutate({
            name,
            device_id: deviceId,
            schedule_starts_at: createIsoDate(startDate, timezone),
            schedule_ends_at: createIsoDate(endDate, timezone),
            ...climateSetting,
        }, {
            onSuccess,
        });
    };
    return { submit, isSubmitting };
}
//# sourceMappingURL=CreateClimateSettingScheduleForm.js.map