Fix certificate issues

This commit is contained in:
Rotimi Best
2023-08-02 22:38:12 +01:00
parent 60d0c6d837
commit f09db20dda
2 changed files with 25 additions and 39 deletions
@@ -1,20 +1,14 @@
<script> <script>
import { course } from '$lib/components/Course/store'; import Box from '$lib/components/Box/index.svelte';
</script> </script>
<section class="studentContainer flex items-center justify-center w-full"> <Box>
<div class="flex flex-col items-center justify-center w-max h-full gap-2"> <div class="flex flex-col items-center justify-center w-max h-full gap-2">
<img src={`./${$course.certificate_theme}.svg`} alt="Certificate" /> <img src="/professional.svg" alt="Certificate" />
<p class="text-xl font-normal text-center">Certificates not available</p> <p class="text-xl font-normal text-center">Certificates not available</p>
<p class="text-sm font-normal text-center"> <p class="text-sm font-normal text-center">
Your instructor needs to unlock your certificate. <br /> If you need your certificate, Your instructor needs to unlock your certificate. <br /> If you need your certificate, please contact
please contact your instructor. your instructor.
</p> </p>
</div> </div>
</section> </Box>
<style>
.studentContainer {
height: 80vh;
}
</style>
@@ -3,29 +3,27 @@
import { currentOrg } from '$lib/utils/store/org'; import { currentOrg } from '$lib/utils/store/org';
import { profile } from '$lib/utils/store/user'; import { profile } from '$lib/utils/store/user';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte'; import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import Box from '$lib/components/Box/index.svelte';
let isLoading = false; let isLoading = false;
const downLoadCertificate = async () => { const downLoadCertificate = async () => {
isLoading = true; isLoading = true;
const response = await fetch( const response = await fetch('https://classroomio-server.fly.dev/downloadCertificate', {
'https://classroomio-server.fly.dev/downloadCertificate', method: 'POST',
{ headers: {
method: 'POST', Accept: 'application/json',
headers: { 'Content-Type': 'application/json'
Accept: 'application/json', },
'Content-Type': 'application/json', body: JSON.stringify({
}, theme: `${$course.certificate_theme}`,
body: JSON.stringify({ studentName: `${$profile.fullname}`,
theme: `${$course.certificate_theme}`, courseName: `${$course.title}`,
studentName: `${$profile.fullname}`, courseDescription: `${$course.description}`,
courseName: `${$course.title}`, orgLogoUrl: `${$currentOrg.avatar_url}`,
courseDescription: `${$course.description}`, orgName: `${$currentOrg.name}`
orgLogoUrl: `${$currentOrg.avatar_url}`, })
orgName: `${$currentOrg.name}`, });
}),
}
);
const data = await response.blob(); const data = await response.blob();
console.log(data); console.log(data);
const file = new Blob([data], { type: 'application/pdf' }); const file = new Blob([data], { type: 'application/pdf' });
@@ -35,9 +33,9 @@
}; };
</script> </script>
<section class="studentContainer flex items-center justify-center w-full"> <Box>
<div class="flex flex-col items-center justify-center w-max h-full gap-5"> <div class="flex flex-col items-center justify-center w-max h-full gap-5">
<img src={`./${$course.certificate_theme}.svg`} alt="Certificate" /> <img src="/professional.svg" alt="Certificate" />
<p class="text-xl font-normal text-center">Certificate is now available</p> <p class="text-xl font-normal text-center">Certificate is now available</p>
<PrimaryButton <PrimaryButton
label="DownLoad Certificate" label="DownLoad Certificate"
@@ -46,10 +44,4 @@
{isLoading} {isLoading}
/> />
</div> </div>
</section> </Box>
<style>
.studentContainer {
height: 80vh;
}
</style>