feat: add email, scheduler, and Zulip integration services
- Add email service for sending meeting invites with ICS attachments - Add scheduler for background calendar sync jobs - Add Zulip service for meeting notifications - Make ics_url optional for participants - Add /api/schedule endpoint with 2-hour lead time validation - Update frontend to support scheduling flow Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { TimeSlot, Participant } from '@/types/calendar';
|
||||
import { scheduleMeeting } from '@/api/client';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -11,7 +12,7 @@ import { Input } from '@/components/ui/input';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { Calendar, Clock, Users, Send } from 'lucide-react';
|
||||
import { Calendar, Clock, Users, Send, AlertCircle } from 'lucide-react';
|
||||
|
||||
interface ScheduleModalProps {
|
||||
isOpen: boolean;
|
||||
@@ -34,7 +35,23 @@ export const ScheduleModal = ({
|
||||
return `${hour.toString().padStart(2, '0')}:00`;
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
const formatDate = (dateStr: string) => {
|
||||
const date = new Date(dateStr + 'T00:00:00');
|
||||
return date.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' });
|
||||
};
|
||||
|
||||
const isTooSoon = () => {
|
||||
if (!slot) return false;
|
||||
// Use UTC to match backend timezone
|
||||
const startDateTime = new Date(`${slot.day}T${formatHour(slot.hour)}:00Z`);
|
||||
const now = new Date();
|
||||
const twoHoursFromNow = new Date(now.getTime() + 2 * 60 * 60 * 1000);
|
||||
return startDateTime < twoHoursFromNow;
|
||||
};
|
||||
|
||||
const tooSoon = isTooSoon();
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!title.trim()) {
|
||||
toast({
|
||||
title: "Please enter a meeting title",
|
||||
@@ -43,19 +60,41 @@ export const ScheduleModal = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (!slot) return;
|
||||
|
||||
setIsSubmitting(true);
|
||||
|
||||
// Simulate API call
|
||||
setTimeout(() => {
|
||||
setIsSubmitting(false);
|
||||
try {
|
||||
// Calculate start and end times
|
||||
// slot.day is YYYY-MM-DD
|
||||
const startDateTime = new Date(`${slot.day}T${formatHour(slot.hour)}:00Z`);
|
||||
const endDateTime = new Date(`${slot.day}T${formatHour(slot.hour + 1)}:00Z`);
|
||||
|
||||
await scheduleMeeting(
|
||||
participants.map(p => p.id),
|
||||
title,
|
||||
notes,
|
||||
startDateTime.toISOString(),
|
||||
endDateTime.toISOString()
|
||||
);
|
||||
|
||||
toast({
|
||||
title: "Meeting scheduled",
|
||||
description: "Invitations sent to all participants",
|
||||
description: "Invitations sent via Email and Zulip",
|
||||
});
|
||||
|
||||
setTitle('');
|
||||
setNotes('');
|
||||
onClose();
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: "Scheduling failed",
|
||||
description: error instanceof Error ? error.message : "Unknown error",
|
||||
variant: "destructive",
|
||||
});
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
if (!slot) return null;
|
||||
@@ -72,7 +111,7 @@ export const ScheduleModal = ({
|
||||
<div className="bg-accent/50 rounded-lg p-4 space-y-3">
|
||||
<div className="flex items-center gap-3 text-sm">
|
||||
<Calendar className="w-4 h-4 text-primary" />
|
||||
<span className="font-medium">{slot.day}</span>
|
||||
<span className="font-medium">{formatDate(slot.day)}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3 text-sm">
|
||||
<Clock className="w-4 h-4 text-primary" />
|
||||
@@ -109,12 +148,20 @@ export const ScheduleModal = ({
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Lead Time Warning */}
|
||||
{tooSoon && (
|
||||
<div className="flex items-center gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-lg text-sm text-destructive">
|
||||
<AlertCircle className="w-4 h-4 flex-shrink-0" />
|
||||
<span>Meetings must be scheduled at least 2 hours in advance</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Actions */}
|
||||
<Button
|
||||
variant="schedule"
|
||||
className="w-full h-12"
|
||||
onClick={handleSubmit}
|
||||
disabled={isSubmitting}
|
||||
disabled={isSubmitting || tooSoon}
|
||||
>
|
||||
{isSubmitting ? (
|
||||
<span className="animate-pulse">Sending...</span>
|
||||
|
||||
Reference in New Issue
Block a user