2022-11-10 15:06:02 +00:00
|
|
|
|
import './DialogCard.module.scss'
|
|
|
|
|
import styles from './DialogCard.module.scss'
|
|
|
|
|
import DialogAvatar from './DialogAvatar'
|
|
|
|
|
import type { Author } from '../../graphql/types.gen'
|
2022-11-15 12:15:07 +00:00
|
|
|
|
// import { useAuthStore } from '../../stores/auth'
|
2022-11-15 09:45:55 +00:00
|
|
|
|
import { createEffect, createSignal } from 'solid-js'
|
|
|
|
|
import { apiClient } from '../../utils/apiClient'
|
2022-11-10 15:06:02 +00:00
|
|
|
|
|
2022-11-15 09:45:55 +00:00
|
|
|
|
const { session } = useAuthStore()
|
2022-11-10 15:06:02 +00:00
|
|
|
|
|
2022-11-15 12:15:07 +00:00
|
|
|
|
type DialogProps = {
|
2022-11-10 15:06:02 +00:00
|
|
|
|
online?: boolean
|
|
|
|
|
message?: string
|
|
|
|
|
counter?: number
|
2022-11-14 17:09:51 +00:00
|
|
|
|
author?: Author
|
|
|
|
|
}
|
2022-11-10 15:06:02 +00:00
|
|
|
|
|
2022-11-15 09:45:55 +00:00
|
|
|
|
const createChat = async ({ title, members }: { title?: string; members?: string[] }): Promise<void> => {
|
|
|
|
|
await apiClient.createChat({ title, members })
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-15 12:15:07 +00:00
|
|
|
|
const DialogCard = (props: DialogProps) => {
|
2022-11-15 09:45:55 +00:00
|
|
|
|
const [currentUser, setCurrentUser] = createSignal(undefined)
|
|
|
|
|
createEffect(() => {
|
|
|
|
|
setCurrentUser(session()?.user?.slug)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const handleOpenChat = async () => {
|
|
|
|
|
try {
|
|
|
|
|
const test = await apiClient.createChat({
|
|
|
|
|
title: 'test chat',
|
2022-11-15 12:15:07 +00:00
|
|
|
|
members: [props.author.slug, currentUser()]
|
2022-11-15 09:45:55 +00:00
|
|
|
|
})
|
|
|
|
|
console.log('!!! test:', test)
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.log('!!! errr:', err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-10 15:06:02 +00:00
|
|
|
|
return (
|
2022-11-15 09:45:55 +00:00
|
|
|
|
<div class={styles.DialogCard} onClick={handleOpenChat}>
|
2022-11-10 15:06:02 +00:00
|
|
|
|
<div class={styles.avatar}>
|
2022-11-14 17:09:51 +00:00
|
|
|
|
<DialogAvatar name={props.author.name} url={props.author.userpic} online={props.online} />
|
2022-11-10 15:06:02 +00:00
|
|
|
|
</div>
|
2022-11-10 15:58:43 +00:00
|
|
|
|
<div class={styles.row}>
|
2022-11-14 17:09:51 +00:00
|
|
|
|
<div class={styles.name}>{props.author.name}</div>
|
2022-11-10 15:06:02 +00:00
|
|
|
|
<div class={styles.message}>
|
|
|
|
|
Указать предпочтительные языки для результатов поиска можно в разделе
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class={styles.activity}>
|
|
|
|
|
<div class={styles.time}>22:22</div>
|
|
|
|
|
<div class={styles.counter}>
|
|
|
|
|
<span>12</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DialogCard
|