Fix bug of adding tutor to lesson
This commit is contained in:
@@ -17,29 +17,6 @@ export const lesson = writable({
|
||||
});
|
||||
export const isLessonDirty = writable(false);
|
||||
|
||||
export const tutors = writable([
|
||||
{
|
||||
id: 1,
|
||||
text: 'Sergey Semko',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
text: 'Jonathan Nelson',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
text: 'Sasha Pokidin',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
text: 'Natasha Rudenko',
|
||||
},
|
||||
{
|
||||
id: 6,
|
||||
text: 'Yulia Marushko',
|
||||
},
|
||||
]);
|
||||
|
||||
export function handleAddLesson() {
|
||||
lessons.update((_lessons) => {
|
||||
return [
|
||||
@@ -47,7 +24,7 @@ export function handleAddLesson() {
|
||||
{
|
||||
id: null,
|
||||
title: 'Untitled lesson',
|
||||
profile: undefined,
|
||||
// profile: undefined,
|
||||
call_url: undefined,
|
||||
lesson_at: new Date(),
|
||||
is_complete: false,
|
||||
|
||||
@@ -179,6 +179,7 @@
|
||||
position: sticky;
|
||||
top: 0;
|
||||
border-right: 1px solid var(--border-color);
|
||||
background-color: rgb(250, 251, 252);
|
||||
|
||||
&.hide {
|
||||
min-width: 0px;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
addGroupMember,
|
||||
fetchGroup,
|
||||
} from '../../../../utils/services/courses';
|
||||
import { invitationModal } from './store';
|
||||
import { invitationModal, resetForm } from './store';
|
||||
import { validateForm } from '../../../Courses/functions';
|
||||
import { course, setCourseData } from '../../../Course/store';
|
||||
|
||||
@@ -56,16 +56,16 @@
|
||||
false
|
||||
);
|
||||
|
||||
$invitationModal.open = false;
|
||||
resetForm();
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
onClose={() => ($invitationModal.open = false)}
|
||||
onClose={resetForm}
|
||||
bind:open={$invitationModal.open}
|
||||
width="w-2/5"
|
||||
modalHeading="Create a Course"
|
||||
modalHeading="Invite people"
|
||||
>
|
||||
<form on:submit|preventDefault={addPerson}>
|
||||
<TextArea
|
||||
|
||||
@@ -5,3 +5,10 @@ export const invitationModal = writable({
|
||||
tutors: '',
|
||||
students: '',
|
||||
});
|
||||
|
||||
export const resetForm = () =>
|
||||
invitationModal.update(() => ({
|
||||
open: false,
|
||||
tutors: '',
|
||||
students: '',
|
||||
}));
|
||||
|
||||
@@ -28,24 +28,27 @@ export const group = writable({
|
||||
|
||||
export async function setCourseData(data, setLesson = true) {
|
||||
if (!data || !(Object.values(data) && Object.values(data).length)) return;
|
||||
console.log(`setCourseData`, data);
|
||||
// const tutorsById = {};
|
||||
|
||||
if (data.group) {
|
||||
const groupData = Object.assign(data.group, { tutors: [], students: [] });
|
||||
const groupData = Object.assign(data.group, {
|
||||
tutors: [],
|
||||
students: [],
|
||||
people: [],
|
||||
});
|
||||
|
||||
if (Array.isArray(groupData.members)) {
|
||||
for (const member of groupData.members) {
|
||||
if (member.role_id === ROLE.STUDENT) {
|
||||
groupData.students.push(member);
|
||||
// } else if (member.profile) {
|
||||
} else {
|
||||
groupData.tutors.push({
|
||||
...member,
|
||||
...member.profile,
|
||||
id: member.id,
|
||||
});
|
||||
} else if (member.profile) {
|
||||
groupData.tutors.push(member.profile);
|
||||
|
||||
// tutorsById[member.profile.id] = member.profile;
|
||||
}
|
||||
}
|
||||
|
||||
groupData.people = groupData.members;
|
||||
}
|
||||
|
||||
delete groupData.members;
|
||||
@@ -56,7 +59,10 @@ export async function setCourseData(data, setLesson = true) {
|
||||
const orderedLessons = (data.lessons || []).sort(
|
||||
(a, b) => new Date(a.created_at) - new Date(b.created_at)
|
||||
);
|
||||
// .map();
|
||||
// .map((lesson) => ({
|
||||
// ...lesson,
|
||||
// profile: lesson.profile && tutorsById[lesson.profile.id],
|
||||
// }));
|
||||
lessons.set(orderedLessons);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user