webapp/src/components/Inbox/DialogCard.tsx
ilya-bkv e2679ce6b1 Wip
2022-11-24 15:58:07 +03:00

49 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import styles from './DialogCard.module.scss'
import DialogAvatar from './DialogAvatar'
import type { Author } from '../../graphql/types.gen'
import { apiClient } from '../../utils/apiClient'
type DialogProps = {
online?: boolean
message?: string
counter?: number
author?: Author
ownSlug: Author['slug']
}
const DialogCard = (props: DialogProps) => {
const handleOpenChat = async () => {
try {
const initChat = await apiClient.createChat({
title: 'test chat',
members: [props.author.slug, props.ownSlug]
})
console.debug('[initChat]', initChat.data.createChat)
} catch (error) {
console.error(error)
}
}
return (
<div class={styles.DialogCard} onClick={handleOpenChat}>
<div class={styles.avatar}>
<DialogAvatar name={props.author.name} url={props.author.userpic} online={props.online} />
</div>
<div class={styles.row}>
<div class={styles.name}>{props.author.name}</div>
<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