tahamajs/IE / Projects /front /src /components /networking /EventHostingPanel.tsx
tahamajs's picture
download
raw
5.12 kB
// src/components/networking/EventHostingPanel.tsx
import { useState } from "react";
import { Calendar, Clock, MapPin, Video, Users, Plus, X, Loader2 } from "lucide-react";
import type { EventType } from "@/types/networking";
interface EventHostingPanelProps {
onSave: (data: any) => void;
onClose: () => void;
initial?: any;
}
const EVENT_TYPES: { value: EventType; label: string; icon: typeof Calendar }[] = [
{ value: "journal_club", label: "Journal Club", icon: Calendar },
{ value: "seminar", label: "Seminar", icon: Video },
{ value: "lab_meeting", label: "Lab Meeting", icon: Users },
{ value: "conference", label: "Conference", icon: Calendar },
{ value: "workshop", label: "Workshop", icon: Users },
{ value: "webinar", label: "Webinar", icon: Video },
];
export function EventHostingPanel({ onSave, onClose, initial }: EventHostingPanelProps) {
const [title, setTitle] = useState(initial?.title ?? "");
const [type, setType] = useState<EventType>(initial?.type ?? "journal_club");
const [description, setDescription] = useState(initial?.description ?? "");
const [scheduledStart, setScheduledStart] = useState(initial?.scheduledStart ?? "");
const [scheduledEnd, setScheduledEnd] = useState(initial?.scheduledEnd ?? "");
const [timezone, setTimezone] = useState(Intl.DateTimeFormat().resolvedOptions().timeZone);
const [isOnline, setIsOnline] = useState(true);
const [location, setLocation] = useState(initial?.location ?? "");
const [streamPlatform, setStreamPlatform] = useState(initial?.streamingPlatform ?? "internal");
const [tags, setTags] = useState<string[]>(initial?.tags ?? []);
const [tagInput, setTagInput] = useState("");
const [saving, setSaving] = useState(false);
const handleSubmit = () => {
if (!title.trim()) return;
onSave({ title, type, description, scheduledStart, scheduledEnd, timezone, isOnline, location: isOnline ? undefined : location, streamingPlatform: streamPlatform, tags });
setSaving(true);
setTimeout(() => setSaving(false), 800);
};
return (
<div className="glass rounded-2xl p-6 space-y-4 max-w-lg">
<div className="flex items-center justify-between">
<h3 className="font-bold text-lg">{initial ? "Edit Event" : "Create Event"}</h3>
<button onClick={onClose} className="text-gray-500 hover:text-gray-700"><X className="w-5 h-5" /></button>
</div>
<input type="text" value={title} onChange={e => setTitle(e.target.value)} placeholder="Event title" className="input" autoFocus />
<select aria-label="Select option" value={type} onChange={e => setType(e.target.value as EventType)} className="input">
{EVENT_TYPES.map(t => <option key={t.value} value={t.value}>{t.label}</option>)}
</select>
<textarea value={description} onChange={e => setDescription(e.target.value)} placeholder="Description" className="input" rows={3} />
<div className="grid grid-cols-2 gap-3">
<div>
<label className="text-xs text-gray-500">Start</label>
<input type="datetime-local" value={scheduledStart} onChange={e => setScheduledStart(e.target.value)} className="input" />
</div>
<div>
<label className="text-xs text-gray-500">End</label>
<input type="datetime-local" value={scheduledEnd} onChange={e => setScheduledEnd(e.target.value)} className="input" />
</div>
</div>
<label className="flex items-center gap-2">
<input type="checkbox" checked={isOnline} onChange={e => setIsOnline(e.target.checked)} className="rounded" /> Online event
</label>
{!isOnline && <input type="text" value={location} onChange={e => setLocation(e.target.value)} placeholder="Physical location" className="input" />}
<div>
<label className="text-xs text-gray-500">Streaming platform</label>
<select aria-label="Select option" value={streamPlatform} onChange={e => setStreamPlatform(e.target.value)} className="input">
<option value="internal">Internal (IE Research)</option>
<option value="zoom">Zoom</option>
<option value="youtube">YouTube</option>
<option value="other">Other</option>
</select>
</div>
<div className="flex gap-2">
<input type="text" value={tagInput} onChange={e => setTagInput(e.target.value)} placeholder="Add tag" className="input flex-1"
onKeyDown={e => { if (e.key === "Enter") { setTags([...tags, tagInput.trim()]); setTagInput(""); } }} />
<button onClick={() => { setTags([...tags, tagInput.trim()]); setTagInput(""); }} className="btn btn-secondary btn-sm">Add</button>
</div>
{tags.length > 0 && <div className="flex flex-wrap gap-1">{tags.map(t => <span key={t} className="text-xs bg-white/10 px-2 py-0.5 rounded-full">{t}</span>)}</div>}
<button onClick={handleSubmit} disabled={!title.trim()} className="btn btn-primary w-full gap-2">
{saving ? <Loader2 className="w-4 h-4 animate-spin" /> : <Calendar className="w-4 h-4" />}
{initial ? "Update Event" : "Create Event"}
</button>
</div>
);
}

Xet Storage Details

Size:
5.12 kB
·
Xet hash:
39d75e64489e630758893d7331d42e3b19705586f5f8582484f26518d56ae654

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.