CLASSROOMIO-T-75:Wrote the function to save the updated certificate theme,description and accessiblity

This commit is contained in:
emmanuel
2023-07-28 11:28:49 +01:00
parent 42530f5f6a
commit 3706509163
2 changed files with 20 additions and 16 deletions
@@ -5,6 +5,7 @@
Toggle, Toggle,
} from 'carbon-components-svelte'; } from 'carbon-components-svelte';
import { goto } from '@sapper/app'; import { goto } from '@sapper/app';
import { updateCourse } from '../../../../utils/services/courses';
import PrimaryButton from '../../../PrimaryButton/index.svelte'; import PrimaryButton from '../../../PrimaryButton/index.svelte';
import TextArea from '../../../Form/TextArea.svelte'; import TextArea from '../../../Form/TextArea.svelte';
import Professional from './certificates/Professional.svelte'; import Professional from './certificates/Professional.svelte';
@@ -13,24 +14,26 @@
import { currentOrg } from '../../../../utils/store/org'; import { currentOrg } from '../../../../utils/store/org';
const studentNamePlaceholder = 'Name of student'; const studentNamePlaceholder = 'Name of student';
const themes = ['professional', 'plain']; const themes = ['professional', 'plain'];
let isSaving = false; let isSaving = false;
let Saved = false;
let errors = {};
const saveCertificate = () => { const saveCertificate = async () => {
// set isSaving to true isSaving = true;
// Validation - make sure description isn't empty if (!$course.description) {
/** errors.description = 'Description cannot be empty';
* Update course description, is_certificate_downloadable and certificate_theme (like in src/components/Course/components/Settings/index.svelte) isSaving = false;
* return;
* await updateCourse($course.id, undefined, { }
await updateCourse($course.id, undefined, {
description: $course.description, description: $course.description,
is_certificate_downloadable: $course.is_certificate_downloadable, is_certificate_downloadable: $course.is_certificate_downloadable,
certificate_theme: $course.certificate_theme certificate_theme: $course.certificate_theme,
}); });
* */ Saved = true;
// set isSaving to false isSaving = false;
}; };
</script> </script>
@@ -82,6 +85,7 @@
placeholder="a little description about the course" placeholder="a little description about the course"
bgColor="bg-gray-100" bgColor="bg-gray-100"
bind:value={$course.description} bind:value={$course.description}
errorMessage={errors.description}
/> />
</span> </span>
<Toggle <Toggle
@@ -109,7 +113,7 @@
</div> </div>
<div class="h-1/5"> <div class="h-1/5">
<PrimaryButton <PrimaryButton
label="Save Changes" label={Saved == true ? 'Saved' : 'Save Changes'}
className="rounded-md" className="rounded-md"
onClick={saveCertificate} onClick={saveCertificate}
isLoading={isSaving} isLoading={isSaving}
@@ -31,7 +31,7 @@
</div> </div>
<div class="mb-2"> <div class="mb-2">
<p class="text-xs text-black font-medium"> <p class="text-xs text-black font-medium">
has successfully completed a courses in has successfully completed the course
</p> </p>
<div> <div>
<p <p