Add topic activity page

This commit is contained in:
Steven Nguyen
2023-12-19 17:58:30 -08:00
parent 842da80e4b
commit fee8e9cbed
3 changed files with 47 additions and 11 deletions
@@ -0,0 +1,8 @@
<script lang="ts">
import type { PageData } from './$types';
import { Activity } from '$lib/layout';
export let data: PageData;
</script>
<Activity {...data} />
@@ -0,0 +1,34 @@
import { Query, type Models } from '@appwrite.io/console';
import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
const payload = {
queries: [Query.limit(limit), Query.offset(offset)]
};
// TODO: remove when the API is ready with data
// This allows us to mock w/ data and when search returns 0 results
const logs: Models.LogList = await sdk.forProject.client.call(
'GET',
new URL(`${sdk.forProject.client.config.endpoint}/messaging/topics/${params.topic}/logs`),
{
'X-Appwrite-Project': sdk.forProject.client.config.project,
'content-type': 'application/json',
'X-Appwrite-Mode': 'admin'
},
payload
);
return {
offset,
limit,
logs
};
};
@@ -18,18 +18,12 @@
href: `${path}/subscribers`,
title: 'Subscribers',
event: 'subscribers'
},
{
href: `${path}/activity`,
title: 'Activity',
event: 'activity'
}
// {
// href: `${path}/sessions`,
// title: 'Sessions',
// event: 'sessions'
// },
// {
// href: `${path}/activity`,
// title: 'Activity',
// event: 'activity',
// hasChildren: true
// }
];
</script>