Skip to content

Commit

Permalink
Merge pull request #70 from whyphi/dev/v0.2
Browse files Browse the repository at this point in the history
merge: v0.2 to staging
  • Loading branch information
jinyoungbang authored Feb 3, 2024
2 parents e07f958 + 8021601 commit a9ab37a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 9 additions & 2 deletions app/admin/listing/[listingId]/insights/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function Insights({ params }: { params: { listingId: string } })
});

// applicantData : list of applicants
const [applicantData, setApplicantData] = useState<[] | [Applicant]>([]);
const [applicantData, setApplicantData] = useState<[] | Applicant[]>([]);
// distributionMetrics : object containing frequencies of each metric for all applicants
const [distributionMetrics, setDistributionMetrics] = useState<DistributionMetricsState>({
colleges: [],
Expand Down Expand Up @@ -54,7 +54,14 @@ export default function Insights({ params }: { params: { listingId: string } })
fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/applicants/${params.listingId}`)
.then((response) => response.json())
.then((data: [Applicant]) => {
setApplicantData(data)
const cleanedData: Applicant[] = data.map((applicant: Applicant) => {
return {
...applicant,
major: applicant.major.toLowerCase(),
minor: applicant.minor.toLowerCase(),
};
});
setApplicantData(cleanedData)
setIsLoading(false);
// parseData()
})
Expand Down
12 changes: 8 additions & 4 deletions components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,17 @@ export default function Form({ title, questions, listingId, includeEventsAttende
});

if (response.ok) {
// Handle successful response here, e.g., show a success message or redirect
router.push(`/public/success`);
} else {
// Handle error response here, e.g., show an error message
const code = response.status;
if (code == 410) {
const responseText = await response.text();
alert(`Error submitting form: ${responseText}`)
} else {
console.error('Error submitting form');
alert(`Error submitting form. Please contact PCT with a screenshot of the error!`);
}
setIsSubmitting(false);
console.error('Error submitting form');
alert(`Error submitting form. Please contact PCT with a screenshot of the error!`);
}
} catch (error) {
// Handle any unexpected errors here
Expand Down

0 comments on commit a9ab37a

Please sign in to comment.