diff --git a/src/components/Course/components/Ceritficate/Design.svelte b/src/components/Course/components/Ceritficate/Design.svelte index ae5b7723..ba2d8930 100644 --- a/src/components/Course/components/Ceritficate/Design.svelte +++ b/src/components/Course/components/Ceritficate/Design.svelte @@ -5,6 +5,7 @@ Toggle, } from 'carbon-components-svelte'; import { goto } from '@sapper/app'; + import { updateCourse } from '../../../../utils/services/courses'; import PrimaryButton from '../../../PrimaryButton/index.svelte'; import TextArea from '../../../Form/TextArea.svelte'; import Professional from './certificates/Professional.svelte'; @@ -13,24 +14,26 @@ import { currentOrg } from '../../../../utils/store/org'; const studentNamePlaceholder = 'Name of student'; - const themes = ['professional', 'plain']; let isSaving = false; + let Saved = false; + let errors = {}; - const saveCertificate = () => { - // set isSaving to true - // Validation - make sure description isn't empty - /** - * Update course description, is_certificate_downloadable and certificate_theme (like in src/components/Course/components/Settings/index.svelte) - * - * await updateCourse($course.id, undefined, { - description: $course.description, - is_certificate_downloadable: $course.is_certificate_downloadable, - certificate_theme: $course.certificate_theme - }); - * */ - // set isSaving to false + const saveCertificate = async () => { + isSaving = true; + if (!$course.description) { + errors.description = 'Description cannot be empty'; + isSaving = false; + return; + } + await updateCourse($course.id, undefined, { + description: $course.description, + is_certificate_downloadable: $course.is_certificate_downloadable, + certificate_theme: $course.certificate_theme, + }); + Saved = true; + isSaving = false; }; @@ -82,6 +85,7 @@ placeholder="a little description about the course" bgColor="bg-gray-100" bind:value={$course.description} + errorMessage={errors.description} />
+ import { course } from '../../../store'; + import UnlockedCertificate from './UnlockedCertificate.svelte'; + import LockedCertificate from './LockedCertificate.svelte'; + + +
+ {#if $course.is_certificate_downloadable == true} + + {:else} + + {/if} +
diff --git a/src/components/Course/components/Ceritficate/StudentCertificate/LockedCertificate.svelte b/src/components/Course/components/Ceritficate/StudentCertificate/LockedCertificate.svelte new file mode 100644 index 00000000..768170a1 --- /dev/null +++ b/src/components/Course/components/Ceritficate/StudentCertificate/LockedCertificate.svelte @@ -0,0 +1,20 @@ + + +
+
+ Certificate +

Certificates not available

+

+ Your instructor needs to unlock your certificate.
If you need your certificate, + please contact your instructor. +

+
+
+ + diff --git a/src/components/Course/components/Ceritficate/StudentCertificate/UnlockedCertificate.svelte b/src/components/Course/components/Ceritficate/StudentCertificate/UnlockedCertificate.svelte new file mode 100644 index 00000000..8e67ad34 --- /dev/null +++ b/src/components/Course/components/Ceritficate/StudentCertificate/UnlockedCertificate.svelte @@ -0,0 +1,55 @@ + + +
+
+ Certificate +

Certificate is now available

+ +
+
+ + diff --git a/src/components/Course/components/Ceritficate/certificates/Plain.svelte b/src/components/Course/components/Ceritficate/certificates/Plain.svelte index 75627219..5c6b4998 100644 --- a/src/components/Course/components/Ceritficate/certificates/Plain.svelte +++ b/src/components/Course/components/Ceritficate/certificates/Plain.svelte @@ -31,7 +31,7 @@

- has successfully completed a courses in + has successfully completed the course

- + + + + + + +