webapp/src/components/Inbox/DialogCard.tsx

49 lines
1.3 KiB
TypeScript
Raw Normal View History

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 09:45:55 +00:00
import { apiClient } from '../../utils/apiClient'
2022-11-10 15:06:02 +00:00
type Props = {
online?: boolean
message?: string
counter?: number
2022-11-15 12:48:42 +00:00
ownerSlug: Author['slug']
2022-11-10 15:06:02 +00:00
} & Author
const DialogCard = (props: Props) => {
2022-11-15 09:45:55 +00:00
const handleOpenChat = async () => {
try {
const test = await apiClient.createChat({
title: 'test chat',
2022-11-15 12:48:42 +00:00
members: [props.slug, props.ownerSlug]
2022-11-15 09:45:55 +00:00
})
2022-11-15 12:48:42 +00:00
console.log('!!! test:', test.data)
2022-11-15 09:45:55 +00:00
} 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}>
<DialogAvatar name={props.name} url={props.userpic} online={props.online} />
</div>
2022-11-10 15:58:43 +00:00
<div class={styles.row}>
2022-11-10 15:06:02 +00:00
<div class={styles.name}>{props.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