-
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.
Merge pull request #31 from CSE2102-Spring25/develop-final
setting up develop-final branch with new pages and features
- Loading branch information
Showing
5 changed files
with
44 additions
and
94 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
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,75 +1,60 @@ | ||
import React, { useEffect, useState } from "react"; | ||
import { useNavigate, useParams } from "react-router-dom"; | ||
import { useEffect, useState } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
type Applicant = { | ||
id: number; | ||
name: string; | ||
location: string; | ||
email: string; | ||
reason: string; | ||
care: string; | ||
home: string; | ||
pet_id: number; | ||
}; | ||
|
||
export default function ApplicantsPage() { | ||
const { id } = useParams(); | ||
const navigate = useNavigate(); | ||
export default function AllApplicantsPage() { | ||
const [applicants, setApplicants] = useState<Applicant[]>([]); | ||
const [menuOpen, setMenuOpen] = useState(true); | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
fetch(`http://localhost:5000/api/pets/${id}/applicants`) | ||
fetch("http://localhost:5000/api/applicants") | ||
.then(res => res.json()) | ||
.then(data => setApplicants(data)) | ||
.catch(err => console.error("Failed to load applicants:", err)); | ||
}, [id]); | ||
.catch(err => console.error("Error loading applicants:", err)); | ||
}, []); | ||
|
||
return ( | ||
<div style={{ display: "flex" }}> | ||
{/* Sidebar */} | ||
<div style={{ | ||
width: menuOpen ? "200px" : "50px", | ||
background: "#333", | ||
color: "white", | ||
height: "100vh", | ||
padding: "1rem", | ||
transition: "width 0.3s" | ||
}}> | ||
<div | ||
style={{ cursor: "pointer", fontSize: "1.5rem", marginBottom: "1rem" }} | ||
onClick={() => setMenuOpen(!menuOpen)} | ||
> | ||
☰ | ||
</div> | ||
{menuOpen && ( | ||
<div style={{ display: "flex", flexDirection: "column", gap: "1rem" }}> | ||
<button onClick={() => navigate("/pao/pets/new")} style={menuBtn}>New Pet Listing</button> | ||
<button onClick={() => navigate("/pao/listings")} style={menuBtn}>Edit Pet Listings</button> | ||
<button onClick={() => navigate("/pao/applicants")} style={menuBtn}>Applicants</button> | ||
<div style={{ padding: "2rem" }}> | ||
<h1>All Adoption Applicants</h1> | ||
<div style={{ display: "flex", gap: "1rem", flexWrap: "wrap" }}> | ||
{applicants.map(app => ( | ||
<div key={app.id} style={{ | ||
backgroundColor: "#6f655a", | ||
padding: "1rem", | ||
borderRadius: "8px", | ||
color: "white", | ||
width: "260px", | ||
boxShadow: "4px 4px 10px rgba(0,0,0,0.2)" | ||
}}> | ||
<h3>{app.name}, {app.location}</h3> | ||
<p><strong>Email:</strong> {app.email}</p> | ||
<p><strong>Reason:</strong> {app.reason}</p> | ||
<button | ||
style={{ | ||
backgroundColor: "black", | ||
color: "white", | ||
border: "none", | ||
padding: "0.5rem 1rem", | ||
borderRadius: "6px", | ||
cursor: "pointer" | ||
}} | ||
onClick={() => navigate(`/pao/applicants/${app.id}`)} | ||
> | ||
View Full Application | ||
</button> | ||
</div> | ||
)} | ||
</div> | ||
|
||
{/* Main View */} | ||
<div style={{ flexGrow: 1, padding: "2rem" }}> | ||
<h1>Applicants for Pet ID: {id}</h1> | ||
{applicants.length === 0 ? ( | ||
<p>No applications yet.</p> | ||
) : ( | ||
<ul> | ||
{applicants.map((app, idx) => ( | ||
<li key={idx}> | ||
{app.name} — {app.reason} | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
const menuBtn: React.CSSProperties = { | ||
background: "#555", | ||
border: "none", | ||
color: "white", | ||
padding: "0.5rem 1rem", | ||
textAlign: "left", | ||
cursor: "pointer", | ||
borderRadius: "4px" | ||
}; |
This file was deleted.
Oops, something went wrong.