diff --git a/rollup.config.js b/rollup.config.js index d0688f49..15e4d9e7 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -14,7 +14,7 @@ import pkg from './package.json'; const mode = process.env.NODE_ENV; const dev = mode === 'development'; -const sourcemap = dev ? 'inline' : false; +const sourcemap = dev ? false : 'inline'; const legacy = !!process.env.SAPPER_LEGACY_BUILD; const onwarn = (warning, onwarn) => { diff --git a/src/routes/_layout.svelte b/src/routes/_layout.svelte index 9629cc18..a5fe6f54 100644 --- a/src/routes/_layout.svelte +++ b/src/routes/_layout.svelte @@ -8,6 +8,7 @@ import { onMount } from 'svelte'; import { derived } from 'svelte/store'; import { stores, goto } from '@sapper/app'; + import * as Sentry from '@sentry/browser'; import { Firework } from 'svelte-loading-spinners'; import Tailwindcss from '../components/Tailwindcss.svelte'; import Navigation from '../components/Navigation/index.svelte'; @@ -72,6 +73,8 @@ profile.set(data[0]); + // Set user in sentry + Sentry.setUser($profile); // If user coming to login page, then if (path.includes('login') || path.includes('signup')) { goto('/profile/' + $profile.id); @@ -85,6 +88,9 @@ console.log(`profileData`, profileData); profile.set(profileData); + // Set user in sentry + Sentry.setUser($profile); + // If user coming to login page, then if (path.includes('login') || path.includes('signup')) { goto('/profile/' + $profile.id); @@ -105,8 +111,7 @@ const _isMvpUser = localStorage.getItem('mvp'); - console.log('mounting layout', isMvpUser, path, _isMvpUser); - if (isMvpUser || window.location.search.includes('mvp')) { + if (_isMvpUser || window.location.search.includes('mvp')) { localStorage.setItem('mvp', 'true'); allowUser = true; } else if (!_isMvpUser) { @@ -122,7 +127,7 @@ if (config.isDev) { handleAuthChange(event, session); } - + console.log(`event`, event); if (event === 'SIGNED_IN') { $user.fetchingUser = true; getProfile(); diff --git a/src/routes/courses/[id]/attendance.svelte b/src/routes/courses/[id]/attendance.svelte index d937caaf..c557e8e3 100644 --- a/src/routes/courses/[id]/attendance.svelte +++ b/src/routes/courses/[id]/attendance.svelte @@ -55,6 +55,57 @@ } } + function handleAttendanceChange(e, student, lesson) { + if (isStudent) return; + + const attendanceItem = $attendance[student.id] + ? $attendance[student.id][lesson.id] || {} + : {}; + + if (attendanceItem.id) { + $snackbarStore.open = true; + $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR; + $snackbarStore.message = + "Something isn't right. Please reload and take attendance again"; + console.error(`Attendance Id Missing`, courseId, student.id, lesson.id); + + return; + } + + const data = { + id: attendanceItem.id, + student_id: student.id, + is_present: e.target.checked, + lesson_id: lesson.id, + course_id: courseId, + }; + + takeAttendance(data).then((res) => { + if (res.error) { + console.error(`res.error`, res.error); + $snackbarStore.open = true; + $snackbarStore.severity = SNACKBAR_SEVERITY.ERROR; + $snackbarStore.message = "Something isn't right."; + } else { + console.log('res', JSON.stringify(res)); + const { id, is_present } = res.data[0]; + if ($attendance[student.id]) { + $attendance[student.id][lesson.id] = { + id, + is_present, + }; + } else { + $attendance[student.id] = { + [lesson.id]: { + id, + is_present, + }, + }; + } + } + }); + } + onMount(async () => { if ($course.id) { if (!Object.keys($attendance).length) { @@ -105,7 +156,7 @@
{student.profile.fullname}
{#if student.assigned_student_id} -#{student.assigned_student_id}
+#{student.assigned_student_id}
{/if}