2024-02-28 03:00:31 +01:00
|
|
|
<script lang="ts">
|
2025-01-04 05:55:14 +01:00
|
|
|
import { goto } from '$app/navigation';
|
2026-03-18 23:39:12 +01:00
|
|
|
import { resolve } from '$app/paths';
|
2025-12-22 02:36:48 +01:00
|
|
|
import { NewsFeedPage } from '$features/course/pages';
|
|
|
|
|
import { Button } from '@cio/ui/base/button';
|
|
|
|
|
import * as Page from '@cio/ui/base/page';
|
2026-03-18 23:39:12 +01:00
|
|
|
import { RefreshPageData, RoleBasedSecurity } from '$features/ui';
|
2024-05-19 18:55:28 +01:00
|
|
|
import { currentOrg } from '$lib/utils/store/org';
|
2025-12-22 02:36:48 +01:00
|
|
|
import { t } from '$lib/utils/functions/translations';
|
|
|
|
|
import type { AccountOrg } from '$features/app/types';
|
2026-03-09 11:18:22 +01:00
|
|
|
import { newsfeedApi } from '$features/course/api';
|
2024-04-19 05:45:48 +01:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
let { data = $bindable() } = $props();
|
2024-02-28 03:00:31 +01:00
|
|
|
|
2025-12-02 09:54:38 +01:00
|
|
|
function getPageRoles(org: AccountOrg) {
|
2024-05-21 00:14:47 +01:00
|
|
|
const roles: number[] = [1, 2];
|
2024-05-19 18:55:28 +01:00
|
|
|
|
|
|
|
|
if (org.customization.course.newsfeed) {
|
2024-05-25 05:50:14 +01:00
|
|
|
roles.push(3);
|
2024-05-19 18:55:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return roles;
|
|
|
|
|
}
|
2023-08-02 19:35:27 +01:00
|
|
|
</script>
|
|
|
|
|
|
2026-03-09 11:18:22 +01:00
|
|
|
<RoleBasedSecurity
|
|
|
|
|
allowedRoles={getPageRoles($currentOrg)}
|
|
|
|
|
onDenied={() => {
|
2026-03-18 23:39:12 +01:00
|
|
|
goto(resolve(`/courses/${data.courseId}/lessons?next=true`, {}));
|
2026-03-09 11:18:22 +01:00
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Page.Root class="mx-auto flex w-[90%] px-4 md:max-w-2xl lg:max-w-3xl">
|
2025-12-22 02:36:48 +01:00
|
|
|
<Page.Header>
|
|
|
|
|
<Page.HeaderContent>
|
|
|
|
|
<Page.Title>
|
2026-03-09 11:18:22 +01:00
|
|
|
{$t('course.navItem.news_feed.heading')}
|
2025-12-22 02:36:48 +01:00
|
|
|
</Page.Title>
|
|
|
|
|
</Page.HeaderContent>
|
|
|
|
|
<Page.Action>
|
2026-03-18 23:39:12 +01:00
|
|
|
<div class="flex items-center gap-2">
|
|
|
|
|
<Button onclick={() => newsfeedApi.openNewFeedModal()}>
|
|
|
|
|
{$t('course.navItem.news_feed.heading_button.title')}
|
|
|
|
|
</Button>
|
|
|
|
|
<RefreshPageData onRefresh={() => newsfeedApi.list(data.courseId)} />
|
|
|
|
|
</div>
|
2025-12-22 02:36:48 +01:00
|
|
|
</Page.Action>
|
|
|
|
|
</Page.Header>
|
|
|
|
|
|
|
|
|
|
<Page.Body>
|
|
|
|
|
{#snippet child()}
|
|
|
|
|
<NewsFeedPage courseId={data.courseId} />
|
2025-11-01 15:49:29 +01:00
|
|
|
{/snippet}
|
2025-12-22 02:36:48 +01:00
|
|
|
</Page.Body>
|
2026-03-09 11:18:22 +01:00
|
|
|
</Page.Root>
|
|
|
|
|
</RoleBasedSecurity>
|