Redirect to chat

This commit is contained in:
ilya-bkv 2022-12-06 12:03:23 +03:00
parent c491edc8f7
commit 267b201732
7 changed files with 17 additions and 0 deletions

View File

@ -10,6 +10,8 @@ import { follow, unfollow } from '../../stores/zine/common'
import { clsx } from 'clsx' import { clsx } from 'clsx'
import { useSession } from '../../context/session' import { useSession } from '../../context/session'
import { FollowingEntity } from '../../graphql/types.gen' import { FollowingEntity } from '../../graphql/types.gen'
import { router, useRouter } from '../../stores/router'
import { openPage } from '@nanostores/router'
interface AuthorCardProps { interface AuthorCardProps {
caption?: string caption?: string
@ -43,6 +45,11 @@ export const AuthorCard = (props: AuthorCardProps) => {
: translit(props.author.name || '', locale() || 'ru') : translit(props.author.name || '', locale() || 'ru')
} }
// TODO: reimplement AuthorCard // TODO: reimplement AuthorCard
const { changeSearchParam } = useRouter()
const handleInitChat = () => {
openPage(router, 'inbox')
changeSearchParam('openChat', `${props.author.id}`)
}
return ( return (
<div <div
class={clsx(styles.author)} class={clsx(styles.author)}
@ -127,6 +134,7 @@ export const AuthorCard = (props: AuthorCardProps) => {
'button--subscribe-topic': props.isAuthorsList, 'button--subscribe-topic': props.isAuthorsList,
[styles.buttonWrite]: props.liteButtons && props.isAuthorsList [styles.buttonWrite]: props.liteButtons && props.isAuthorsList
}} }}
onClick={handleInitChat}
> >
<Icon name="comment" class={styles.icon} /> <Icon name="comment" class={styles.icon} />
<Show when={!props.liteButtons}>{t('Write')}</Show> <Show when={!props.liteButtons}>{t('Write')}</Show>

View File

@ -7,3 +7,7 @@ export type AuthModalSearchParams = {
export type ConfirmEmailSearchParams = { export type ConfirmEmailSearchParams = {
token: string token: string
} }
export type CreateChatSearchParams = {
id: number
}

View File

@ -4,6 +4,7 @@ export default gql`
query GetAuthorBySlugQuery($slug: String!) { query GetAuthorBySlugQuery($slug: String!) {
getAuthor(slug: $slug) { getAuthor(slug: $slug) {
_id: slug _id: slug
id
slug slug
name name
bio bio

View File

@ -4,6 +4,7 @@ export default gql`
query UserSubscribersQuery($slug: String!) { query UserSubscribersQuery($slug: String!) {
userSubcribers(slug: $slug) { userSubcribers(slug: $slug) {
_id: slug _id: slug
id
slug slug
name name
bio bio

View File

@ -4,6 +4,7 @@ export default gql`
query UserFollowingQuery($slug: String!) { query UserFollowingQuery($slug: String!) {
userFollowing(slug: $slug) { userFollowing(slug: $slug) {
_id: slug _id: slug
id
slug slug
name name
bio bio

View File

@ -4,6 +4,7 @@ export default gql`
query AuthorsAllQuery { query AuthorsAllQuery {
authorsAll { authorsAll {
_id: slug _id: slug
id
slug slug
name name
bio bio

View File

@ -4,6 +4,7 @@ export default gql`
query AuthorLoadByQuery($by: AuthorsBy, $limit: Int, $offset: Int) { query AuthorLoadByQuery($by: AuthorsBy, $limit: Int, $offset: Int) {
loadAuthorsBy(by: $by, limit: $limit, offset: $offset) { loadAuthorsBy(by: $by, limit: $limit, offset: $offset) {
_id: slug _id: slug
id
slug slug
name name
bio bio