diff --git a/apps/dashboard/src/lib/components/Course/components/Settings/DragAndDrop.svelte b/apps/dashboard/src/lib/components/Course/components/Settings/DragAndDrop.svelte
index 454de59c..48661188 100644
--- a/apps/dashboard/src/lib/components/Course/components/Settings/DragAndDrop.svelte
+++ b/apps/dashboard/src/lib/components/Course/components/Settings/DragAndDrop.svelte
@@ -4,6 +4,9 @@
import { dndzone } from 'svelte-dnd-action';
import Draggable from 'carbon-icons-svelte/lib/Draggable.svelte';
import { t } from '$lib/utils/functions/translations';
+ import { createEventDispatcher } from 'svelte';
+
+ const dispatch = createEventDispatcher();
const flipDurationMs = 300;
@@ -13,6 +16,8 @@
function handleDndFinalize(e) {
$settings.tabs = e.detail.items;
+
+ dispatch('change');
}
diff --git a/apps/dashboard/src/lib/components/Course/components/Settings/index.svelte b/apps/dashboard/src/lib/components/Course/components/Settings/index.svelte
index cfd6c265..239c9f56 100644
--- a/apps/dashboard/src/lib/components/Course/components/Settings/index.svelte
+++ b/apps/dashboard/src/lib/components/Course/components/Settings/index.svelte
@@ -35,6 +35,7 @@
import IconButton from '$lib/components/IconButton/index.svelte';
import generateSlug from '$lib/utils/functions/generateSlug';
import { t } from '$lib/utils/functions/translations';
+ import DeleteModal from '$lib/components/Modal/DeleteModal.svelte';
import { COURSE_TYPE } from '$lib/utils/types';
let isSaving = false;
@@ -43,9 +44,10 @@
let errors: {
title: string | undefined;
description: string | undefined;
- } = { title: undefined, description: undefined };
+ };
let avatar: string | undefined;
let hasUnsavedChanges = false;
+ let openDeleteModal = false;
function widgetControl() {
$handleOpenWidget.open = !$handleOpenWidget.open;
@@ -71,6 +73,7 @@
slideUrl: lesson.slide_url || '',
video: lesson.videos || ''
}));
+
const response = await fetch(env.PUBLIC_SERVER_URL + '/downloadCourse', {
method: 'POST',
headers: {
@@ -109,19 +112,21 @@
};
const deleteBannerImage = () => {
- $course.logo = '';
+ $settings.logo = '';
+ hasUnsavedChanges = true;
};
async function handleDeleteCourse() {
isDeleting = true;
+
try {
await deleteCourse($course.id);
- isDeleting = false;
goto($currentOrgPath + '/courses');
} catch (error) {
snackbar.error('snackbar.course_settings.error.went_wrong');
- isDeleting = false;
}
+
+ isDeleting = false;
}
const handleSave = async () => {
@@ -172,12 +177,11 @@
const generateNewCourseLink = () => {
$course.slug = generateSlug($course.title);
+ hasUnsavedChanges = true;
};
- let hasInitialized = false;
-
async function setDefault(course: Course) {
- if (!course || !Object.keys(course).length || hasInitialized) return;
+ if (!course || !Object.keys(course).length) return;
settings.set({
course_title: course.title,
@@ -190,14 +194,6 @@
is_published: !!course.is_published,
allow_new_students: course.metadata.allowNewStudent
});
-
- settings.subscribe((s) => {
- if (!hasInitialized) return;
-
- hasUnsavedChanges = true;
- });
-
- hasInitialized = true;
}
$: setDefault($course);
@@ -206,6 +202,8 @@