diff --git a/src/lib/components/CourseLandingPage/components/utils.ts b/src/lib/components/CourseLandingPage/components/utils.ts
new file mode 100644
index 00000000..282ab3e7
--- /dev/null
+++ b/src/lib/components/CourseLandingPage/components/utils.ts
@@ -0,0 +1,60 @@
+import { supabase } from '$lib/utils/functions/supabase';
+
+export async function sendTeacherStudentJoinRequest(params: {
+ to: string;
+ courseName: string;
+ studentEmail: string;
+ studentFullname: string;
+}) {
+ const { data } = await supabase.auth.getSession();
+ const accessToken = data.session?.access_token || '';
+
+ try {
+ const response = await fetch('/api/email/course/teacher_student_buycourse', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: accessToken
+ },
+ body: JSON.stringify(params)
+ });
+ if (!response.ok) {
+ throw new Error(await response.text());
+ }
+ const result = await response.json();
+
+ console.log('Sent invite email', result);
+ } catch (error) {
+ console.error('Error sending invite email', error);
+ }
+}
+
+export async function sendStudentRequestReceipt(params: {
+ to: string;
+ courseName: string;
+ orgName: string;
+ studentFullname: string;
+ teacherEmail: string;
+}) {
+ const { data } = await supabase.auth.getSession();
+ const accessToken = data.session?.access_token || '';
+
+ try {
+ const response = await fetch('/api/email/course/student_prove_payment', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: accessToken
+ },
+ body: JSON.stringify(params)
+ });
+ if (!response.ok) {
+ throw new Error(await response.text());
+ }
+ const result = await response.json();
+
+ console.log('Sent invite email', result);
+ } catch (error) {
+ console.error('Error sending invite email', error);
+ }
+}
diff --git a/src/lib/components/CourseLandingPage/index.svelte b/src/lib/components/CourseLandingPage/index.svelte
index a3101f38..18461649 100644
--- a/src/lib/components/CourseLandingPage/index.svelte
+++ b/src/lib/components/CourseLandingPage/index.svelte
@@ -26,11 +26,7 @@
dayjs.extend(relativeTime);
export let editMode = false;
- export let courseData: Course = {
- id: '',
- title: '',
- description: ''
- };
+ export let courseData: Course;
const ratingsImg = [
'/images/rating-1.svg',
'/images/rating-2.svg',
@@ -44,6 +40,7 @@
let player: any;
let averageRating = 0;
let totalRatings = 0;
+ let startCoursePayment = false;
// initialize the expandDescription array with 'false' values for each review.
let expandDescription = Array(reviews.length).fill(false);
@@ -62,16 +59,6 @@
activeNav = window.location.hash;
}
- function addToCart() {}
-
- function buyNow() {
- // if (courseData.cost) {
- // paystackApi.tra;
- // } else {
- // // Course is free
- // }
- }
-
function initPlyr(_player: any, _video: string | undefined) {
if (!player) return;
@@ -120,7 +107,13 @@
{get(courseData, 'metadata.instructor.name', '')}
-
+
{
+ startCoursePayment = true;
+ }}
+ />