-
Notifications
You must be signed in to change notification settings - Fork 0
Issue 171/admin dashboard #239
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
Open
hunterShierman
wants to merge
2
commits into
main
Choose a base branch
from
issue-171/admin-dashboard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
240 changes: 240 additions & 0 deletions
240
frontend/src/features/admin/components/AddInterviewers.tsx
This file contains hidden or 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,240 @@ | ||
| import { useState } from "react"; | ||
|
|
||
| interface AddInterviewersProps { | ||
| departments?: string[]; | ||
| } | ||
|
|
||
| export default function AddInterviewers({ departments = ["Engineering", "Design", "Marketing", "Product", "Operations"] }: AddInterviewersProps) { | ||
| const [activeTab, setActiveTab] = useState<"interviewers" | "candidates">("interviewers"); | ||
|
|
||
| // Interviewer form state | ||
| const [firstName, setFirstName] = useState(""); | ||
| const [lastName, setLastName] = useState(""); | ||
| const [email, setEmail] = useState(""); | ||
| const [department, setDepartment] = useState(""); | ||
| const [isSubmitting, setIsSubmitting] = useState(false); | ||
| const [successMessage, setSuccessMessage] = useState(""); | ||
| const [errorMessage, setErrorMessage] = useState(""); | ||
|
|
||
| // Candidate form state | ||
| const [candidateFirstName, setCandidateFirstName] = useState(""); | ||
| const [candidateLastName, setCandidateLastName] = useState(""); | ||
| const [candidateEmail, setCandidateEmail] = useState(""); | ||
| const [candidateDepartment, setCandidateDepartment] = useState(""); | ||
| const [isCandidateSubmitting, setIsCandidateSubmitting] = useState(false); | ||
| const [candidateSuccessMessage, setCandidateSuccessMessage] = useState(""); | ||
| const [candidateErrorMessage, setCandidateErrorMessage] = useState(""); | ||
|
|
||
| const handleSendInvite = async () => { | ||
| setSuccessMessage(""); | ||
| setErrorMessage(""); | ||
|
|
||
| if (!firstName || !lastName || !email || !department) { | ||
| setErrorMessage("Please fill in all fields."); | ||
| return; | ||
| } | ||
|
|
||
| const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | ||
| if (!emailRegex.test(email)) { | ||
| setErrorMessage("Please enter a valid email address."); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| setIsSubmitting(true); | ||
| // TODO: Replace with actual API call | ||
| await new Promise((resolve) => setTimeout(resolve, 800)); | ||
|
|
||
| setSuccessMessage(`Invite sent to ${email} successfully.`); | ||
| setFirstName(""); | ||
| setLastName(""); | ||
| setEmail(""); | ||
| setDepartment(""); | ||
| } catch (err) { | ||
| setErrorMessage("Failed to send invite. Please try again."); | ||
| console.log(err); | ||
| } finally { | ||
| setIsSubmitting(false); | ||
| } | ||
| }; | ||
|
|
||
| const handleSendCandidateInvite = async () => { | ||
| setCandidateSuccessMessage(""); | ||
| setCandidateErrorMessage(""); | ||
|
|
||
| if (!candidateFirstName || !candidateLastName || !candidateEmail || !candidateDepartment) { | ||
| setCandidateErrorMessage("Please fill in all fields."); | ||
| return; | ||
| } | ||
|
|
||
| const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; | ||
| if (!emailRegex.test(candidateEmail)) { | ||
| setCandidateErrorMessage("Please enter a valid email address."); | ||
| return; | ||
| } | ||
|
|
||
| try { | ||
| setIsCandidateSubmitting(true); | ||
| // TODO: Replace with actual API call | ||
| await new Promise((resolve) => setTimeout(resolve, 800)); | ||
|
|
||
| setCandidateSuccessMessage(`Invite sent to ${candidateEmail} successfully.`); | ||
| setCandidateFirstName(""); | ||
| setCandidateLastName(""); | ||
| setCandidateEmail(""); | ||
| setCandidateDepartment(""); | ||
| } catch (err) { | ||
| setCandidateErrorMessage("Failed to send invite. Please try again."); | ||
| console.log(err); | ||
| } finally { | ||
| setIsCandidateSubmitting(false); | ||
| } | ||
| }; | ||
|
|
||
| const formUI = ( | ||
| values: { firstName: string; lastName: string; email: string; department: string }, | ||
| handlers: { | ||
| setFirstName: (v: string) => void; | ||
| setLastName: (v: string) => void; | ||
| setEmail: (v: string) => void; | ||
| setDepartment: (v: string) => void; | ||
| }, | ||
| isSubmitting: boolean, | ||
| successMessage: string, | ||
| errorMessage: string, | ||
| handleSubmit: () => void | ||
| ) => ( | ||
| <div> | ||
| <p className="text-base font-semibold text-gray-700 mb-4">Add Information</p> | ||
|
|
||
| {successMessage && ( | ||
| <div className="mb-4 text-base text-green-700 bg-green-50 border border-green-200 rounded-lg px-4 py-3"> | ||
| {successMessage} | ||
| </div> | ||
| )} | ||
| {errorMessage && ( | ||
| <div className="mb-4 text-base text-red-700 bg-red-50 border border-red-200 rounded-lg px-4 py-3"> | ||
| {errorMessage} | ||
| </div> | ||
| )} | ||
|
|
||
| <div className="mb-5"> | ||
| <label className="block text-base text-gray-600 mb-2">First name</label> | ||
| <input | ||
| type="text" | ||
| value={values.firstName} | ||
| onChange={(e) => handlers.setFirstName(e.target.value)} | ||
| className="w-full px-4 py-3 bg-gray-100 rounded-md text-base text-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-300" | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="mb-5"> | ||
| <label className="block text-base text-gray-600 mb-2">Last name</label> | ||
| <input | ||
| type="text" | ||
| value={values.lastName} | ||
| onChange={(e) => handlers.setLastName(e.target.value)} | ||
| className="w-full px-4 py-3 bg-gray-100 rounded-md text-base text-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-300" | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="mb-5"> | ||
| <label className="block text-base text-gray-600 mb-2">Email address</label> | ||
| <input | ||
| type="email" | ||
| value={values.email} | ||
| onChange={(e) => handlers.setEmail(e.target.value)} | ||
| className="w-full px-4 py-3 bg-gray-100 rounded-md text-base text-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-300" | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="mb-8"> | ||
| <label className="block text-base text-gray-600 mb-2">Department</label> | ||
| <select | ||
| value={values.department} | ||
| onChange={(e) => handlers.setDepartment(e.target.value)} | ||
| className="w-64 px-4 py-3 bg-gray-100 rounded-md text-base text-gray-800 focus:outline-none focus:ring-2 focus:ring-blue-300 cursor-pointer" | ||
| > | ||
| <option value="">Select</option> | ||
| {departments.map((dept) => ( | ||
| <option key={dept} value={dept}> | ||
| {dept} | ||
| </option> | ||
| ))} | ||
| </select> | ||
| </div> | ||
|
|
||
| <div className="flex justify-end"> | ||
| <button | ||
| onClick={handleSubmit} | ||
| disabled={isSubmitting} | ||
| className="bg-gray-900 hover:bg-gray-700 disabled:bg-gray-400 disabled:cursor-not-allowed text-white text-base font-medium px-6 py-3 rounded-lg transition-colors" | ||
| > | ||
| {isSubmitting ? "Sending..." : "Send Invite"} | ||
| </button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| return ( | ||
| <> | ||
| <style>{` | ||
| @keyframes fadeIn { | ||
| from { opacity: 0; transform: translateY(6px); } | ||
| to { opacity: 1; transform: translateY(0); } | ||
| } | ||
| `}</style> | ||
| <div className="bg-white rounded-xl border border-gray-200 p-8 max-w-5xl"> | ||
| <h1 className="text-3xl font-bold text-gray-900">Add Team Members</h1> | ||
| <p className="text-gray-500 text-base mt-1 mb-6"> | ||
| Send invitations for interviewers and candidates to join your team! | ||
| </p> | ||
|
|
||
| {/* Tabs */} | ||
| <div className="border-b border-gray-200 mb-6"> | ||
| <div className="flex"> | ||
| <button | ||
| onClick={() => setActiveTab("interviewers")} | ||
| className={`pb-3 px-4 text-base font-medium transition-colors ${ | ||
| activeTab === "interviewers" | ||
| ? "border-b-2 border-gray-900 text-gray-900" | ||
| : "text-gray-400 hover:text-gray-600" | ||
| }`} | ||
| > | ||
| Add Interviewers | ||
| </button> | ||
| <button | ||
| onClick={() => setActiveTab("candidates")} | ||
| className={`pb-3 px-4 text-base font-medium transition-colors ${ | ||
| activeTab === "candidates" | ||
| ? "border-b-2 border-gray-900 text-gray-900" | ||
| : "text-gray-400 hover:text-gray-600" | ||
| }`} | ||
| > | ||
| Add Candidates | ||
| </button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div key={activeTab} style={{ animation: "fadeIn 0.2s ease-in-out" }}> | ||
| {activeTab === "interviewers" | ||
| ? formUI( | ||
| { firstName, lastName, email, department }, | ||
| { setFirstName, setLastName, setEmail, setDepartment }, | ||
| isSubmitting, | ||
| successMessage, | ||
| errorMessage, | ||
| handleSendInvite | ||
| ) | ||
| : formUI( | ||
| { firstName: candidateFirstName, lastName: candidateLastName, email: candidateEmail, department: candidateDepartment }, | ||
| { setFirstName: setCandidateFirstName, setLastName: setCandidateLastName, setEmail: setCandidateEmail, setDepartment: setCandidateDepartment }, | ||
| isCandidateSubmitting, | ||
| candidateSuccessMessage, | ||
| candidateErrorMessage, | ||
| handleSendCandidateInvite | ||
| )} | ||
| </div> | ||
| </div> | ||
| </> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic that involves the backend should be in the service's folder.