diff --git a/platforms/pictique/src/lib/fragments/Group/Group.svelte b/platforms/pictique/src/lib/fragments/Group/Group.svelte new file mode 100644 index 00000000..d4967445 --- /dev/null +++ b/platforms/pictique/src/lib/fragments/Group/Group.svelte @@ -0,0 +1,53 @@ + + + + + diff --git a/platforms/pictique/src/lib/fragments/SettingsNavigationButton/SettingsNavigationButton.svelte b/platforms/pictique/src/lib/fragments/SettingsNavigationButton/SettingsNavigationButton.svelte index 05617d8b..1461331e 100644 --- a/platforms/pictique/src/lib/fragments/SettingsNavigationButton/SettingsNavigationButton.svelte +++ b/platforms/pictique/src/lib/fragments/SettingsNavigationButton/SettingsNavigationButton.svelte @@ -38,7 +38,7 @@ diff --git a/platforms/pictique/src/lib/fragments/index.ts b/platforms/pictique/src/lib/fragments/index.ts index abe4ed0e..ad355640 100644 --- a/platforms/pictique/src/lib/fragments/index.ts +++ b/platforms/pictique/src/lib/fragments/index.ts @@ -17,3 +17,4 @@ export { default as Comment } from './Comment/Comment.svelte'; export { default as SettingsDeleteButton } from './SettingsDeleteButton/SettingsDeleteButton.svelte'; export { default as UserRequest } from './UserRequest/UserRequest.svelte'; export { default as UploadedPostView } from './UploadedPostView/UploadedPostView.svelte'; +export { default as Group } from './Group/Group.svelte'; diff --git a/platforms/pictique/src/lib/store/store.svelte.ts b/platforms/pictique/src/lib/store/store.svelte.ts index 1a090e49..f2c1e026 100644 --- a/platforms/pictique/src/lib/store/store.svelte.ts +++ b/platforms/pictique/src/lib/store/store.svelte.ts @@ -23,4 +23,3 @@ export const uploadedImages: { value: Image[] | null } = $state({ export const audience: { value: string } = $state({ value: 'Everyone' }); - diff --git a/platforms/pictique/src/lib/stores/posts.ts b/platforms/pictique/src/lib/stores/posts.ts index bb653d14..a9fbfc71 100644 --- a/platforms/pictique/src/lib/stores/posts.ts +++ b/platforms/pictique/src/lib/stores/posts.ts @@ -3,28 +3,28 @@ import { apiClient } from '$lib/utils/axios'; import { goto } from '$app/navigation'; export interface Post { - id: string; - text: string; - images: string[]; - author: { - id: string; - handle: string; - name: string; - avatarUrl: string; - }; - createdAt: string; - likedBy: string[]; - comments: { - id: string; - text: string; - author: { - id: string; - handle: string; - name: string; - avatarUrl: string; - }; - createdAt: string; - }[]; + id: string; + text: string; + images: string[]; + author: { + id: string; + handle: string; + name: string; + avatarUrl: string; + }; + createdAt: string; + likedBy: string[]; + comments: { + id: string; + text: string; + author: { + id: string; + handle: string; + name: string; + avatarUrl: string; + }; + createdAt: string; + }[]; } export const posts = writable([]); @@ -36,41 +36,41 @@ export const openCreatePostModal = () => isCreatePostModalOpen.set(true); export const closeCreatePostModal = () => isCreatePostModalOpen.set(false); export const fetchFeed = async (page = 1, limit = 10_000) => { - try { - isLoading.set(true); - error.set(null); - const response = await apiClient.get(`/api/posts/feed?page=${page}&limit=${limit}`); - posts.set(response.data); - } catch (err) { - error.set(err instanceof Error ? err.message : 'Failed to fetch feed'); - } finally { - isLoading.set(false); - } + try { + isLoading.set(true); + error.set(null); + const response = await apiClient.get(`/api/posts/feed?page=${page}&limit=${limit}`); + posts.set(response.data); + } catch (err) { + error.set(err instanceof Error ? err.message : 'Failed to fetch feed'); + } finally { + isLoading.set(false); + } }; export const createPost = async (text: string, images: string[]) => { - try { - isLoading.set(true); - error.set(null); - const response = await apiClient.post('/api/posts', { - text, - images: images.map((img) => img) - }); - await fetchFeed(1); - return response.data; - } catch (err) { - error.set(err instanceof Error ? err.message : 'Failed to create post'); - throw err; - } finally { - isLoading.set(false); - } + try { + isLoading.set(true); + error.set(null); + const response = await apiClient.post('/api/posts', { + text, + images: images.map((img) => img) + }); + await fetchFeed(1); + return response.data; + } catch (err) { + error.set(err instanceof Error ? err.message : 'Failed to create post'); + throw err; + } finally { + isLoading.set(false); + } }; export const toggleLike = async (postId: string) => { - try { - const response = await apiClient.post(`/api/posts/${postId}/like`); - return response.data; - } catch (err) { - throw new Error(err instanceof Error ? err.message : 'Failed to toggle like'); - } + try { + const response = await apiClient.post(`/api/posts/${postId}/like`); + return response.data; + } catch (err) { + throw new Error(err instanceof Error ? err.message : 'Failed to toggle like'); + } }; diff --git a/platforms/pictique/src/lib/types.ts b/platforms/pictique/src/lib/types.ts index b21b4334..153522a1 100644 --- a/platforms/pictique/src/lib/types.ts +++ b/platforms/pictique/src/lib/types.ts @@ -1,49 +1,55 @@ -import type { SVGAttributes } from "svelte/elements"; +import type { SVGAttributes } from 'svelte/elements'; export interface ISvgProps extends SVGAttributes { - size?: number | string; - color?: string; + size?: number | string; + color?: string; } export type CommentType = { - commentId: string; - name: string; - userImgSrc: string; - comment: string; - isUpVoted: boolean; - isDownVoted: boolean; - upVotes: number; - time: string; - replies: CommentType[]; + commentId: string; + name: string; + userImgSrc: string; + comment: string; + isUpVoted: boolean; + isDownVoted: boolean; + upVotes: number; + time: string; + replies: CommentType[]; }; export type PostData = { createdAt: string | number | Date; - id: string; - avatar: string; - userId: string; - username: string; - imgUris: string[]; - caption: string; - time: string; - count: { - likes: number; - comments: number; - }; + id: string; + avatar: string; + userId: string; + username: string; + imgUris: string[]; + caption: string; + time: string; + count: { + likes: number; + comments: number; + }; }; export type userProfile = { - userId: string; - username: string; - avatarUrl: string; - totalPosts: number; - followers: number; - following: number; - userBio: string; - posts: PostData[]; + userId: string; + username: string; + avatarUrl: string; + totalPosts: number; + followers: number; + following: number; + userBio: string; + posts: PostData[]; }; export type Image = { - url: string; - alt: string; + url: string; + alt: string; }; + +export type GroupInfo = { + id: string; + name: string; + avatar: string; +}; \ No newline at end of file diff --git a/platforms/pictique/src/routes/(protected)/group/[id]/+page.svelte b/platforms/pictique/src/routes/(protected)/group/[id]/+page.svelte new file mode 100644 index 00000000..cabebf45 --- /dev/null +++ b/platforms/pictique/src/routes/(protected)/group/[id]/+page.svelte @@ -0,0 +1,213 @@ + + +
+
+ +
+

{group.name}

+

{group.description}

+
+
+
+ + +
+
+ +
+
+ {#each messages as msg (msg.id)} + + {/each} +
+ + +
+ + (openEditDialog = false)} + onclose={() => (openEditDialog = false)} + class="w-[90vw] md:max-w-[30vw] z-50 absolute start-[50%] top-[50%] translate-x-[-50%] translate-y-[-50%] p-4 border border-gray-400 rounded-3xl bg-white shadow-xl" +> +
+
+ Group Avatar + {#if canEdit} + { + const files = (e.target as HTMLInputElement).files; + if (files && files[0]) { + groupImageFiles = files; + } + }} + /> + + {/if} +
+ +
+ + {#if canEdit} + + {:else} +

{group.name}

+ {/if} +
+ +
+ + {#if canEdit} + +