2022-11-10 15:06:02 +00:00
|
|
|
|
import styles from './DialogCard.module.scss'
|
|
|
|
|
import DialogAvatar from './DialogAvatar'
|
2022-11-23 05:40:45 +00:00
|
|
|
|
import type { Author } from '../../graphql/types.gen'
|
2022-11-15 09:45:55 +00:00
|
|
|
|
import { apiClient } from '../../utils/apiClient'
|
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-23 04:12:11 +00:00
|
|
|
|
ownSlug: Author['slug']
|
2022-11-15 09:45:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-15 12:15:07 +00:00
|
|
|
|
const DialogCard = (props: DialogProps) => {
|
2022-11-15 09:45:55 +00:00
|
|
|
|
const handleOpenChat = async () => {
|
|
|
|
|
try {
|
2022-11-15 13:55:00 +00:00
|
|
|
|
const initChat = await apiClient.createChat({
|
2022-11-15 09:45:55 +00:00
|
|
|
|
title: 'test chat',
|
2022-11-23 04:12:11 +00:00
|
|
|
|
members: [props.author.slug, props.ownSlug]
|
2022-11-15 09:45:55 +00:00
|
|
|
|
})
|
2022-11-23 04:12:11 +00:00
|
|
|
|
console.debug('[initChat]', initChat.data)
|
2022-11-15 14:24:50 +00:00
|
|
|
|
} catch (error) {
|
2022-11-23 04:12:11 +00:00
|
|
|
|
console.error(error)
|
2022-11-15 09:45:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|