JosepinPai commited on
Commit
326d002
·
verified ·
1 Parent(s): c38824d

Upload components/EventModal.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/EventModal.jsx +178 -0
components/EventModal.jsx ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect } from 'react';
2
+
3
+ const COLORS = [
4
+ { name: 'blue', label: 'Azul', class: 'bg-blue-500' },
5
+ { name: 'green', label: 'Verde', class: 'bg-green-500' },
6
+ { name: 'red', label: 'Rojo', class: 'bg-red-500' },
7
+ { name: 'purple', label: 'Morado', class: 'bg-purple-500' },
8
+ { name: 'orange', label: 'Naranja', class: 'bg-orange-500' },
9
+ { name: 'pink', label: 'Rosa', class: 'bg-pink-500' },
10
+ ];
11
+
12
+ export default function EventModal({ isOpen, onClose, onSave, selectedDate, editEvent }) {
13
+ const [title, setTitle] = useState('');
14
+ const [description, setDescription] = useState('');
15
+ const [time, setTime] = useState('');
16
+ const [color, setColor] = useState('blue');
17
+ const [date, setDate] = useState('');
18
+
19
+ useEffect(() => {
20
+ if (editEvent) {
21
+ setTitle(editEvent.title);
22
+ setDescription(editEvent.description || '');
23
+ setTime(editEvent.time || '');
24
+ setColor(editEvent.color);
25
+ setDate(editEvent.date);
26
+ } else {
27
+ setTitle('');
28
+ setDescription('');
29
+ setTime('');
30
+ setColor('blue');
31
+ setDate(selectedDate || '');
32
+ }
33
+ }, [editEvent, selectedDate, isOpen]);
34
+
35
+ const handleSubmit = (e) => {
36
+ e.preventDefault();
37
+ if (!title.trim() || !date) return;
38
+
39
+ onSave({
40
+ id: editEvent?.id || null,
41
+ title: title.trim(),
42
+ description: description.trim(),
43
+ time,
44
+ color,
45
+ date,
46
+ });
47
+
48
+ onClose();
49
+ };
50
+
51
+ if (!isOpen) return null;
52
+
53
+ return (
54
+ <div className="fixed inset-0 z-50 overflow-y-auto">
55
+ <div className="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:p-0">
56
+ {/* Backdrop */}
57
+ <div
58
+ className="fixed inset-0 bg-slate-900 bg-opacity-50 transition-opacity"
59
+ onClick={onClose}
60
+ ></div>
61
+
62
+ {/* Modal */}
63
+ <div className="relative bg-white rounded-2xl shadow-2xl max-w-md w-full mx-auto z-10 transform transition-all">
64
+ <div className="p-6">
65
+ {/* Header */}
66
+ <div className="flex items-center justify-between mb-6">
67
+ <h3 className="text-xl font-bold text-slate-800">
68
+ {editEvent ? 'Editar Evento' : 'Nuevo Evento'}
69
+ </h3>
70
+ <button
71
+ onClick={onClose}
72
+ className="p-2 hover:bg-slate-100 rounded-lg transition-colors duration-200"
73
+ >
74
+ <svg className="w-5 h-5 text-slate-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
75
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
76
+ </svg>
77
+ </button>
78
+ </div>
79
+
80
+ {/* Form */}
81
+ <form onSubmit={handleSubmit} className="space-y-4">
82
+ <div>
83
+ <label className="block text-sm font-medium text-slate-700 mb-1">
84
+ Título del evento *
85
+ </label>
86
+ <input
87
+ type="text"
88
+ value={title}
89
+ onChange={(e) => setTitle(e.target.value)}
90
+ className="input-field"
91
+ placeholder="Ej: Reunión de trabajo"
92
+ required
93
+ />
94
+ </div>
95
+
96
+ <div>
97
+ <label className="block text-sm font-medium text-slate-700 mb-1">
98
+ Fecha *
99
+ </label>
100
+ <input
101
+ type="date"
102
+ value={date}
103
+ onChange={(e) => setDate(e.target.value)}
104
+ className="input-field"
105
+ required
106
+ />
107
+ </div>
108
+
109
+ <div>
110
+ <label className="block text-sm font-medium text-slate-700 mb-1">
111
+ Hora
112
+ </label>
113
+ <input
114
+ type="time"
115
+ value={time}
116
+ onChange={(e) => setTime(e.target.value)}
117
+ className="input-field"
118
+ />
119
+ </div>
120
+
121
+ <div>
122
+ <label className="block text-sm font-medium text-slate-700 mb-1">
123
+ Descripción
124
+ </label>
125
+ <textarea
126
+ value={description}
127
+ onChange={(e) => setDescription(e.target.value)}
128
+ className="input-field resize-none"
129
+ rows={3}
130
+ placeholder="Añade detalles sobre el evento..."
131
+ />
132
+ </div>
133
+
134
+ <div>
135
+ <label className="block text-sm font-medium text-slate-700 mb-2">
136
+ Color
137
+ </label>
138
+ <div className="flex gap-2">
139
+ {COLORS.map((c) => (
140
+ <button
141
+ key={c.name}
142
+ type="button"
143
+ onClick={() => setColor(c.name)}
144
+ className={`w-8 h-8 rounded-full ${c.class} transition-all duration-200
145
+ ${color === c.name
146
+ ? 'ring-2 ring-offset-2 ring-slate-400 scale-110'
147
+ : 'hover:scale-105'
148
+ }
149
+ `}
150
+ title={c.label}
151
+ />
152
+ ))}
153
+ </div>
154
+ </div>
155
+
156
+ {/* Actions */}
157
+ <div className="flex gap-3 pt-4">
158
+ <button
159
+ type="button"
160
+ onClick={onClose}
161
+ className="btn-secondary flex-1"
162
+ >
163
+ Cancelar
164
+ </button>
165
+ <button
166
+ type="submit"
167
+ className="btn-primary flex-1"
168
+ >
169
+ {editEvent ? 'Guardar Cambios' : 'Crear Evento'}
170
+ </button>
171
+ </div>
172
+ </form>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ </div>
177
+ );
178
+ }