autmation final reaftocrs and setitgns dafautls
This commit is contained in:
@@ -32,8 +32,8 @@ export interface UnifiedSiteSettings {
|
||||
site_name: string;
|
||||
automation: {
|
||||
enabled: boolean;
|
||||
frequency: 'hourly' | 'daily' | 'weekly';
|
||||
time: string; // HH:MM format
|
||||
frequency: 'daily' | 'weekly' | 'monthly';
|
||||
time: string; // HH:00 format (hour only)
|
||||
last_run_at: string | null;
|
||||
next_run_at: string | null;
|
||||
};
|
||||
@@ -66,8 +66,8 @@ export interface UnifiedSiteSettings {
|
||||
export interface UpdateUnifiedSettingsRequest {
|
||||
automation?: {
|
||||
enabled?: boolean;
|
||||
frequency?: 'hourly' | 'daily' | 'weekly';
|
||||
time?: string;
|
||||
frequency?: 'daily' | 'weekly' | 'monthly';
|
||||
time?: string; // HH:00 format (hour only)
|
||||
};
|
||||
stages?: Array<{
|
||||
number: number;
|
||||
@@ -136,20 +136,65 @@ export const DAYS_OF_WEEK = [
|
||||
* Frequency options for automation
|
||||
*/
|
||||
export const FREQUENCY_OPTIONS = [
|
||||
{ value: 'hourly', label: 'Hourly' },
|
||||
{ value: 'daily', label: 'Daily' },
|
||||
{ value: 'weekly', label: 'Weekly' },
|
||||
{ value: 'monthly', label: 'Monthly' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Hour options (1-12) for time selection
|
||||
*/
|
||||
export const HOUR_OPTIONS = [
|
||||
{ value: '12', label: '12' },
|
||||
{ value: '1', label: '1' },
|
||||
{ value: '2', label: '2' },
|
||||
{ value: '3', label: '3' },
|
||||
{ value: '4', label: '4' },
|
||||
{ value: '5', label: '5' },
|
||||
{ value: '6', label: '6' },
|
||||
{ value: '7', label: '7' },
|
||||
{ value: '8', label: '8' },
|
||||
{ value: '9', label: '9' },
|
||||
{ value: '10', label: '10' },
|
||||
{ value: '11', label: '11' },
|
||||
];
|
||||
|
||||
/**
|
||||
* AM/PM options
|
||||
*/
|
||||
export const AMPM_OPTIONS = [
|
||||
{ value: 'AM', label: 'AM' },
|
||||
{ value: 'PM', label: 'PM' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Convert hour (1-12) and AM/PM to 24-hour time string (HH:00)
|
||||
*/
|
||||
export function toTime24(hour: string, ampm: string): string {
|
||||
let h = parseInt(hour);
|
||||
if (ampm === 'PM' && h !== 12) h += 12;
|
||||
if (ampm === 'AM' && h === 12) h = 0;
|
||||
return `${h.toString().padStart(2, '0')}:00`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert 24-hour time string to hour (1-12) and AM/PM
|
||||
*/
|
||||
export function fromTime24(time: string): { hour: string; ampm: string } {
|
||||
const [hours] = time.split(':');
|
||||
let h = parseInt(hours);
|
||||
const ampm = h >= 12 ? 'PM' : 'AM';
|
||||
if (h > 12) h -= 12;
|
||||
if (h === 0) h = 12;
|
||||
return { hour: h.toString(), ampm };
|
||||
}
|
||||
|
||||
/**
|
||||
* Format time for display
|
||||
*/
|
||||
export function formatTime(time: string): string {
|
||||
const [hours, minutes] = time.split(':');
|
||||
const h = parseInt(hours);
|
||||
const ampm = h >= 12 ? 'PM' : 'AM';
|
||||
const displayHour = h > 12 ? h - 12 : h === 0 ? 12 : h;
|
||||
return `${displayHour}:${minutes} ${ampm}`;
|
||||
const { hour, ampm } = fromTime24(time);
|
||||
return `${hour}:00 ${ampm}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user