Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add role and linkedin to register form #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ interface Event {
agenda: { time: string; topic: string }[];
}

interface Participant {
name: string;
email: string;
role: string;
linkedin: string;
}

function App() {
const [participant, setParticipant] = useState<{ name: string; email: string; } | null>(null);
const [participant, setParticipant] = useState<Participant | null>(null);
const [event, setEvent] = useState<Event | null>(null);
const [loading, setLoading] = useState(false);
const [fetchingEvent, setFetchingEvent] = useState(true);

const handleRegister = async (name: string, email: string) => {
const handleRegister = async (name: string, email: string, role: string, linkedin: string) => {
if (!event) return;

setLoading(true);
Expand All @@ -41,14 +48,16 @@ function App() {
await addDoc(participantsRef, {
name,
email,
role,
linkedin,
eventId: event.id,
timestamp: Timestamp.now(),
});
} else {
console.log("El usuario ya está registrado para este evento.");
}

setParticipant({ name, email });
setParticipant({ name, email, role, linkedin });
} catch (error) {
console.error("Error al registrar al participante:", error);
}
Expand Down
34 changes: 31 additions & 3 deletions src/components/registration-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ import React, { useState } from 'react';


interface RegistrationFormProps {
onRegister: (name: string, email: string) => void;
onRegister: (name: string, email: string, role: string, linkedin: string) => void;
}

function RegistrationForm({ onRegister }: RegistrationFormProps) {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [role, setRole] = useState('');
const [linkedin, setLinkedin] = useState('');

const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (name && email) {
onRegister(name, email);
if (name && email && role && linkedin) {
onRegister(name, email, role, linkedin);
}
};

Expand Down Expand Up @@ -46,6 +48,32 @@ function RegistrationForm({ onRegister }: RegistrationFormProps) {
required
/>
</div>
<div>
<label htmlFor="role" className="block text-sm font-medium mb-2">
Role
</label>
<input
type="text"
id="role"
value={role}
onChange={(e) => setRole(e.target.value)}
className="w-full px-4 py-2 rounded-lg bg-zinc-800 border border-zinc-700 focus:outline-none focus:border-purple-500"
required
/>
</div>
<div>
<label htmlFor="linkedin" className="block text-sm font-medium mb-2">
Linkedin
</label>
<input
type="text"
id="linkedin"
value={linkedin}
onChange={(e) => setLinkedin(e.target.value)}
className="w-full px-4 py-2 rounded-lg bg-zinc-800 border border-zinc-700 focus:outline-none focus:border-purple-500"
required
/>
</div>
<button
type="submit"
className="w-full bg-purple-500 hover:bg-purple-600 text-white font-bold py-2 px-4 rounded-lg transition duration-200"
Expand Down