diff --git a/src/components/Views/Inbox.tsx b/src/components/Views/Inbox.tsx index 18095ecc..f339cc84 100644 --- a/src/components/Views/Inbox.tsx +++ b/src/components/Views/Inbox.tsx @@ -1,5 +1,5 @@ import { For, createSignal, Show, onMount, createEffect, createMemo } from 'solid-js' -import type { Author } from '../../graphql/types.gen' +import type { Author, Chat } from '../../graphql/types.gen' import { AuthorCard } from '../Author/Card' import { Icon } from '../_shared/Icon' import { Loading } from '../Loading' @@ -12,6 +12,10 @@ import { loadRecipients, loadChats } from '../../stores/inbox' import { t } from '../../utils/intl' import '../../styles/Inbox.scss' import { useInbox } from '../../context/inbox' +import { Modal } from '../Nav/Modal' +import { showModal } from '../../stores/ui' +import InviteUser from '../Inbox/InviteUser' +import CreateModalContent from '../Inbox/CreateModalContent' const OWNER_ID = '501' const client = createClient({ @@ -54,18 +58,10 @@ const postMessage = async (msg: string) => { return response.data.createComment } -const handleGetChats = async () => { - try { - const response = await loadChats() - console.log('!!! handleGetChats:', response) - } catch (error) { - console.log(error) - } -} - export const InboxView = () => { const [messages, setMessages] = createSignal([]) const [recipients, setRecipients] = createSignal([]) + const [chats, setChats] = createSignal([]) const [cashedRecipients, setCashedRecipients] = createSignal([]) const [postMessageText, setPostMessageText] = createSignal('') const [loading, setLoading] = createSignal(false) @@ -112,6 +108,13 @@ export const InboxView = () => { } catch (error) { console.log(error) } + + try { + const response = await loadChats() + setChats(response as unknown as Chat[]) + } catch (error) { + console.log(error) + } }) const handleSubmit = async () => { @@ -125,36 +128,46 @@ export const InboxView = () => { } } - let formParent // autoresize ghost element + let textareaParent // textarea autoresize ghost element const handleChangeMessage = (event) => { setPostMessageText(event.target.value) } createEffect(() => { - formParent.dataset.replicatedValue = postMessageText() + textareaParent.dataset.replicatedValue = postMessageText() }) - // FIXME: прописать типы - // const { chatEntitieies, actions: { createCaht }} = useInbox() - // const { actions: { createCaht }} = useInbox() + const handleOpenInviteModal = (event: Event) => { + event.preventDefault() + showModal('inviteToChat') + } return ( + + + - + + + + + + + {t('All')} - {t('Conversations')} + {t('Personal')} {t('Groups')} - - {(author) => } + + {(chat) => } @@ -185,7 +198,7 @@ export const InboxView = () => { - + Promise + createChat: (members: string[], title: string) => Promise } } @@ -20,8 +20,8 @@ export function useInbox() { export const InboxProvider = (props: { children: JSX.Element }) => { const [chatEntities, setChatEntities] = createStore({}) - const createChat = async (members: string[]) => { - const chat = await apiClient.createChat({ members }) + const createChat = async (members: string[], title: string) => { + const chat = await apiClient.createChat({ members, title }) setChatEntities((s) => { s[chat.id] = chat }) @@ -31,6 +31,7 @@ export const InboxProvider = (props: { children: JSX.Element }) => { const actions = { createChat } + const value: InboxContextType = { chatEntities, actions } return {props.children} } diff --git a/src/locales/ru.json b/src/locales/ru.json index 9d544a05..49cd9358 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -181,7 +181,12 @@ "zine": "журнал", "shout": "пост", "discussion": "дискурс", - "Conversations": "Переписки", + "Personal": "Личные", "Groups": "Группы", - "All": "Все" + "All": "Все", + "create_chat": "Создать чат", + "create_group": "Создать группу", + "discourse_theme": "Тема дискурса", + "cancel": "Отмена", + "group_chat": "Общий чат" } diff --git a/src/stores/ui.ts b/src/stores/ui.ts index cbff3f54..79730db3 100644 --- a/src/stores/ui.ts +++ b/src/stores/ui.ts @@ -4,7 +4,7 @@ import type { AuthModalSearchParams, ConfirmEmailSearchParams } from '../compone import type { RootSearchParams } from '../components/types' export const [locale, setLocale] = createSignal('ru') -export type ModalType = 'auth' | 'subscribe' | 'feedback' | 'thank' | 'donate' +export type ModalType = 'auth' | 'subscribe' | 'feedback' | 'thank' | 'donate' | 'inviteToChat' type WarnKind = 'error' | 'warn' | 'info' export interface Warning { @@ -18,7 +18,8 @@ export const MODALS: Record = { subscribe: 'subscribe', feedback: 'feedback', thank: 'thank', - donate: 'donate' + donate: 'donate', + inviteToChat: 'inviteToChat' } const [modal, setModal] = createSignal(null) diff --git a/src/styles/Inbox.scss b/src/styles/Inbox.scss index 57709423..ea766bbe 100644 --- a/src/styles/Inbox.scss +++ b/src/styles/Inbox.scss @@ -17,7 +17,7 @@ main { flex: 1; flex-direction: column; position: fixed; - z-index: 9; + z-index: 900; .row { flex: 1; @@ -41,6 +41,12 @@ main { $fade-height: 10px; + .sidebar-header { + display: flex; + align-items: center; + gap: 10px; + } + .holder { overflow: hidden; flex: 1; @@ -105,11 +111,13 @@ main { li { margin-right: 1em; + color: #696969; } strong { border-bottom: 3px solid; font-weight: normal; + color: #000; } } diff --git a/src/styles/app.scss b/src/styles/app.scss index 869b2fe4..91400adc 100644 --- a/src/styles/app.scss +++ b/src/styles/app.scss @@ -4,6 +4,8 @@ @import 'bootstrap/scss/containers'; @import 'bootstrap/scss/grid'; @import 'bootstrap/scss/bootstrap-utilities'; +@import 'bootstrap/scss/forms'; +@import 'bootstrap/scss/buttons'; :root { --background-color: #fff; diff --git a/src/utils/apiClient.ts b/src/utils/apiClient.ts index 3abbe2f4..602eb095 100644 --- a/src/utils/apiClient.ts +++ b/src/utils/apiClient.ts @@ -272,8 +272,7 @@ export const apiClient = { // inbox getChats: async (options: QueryLoadChatsArgs) => { const resp = await privateGraphQLClient.query(myChats, options).toPromise() - console.debug('[loadChats]', resp) - return resp.data.loadChats + return resp.data.loadChats.chats }, createChat: async (options: MutationCreateChatArgs) => {