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

initialized new branch --> removed unecessary applicant api calls in … #87

Merged
merged 1 commit into from
Feb 16, 2024
Merged
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
18 changes: 1 addition & 17 deletions app/admin/listing/[listingId]/insights/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ import { FlowbiteTabTheme } from "flowbite-react";

export default function Insights({ params }: { params: { listingId: string } }) {
const router = useRouter();
// applicantData : list of applicants
const [applicantData, setApplicantData] = useState<[] | Applicant[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(true);
// dashboard : object containing data from backend (# applicants, average gpa, #1 major, avg gradYear, avg response length)
const [dashboard, setDashboard] = useState<Dashboard>({
applicantCount: null,
Expand Down Expand Up @@ -44,19 +41,6 @@ export default function Insights({ params }: { params: { listingId: string } })

// matchingApplicants : list of applicants depending on which part of PieChart (if any) has been clicked
const [matchingApplicants, setMatchingApplicants] = useState<[] | Applicant[]>([]);

// Fetch listings data from your /listings API endpoint
useEffect(() => {
fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/applicants/${params.listingId}`)
.then((response) => response.json())
.then((data: [Applicant]) => {
setApplicantData(data)
setIsLoading(false);
})
.catch((error) => console.error("Error fetching applicants:", error));

}, [])


// Fetch insights data from your /listings API endpoint
useEffect(() => {
Expand Down Expand Up @@ -202,7 +186,7 @@ export default function Insights({ params }: { params: { listingId: string } })
}

// if applicants data not yet received : produce loading screen
if (isLoading || insightsLoading) return (<Loader />)
if (insightsLoading) return (<Loader />)

return (
<div>
Expand Down
Loading