Skip to content

Commit

Permalink
More feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
faucomte97 committed Oct 18, 2024
1 parent 49010db commit 5917439
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/components/StudentCredentialsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ const StudentCredentialsPDF: FC<{
key={`${student.user.first_name}-pdf`}
style={pdfStyles.mainView}
>
<Image source={CflLogoImage} src={CflLogoImage} style={pdfStyles.image} />
<Image
source={CflLogoImage}
src={CflLogoImage}
style={pdfStyles.image}
/>
<View>
{/*TODO: Auto login link is too long and doesn't fit in PDF.*/}
<Text style={pdfStyles.text}>
Expand Down Expand Up @@ -115,8 +119,8 @@ const DownloadPDFButton: FC<DownloadButtonProps> = ({
if (linkRef.current) {
linkRef.current.href = url
linkRef.current.click()

Check warning on line 121 in src/components/StudentCredentialsTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/StudentCredentialsTable.tsx#L120-L121

Added lines #L120 - L121 were not covered by tests
URL.revokeObjectURL(url)
}
URL.revokeObjectURL(url)

Check warning on line 123 in src/components/StudentCredentialsTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/StudentCredentialsTable.tsx#L123

Added line #L123 was not covered by tests
} catch (error) {
console.error(error)

Check warning on line 125 in src/components/StudentCredentialsTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/StudentCredentialsTable.tsx#L125

Added line #L125 was not covered by tests
}
Expand All @@ -143,10 +147,7 @@ const DownloadCSVButton: FC<DownloadButtonProps> = ({
classLoginLink,
students,
}) => {
const generateCSV: (
students: StudentCredentialsTableProps["students"],
classLoginLink: string,
) => string = (students, classLoginLink) => {
const generateCSV: () => string = () => {
let csvContent = "Name,Password,Class Link,Login URL\n"
students.forEach(student => {
csvContent += `${student.user.first_name},${student.user.password},${classLoginLink},${makeAutoLoginLink(classLoginLink, student)}\n`

Check warning on line 153 in src/components/StudentCredentialsTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/StudentCredentialsTable.tsx#L150-L153

Added lines #L150 - L153 were not covered by tests
Expand All @@ -156,7 +157,7 @@ const DownloadCSVButton: FC<DownloadButtonProps> = ({
const linkRef = useRef<HTMLAnchorElement | null>(null)

Check warning on line 157 in src/components/StudentCredentialsTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/StudentCredentialsTable.tsx#L157

Added line #L157 was not covered by tests

const downloadCSV: () => void = () => {
const csvContent = generateCSV(students, classLoginLink)
const csvContent = generateCSV()
const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" })
const url = URL.createObjectURL(blob)

Check warning on line 162 in src/components/StudentCredentialsTable.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/StudentCredentialsTable.tsx#L159-L162

Added lines #L159 - L162 were not covered by tests

Expand Down

0 comments on commit 5917439

Please sign in to comment.