Skip to content

Commit 8ad350b

Browse files
committed
chore: fix checks of pictique.
1 parent b73f510 commit 8ad350b

File tree

3 files changed

+105
-78
lines changed

3 files changed

+105
-78
lines changed
Lines changed: 87 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,108 @@
1-
import type { SVGAttributes } from 'svelte/elements';
1+
import type { SVGAttributes } from "svelte/elements";
22

33
export interface ISvgProps extends SVGAttributes<SVGElement> {
4-
size?: number | string;
5-
color?: string;
4+
size?: number | string;
5+
color?: string;
66
}
77

88
export type CommentType = {
9-
commentId: string;
10-
name: string;
11-
userImgSrc: string;
12-
comment: string;
13-
isUpVoted: boolean;
14-
isDownVoted: boolean;
15-
upVotes: number;
16-
time: string;
17-
replies: CommentType[];
9+
commentId: string;
10+
name: string;
11+
userImgSrc: string;
12+
comment: string;
13+
isUpVoted: boolean;
14+
isDownVoted: boolean;
15+
upVotes: number;
16+
time: string;
17+
replies: CommentType[];
1818
};
1919

2020
export type PostData = {
21-
createdAt: string | number | Date;
22-
id: string;
23-
avatar: string;
24-
userId: string;
25-
handle: string;
26-
imgUris: string[];
27-
caption: string;
28-
time: string;
29-
count: {
30-
likes: number;
31-
comments: number;
32-
};
21+
createdAt: string | number | Date;
22+
id: string;
23+
avatar: string;
24+
userId: string;
25+
handle: string;
26+
imgUris: string[];
27+
caption: string;
28+
time: string;
29+
count: {
30+
likes: number;
31+
comments: number;
32+
};
3333
};
3434

3535
export interface Post {
36-
id: string;
37-
text: string;
38-
images: string[];
39-
author: {
40-
id: string;
41-
handle: string;
42-
name: string;
43-
avatarUrl: string;
44-
};
45-
createdAt: string;
46-
likedBy: userProfile[];
47-
comments: {
48-
id: string;
49-
text: string;
50-
author: {
51-
id: string;
52-
handle: string;
53-
name: string;
54-
avatarUrl: string;
55-
};
56-
createdAt: string;
57-
}[];
36+
id: string;
37+
text: string;
38+
images: string[];
39+
author: {
40+
id: string;
41+
handle: string;
42+
name: string;
43+
avatarUrl: string;
44+
};
45+
createdAt: string;
46+
likedBy: userProfile[];
47+
comments: {
48+
id: string;
49+
text: string;
50+
author: {
51+
id: string;
52+
handle: string;
53+
name: string;
54+
avatarUrl: string;
55+
};
56+
createdAt: string;
57+
}[];
5858
}
5959

6060
export type userProfile = {
61-
userId: string;
62-
username: string;
63-
avatarUrl: string;
64-
totalPosts: number;
65-
followers: number;
66-
following: number;
67-
userBio: string;
68-
posts: PostData[];
61+
id: string;
62+
handle: string;
63+
name: string;
64+
description: string;
65+
avatarUrl: string;
66+
totalPosts: number;
67+
followers: number;
68+
following: number;
69+
posts: PostData[];
6970
};
7071

7172
export type Image = {
72-
url: string;
73-
alt: string;
73+
url: string;
74+
alt: string;
7475
};
7576

7677
export type GroupInfo = {
77-
id: string;
78-
name: string;
79-
avatar: string;
78+
id: string;
79+
name: string;
80+
avatar: string;
81+
};
82+
83+
export type Chat = {
84+
id: string;
85+
avatar: string;
86+
handle: string;
87+
unread: boolean;
88+
text: string;
89+
participants: {
90+
id: string;
91+
name?: string;
92+
handle?: string;
93+
ename?: string;
94+
avatarUrl: string;
95+
}[];
96+
latestMessage: {
97+
text: string;
98+
isRead: boolean;
99+
};
100+
};
101+
102+
export type MessageType = {
103+
id: string;
104+
avatar: string;
105+
handle: string;
106+
unread: boolean;
107+
text: string;
80108
};

platforms/pictique/src/routes/(protected)/group/[id]/+page.svelte

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script lang="ts">
2-
import { onMount } from 'svelte';
3-
import { ChatMessage, MessageInput } from '$lib/fragments';
4-
import { Avatar, Button, Input, Label } from '$lib/ui';
52
import { goto } from '$app/navigation';
63
import { page } from '$app/state';
4+
import { ChatMessage, MessageInput } from '$lib/fragments';
75
import Settings from '$lib/icons/Settings.svelte';
6+
import { Avatar, Button, Input, Label } from '$lib/ui';
87
import { clickOutside } from '$lib/utils';
98
import { Pen01FreeIcons } from '@hugeicons/core-free-icons';
109
import { HugeiconsIcon } from '@hugeicons/svelte';
10+
import { onMount } from 'svelte';
1111
1212
let messagesContainer: HTMLDivElement;
1313
let messageValue = $state('');
@@ -63,8 +63,8 @@
6363
setTimeout(scrollToBottom, 0);
6464
});
6565
66-
function handleSend() {
67-
if (!messageValue.trim()) return;
66+
async function handleSend() {
67+
if (!messageValue.trim()) return Promise.resolve();
6868
messages = [
6969
...messages,
7070
{
@@ -152,7 +152,7 @@
152152
</div>
153153

154154
<MessageInput
155-
class="sticky start-0 bottom-[-15px] w-full"
155+
class="sticky bottom-[-15px] start-0 w-full"
156156
variant="dm"
157157
src={group.avatar}
158158
bind:value={messageValue}
@@ -188,7 +188,7 @@
188188
/>
189189
<label
190190
for="group-avatar-input"
191-
class="bg-brand-burnt-orange border-brand-burnt-orange absolute right-0 bottom-0 cursor-pointer rounded-full border p-1 shadow"
191+
class="bg-brand-burnt-orange border-brand-burnt-orange absolute bottom-0 right-0 cursor-pointer rounded-full border p-1 shadow"
192192
>
193193
<HugeiconsIcon icon={Pen01FreeIcons} color="white" />
194194
</label>
@@ -212,7 +212,7 @@
212212
rows="2"
213213
maxlength="260"
214214
placeholder="Edit group description"
215-
class="bg-grey text-black-800 font-geist placeholder:text-black-600 invalid:border-red invalid:text-red focus:invalid:text-black-800 w-full rounded-4xl border border-transparent px-6 py-3.5 text-[15px] font-normal outline-0 focus:invalid:border-transparent"
215+
class="bg-grey text-black-800 font-geist placeholder:text-black-600 invalid:border-red invalid:text-red focus:invalid:text-black-800 rounded-4xl w-full border border-transparent px-6 py-3.5 text-[15px] font-normal outline-0 focus:invalid:border-transparent"
216216
bind:value={groupDescription}
217217
/>
218218
{:else}

platforms/pictique/src/routes/(protected)/messages/+page.svelte

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
<script lang="ts">
22
import { goto } from '$app/navigation';
3-
import { onMount } from 'svelte';
43
import { Message } from '$lib/fragments';
54
import Group from '$lib/fragments/Group/Group.svelte';
6-
import { Button, Avatar, Input } from '$lib/ui';
5+
import { isSearching, searchError, searchResults, searchUsers } from '$lib/stores/users';
6+
import type { Chat, GroupInfo, MessageType } from '$lib/types';
7+
import { Avatar, Button, Input } from '$lib/ui';
78
import { clickOutside } from '$lib/utils';
8-
import { heading } from '../../store';
99
import { apiClient } from '$lib/utils/axios';
10+
import { onMount } from 'svelte';
11+
import { heading } from '../../store';
1012
11-
import { searchUsers, searchResults, isSearching, searchError } from '$lib/stores/users';
12-
import type { GroupInfo } from '$lib/types';
13-
14-
let messages = $state([]);
13+
let messages = $state<MessageType[]>([]);
1514
let groups: GroupInfo[] = $state([]);
16-
let allMembers = $state([]);
15+
let allMembers = $state<Record<string, string>[]>([]);
1716
let selectedMembers = $state<string[]>([]);
1817
let currentUserId = '';
1918
let openNewChatModal = $state(false);
2019
let searchValue = $state('');
2120
let debounceTimer: NodeJS.Timeout;
2221
2322
async function loadMessages() {
24-
const { data } = await apiClient.get('/api/chats');
23+
const { data } = await apiClient.get<{ chats: Chat[] }>('/api/chats');
2524
const { data: userData } = await apiClient.get('/api/users');
2625
currentUserId = userData.id;
2726
@@ -67,7 +66,7 @@
6766
6867
try {
6968
if (selectedMembers.length === 1) {
70-
await apiClient.post(`/api/chats/`, {
69+
await apiClient.post('/api/chats/', {
7170
name: allMembers.find((m) => m.id === selectedMembers[0])?.name ?? 'New Chat',
7271
participantIds: [selectedMembers[0]]
7372
});
@@ -125,7 +124,7 @@
125124
{/if}
126125

127126
{#if groups.length > 0}
128-
<h3 class="text-md mt-6 mb-2 font-semibold text-gray-700">Groups</h3>
127+
<h3 class="text-md mb-2 mt-6 font-semibold text-gray-700">Groups</h3>
129128
{#each groups as group}
130129
<Group
131130
name={group.name || 'New Group'}

0 commit comments

Comments
 (0)