CLASSROOMIO-T-75:Wrote the function to save the updated certificate theme,description and accessiblity
This commit is contained in:
@@ -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, {
|
}
|
||||||
description: $course.description,
|
await updateCourse($course.id, undefined, {
|
||||||
is_certificate_downloadable: $course.is_certificate_downloadable,
|
description: $course.description,
|
||||||
certificate_theme: $course.certificate_theme
|
is_certificate_downloadable: $course.is_certificate_downloadable,
|
||||||
});
|
certificate_theme: $course.certificate_theme,
|
||||||
* */
|
});
|
||||||
// set isSaving to false
|
Saved = true;
|
||||||
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user