2023-09-14 23:04:51 +01:00
|
|
|
import type { Course } from '../types';
|
|
|
|
|
|
|
|
|
|
export const isCourseFree = (cost: number) => !(Number(cost) > 0);
|
|
|
|
|
|
2023-12-05 08:31:26 +03:00
|
|
|
export const getStudentInviteLink = (_course: Course, orgSiteName: string, origin: string) => {
|
2023-09-14 23:04:51 +01:00
|
|
|
const hash = encodeURIComponent(
|
|
|
|
|
btoa(
|
|
|
|
|
JSON.stringify({
|
2024-07-10 21:53:34 +01:00
|
|
|
id: _course.id,
|
2023-09-14 23:04:51 +01:00
|
|
|
name: _course.title,
|
|
|
|
|
description: _course.description,
|
|
|
|
|
orgSiteName
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
2023-12-05 08:31:26 +03:00
|
|
|
return `${origin}/invite/s/${hash}`;
|
2023-09-14 23:04:51 +01:00
|
|
|
};
|
2023-10-15 04:38:37 +00:00
|
|
|
|
2023-12-05 08:31:26 +03:00
|
|
|
const tagsToReplace: { [k: string]: string } = {
|
2023-10-21 07:44:57 +00:00
|
|
|
'&': '&',
|
|
|
|
|
'<': '<',
|
|
|
|
|
'>': '>'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function replaceHTMLTag(text: string) {
|
|
|
|
|
return text
|
|
|
|
|
.split('')
|
|
|
|
|
.map((char) => tagsToReplace[char] || char)
|
|
|
|
|
.join('');
|
|
|
|
|
}
|