Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- **Shift Presets**: Create reusable shift templates with custom times, colors, and labels
- **Drag & Drop**: Reorder calendars and presets with intuitive drag-and-drop functionality
- **Calendar Notes**: Right-click any day to add custom notes (e.g., "Morning shift because afternoon hairdresser")
- **ICloud Sync**: Import shifts from multiple iCloud calendars with individual sync management
- **ICloud Sync**: Automatically or manually synchronize multiple iCloud calendars at configurable intervals

### 🎨 Customization & Organization

Expand Down
29 changes: 27 additions & 2 deletions app/api/icloud-syncs/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,15 @@ export async function PATCH(
try {
const { id } = await params;
const body = await request.json();
const { name, icloudUrl, color, displayMode, isHidden, hideFromStats } =
body;
const {
name,
icloudUrl,
color,
displayMode,
isHidden,
hideFromStats,
autoSyncInterval,
} = body;

// Validate iCloud URL if provided
if (icloudUrl !== undefined && !isValidICloudUrl(icloudUrl)) {
Expand All @@ -58,6 +65,22 @@ export async function PATCH(
);
}

// Validate autoSyncInterval if provided
const validIntervals = [0, 5, 15, 30, 60, 120, 360, 720, 1440];
if (
autoSyncInterval !== undefined &&
!validIntervals.includes(autoSyncInterval)
) {
return NextResponse.json(
{
error: `Invalid auto-sync interval. Must be one of: ${validIntervals.join(
", "
)} minutes`,
},
{ status: 400 }
);
}

const updateData: Record<string, unknown> = {
updatedAt: new Date(),
};
Expand All @@ -68,6 +91,8 @@ export async function PATCH(
if (displayMode !== undefined) updateData.displayMode = displayMode;
if (isHidden !== undefined) updateData.isHidden = isHidden;
if (hideFromStats !== undefined) updateData.hideFromStats = hideFromStats;
if (autoSyncInterval !== undefined)
updateData.autoSyncInterval = autoSyncInterval;

const [updated] = await db
.update(icloudSyncs)
Expand Down
Loading