diff --git a/packages/gui/src/components/EssentialWorkshops/EssentialWorkshops.svelte b/packages/gui/src/components/EssentialWorkshops/EssentialWorkshops.svelte index fc888e5..42679fb 100644 --- a/packages/gui/src/components/EssentialWorkshops/EssentialWorkshops.svelte +++ b/packages/gui/src/components/EssentialWorkshops/EssentialWorkshops.svelte @@ -1,9 +1,10 @@ - +{#if courses.length} + +{:else} +
+ +
+{/if} diff --git a/packages/gui/src/components/News/News.svelte b/packages/gui/src/components/News/News.svelte index 064026a..bbd4fb7 100644 --- a/packages/gui/src/components/News/News.svelte +++ b/packages/gui/src/components/News/News.svelte @@ -1,9 +1,10 @@ - +{#if news.length} + +{:else} +
+ +
+{/if} diff --git a/packages/gui/src/libs/api/tauri.ts b/packages/gui/src/libs/api/tauri.ts index 077517f..4b5a099 100644 --- a/packages/gui/src/libs/api/tauri.ts +++ b/packages/gui/src/libs/api/tauri.ts @@ -14,26 +14,21 @@ import { getClient } from '@tauri-apps/api/http'; // import { invoke } from '@tauri-apps/api'; import { Command } from '@tauri-apps/api/shell'; import { readDir, BaseDirectory } from '@tauri-apps/api/fs'; -import { Buffer } from 'buffer'; -import type { Package, Review } from '@tea/ui/types'; +import type { Package, Review, AirtablePost } from '@tea/ui/types'; import type { GUIPackage, Course } from '../types'; import * as mock from './mock'; import { PackageStates } from '../types'; -import { AirtablePost } from '../../../../ui/src/types'; - -const username = 'user'; -const password = 'password'; -const auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64'); const base = 'https://api.tea.xyz/v1'; -async function get(path: string) { +async function get(path: string, query?: { [key: string]: any }) { const client = await getClient(); const uri = join(base, path); const { data } = await client.get(uri.toString(), { headers: { - Authorization: auth - } + Authorization: 'public' // TODO: figure out why req w/o Authorization does not work + }, + query: query || {} }); return data; } @@ -149,8 +144,8 @@ export async function getTopPackages(): Promise { return packages; } -export async function getAllPosts(type: string): Promise { - // add filter here someday: type = news | course - const posts = await mock.getAllPosts(type); +export async function getAllPosts(tag: string): Promise { + // add filter here someday: tag = news | course + const posts = await get('posts', { tag }); return posts; } diff --git a/packages/ui/src/Posts/Posts.svelte b/packages/ui/src/Posts/Posts.svelte index cd1e7f0..62c1d3a 100644 --- a/packages/ui/src/Posts/Posts.svelte +++ b/packages/ui/src/Posts/Posts.svelte @@ -12,9 +12,9 @@
{article.title}
-
+

{article.title}

-

{article.short_description}

+

{article.short_description}

Read more ...