diff --git a/src/lib/components/Org/Community/Loader.svelte b/src/lib/components/Org/Community/Loader.svelte new file mode 100644 index 00000000..d57ab322 --- /dev/null +++ b/src/lib/components/Org/Community/Loader.svelte @@ -0,0 +1,25 @@ + + +
+
+ + +
+ +
+ +
+ +
+ + +
+ +
+ +
+
diff --git a/src/lib/components/Org/Community/index.svelte b/src/lib/components/Org/Community/index.svelte index f1e1f221..1b423954 100644 --- a/src/lib/components/Org/Community/index.svelte +++ b/src/lib/components/Org/Community/index.svelte @@ -3,6 +3,7 @@ import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; import AddCommentIcon from 'carbon-icons-svelte/lib/AddComment.svelte'; + import CommunityLoader from './Loader.svelte'; import Vote from '$lib/components/Vote/index.svelte'; import Box from '$lib/components/Box/index.svelte'; import CoursesEmptyIcon from '$lib/components/Icons/CoursesEmptyIcon.svelte'; @@ -12,12 +13,14 @@ export let isLMS = false; + let isLoading = false; let discussions = []; dayjs.extend(relativeTime); async function fetchCommunityQuestions(orgId) { if (!orgId) return; + isLoading = true; const { data, error } = await supabase .from('community_question') @@ -37,6 +40,7 @@ .eq('organization_id', orgId); console.log('data', data); console.log('error', error); + isLoading = false; if (error) { console.error('Error loading community', error); @@ -60,35 +64,42 @@
- {#each discussions as discussion} -
- -
-

- - {discussion.title} - -

- - {discussion.author} asked {discussion.createdAt} - -
- -
- - {discussion.comments} -
-
+ {#if isLoading} + + + + {:else} - - -

No Questions asked

-

Ask a question to the community

-
- {/each} + {#each discussions as discussion} +
+ +
+

+ + {discussion.title} + +

+ + {discussion.author} asked {discussion.createdAt} + +
+ +
+ + {discussion.comments} +
+
+ {:else} + + +

No Questions asked

+

Ask a question to the community

+
+ {/each} + {/if}