-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d2b455
commit 8dc59d1
Showing
2 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import React from 'react'; | ||
import InviteAdmin from '../invite-admin'; | ||
|
||
|
||
export default function Home() { | ||
|
||
|
||
return ( | ||
<div className="flex items-center justify-center"> | ||
logged in! | ||
</div> | ||
<><div className="flex items-center justify-center mb-2"> | ||
Success! Logged in! | ||
</div><InviteAdmin /></> | ||
|
||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"use client"; | ||
|
||
import React, { useState } from 'react'; | ||
import { doc, setDoc, getFirestore } from 'firebase/firestore'; | ||
|
||
const InviteAdmin = () => { | ||
const [email, setEmail] = useState(''); | ||
const [status, setStatus] = useState(''); | ||
const db = getFirestore(); | ||
|
||
const handleInvite = async (e: any) => { | ||
e.preventDefault(); | ||
const inviteRef = doc(db, 'invitations', email); | ||
|
||
try { | ||
await setDoc(inviteRef, { invited: true }); | ||
setStatus('Invitation sent successfully.'); | ||
setEmail(''); | ||
} catch (error: any) { | ||
setStatus(`Failed to send invitation: ${error.message}`); | ||
} | ||
}; | ||
|
||
|
||
|
||
return ( | ||
<div className="flex items-center justify-center"> | ||
<form onSubmit={handleInvite} className="flex flex-col items-center"> | ||
<input | ||
className="mb-2 p-2 border w-full rounded border-gray-400" | ||
type="email" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
placeholder="Enter email to invite" | ||
required | ||
/> | ||
<button | ||
type="submit" | ||
style={{ | ||
backgroundColor: '#00629B', | ||
color: 'white', | ||
border: 'none', | ||
borderRadius: '4px', | ||
padding: '7px 14px', | ||
cursor: 'pointer', | ||
}} | ||
className="hover:bg-blue-700 transition-colors" | ||
> | ||
Add Admin | ||
</button> | ||
</form> | ||
{status && <p>{status}</p>} | ||
</div> | ||
); | ||
|
||
}; | ||
|
||
export default InviteAdmin; |