From eb7e7bd063d758a239039b1b7f5db56e9be0e4c0 Mon Sep 17 00:00:00 2001
From: ilya-bkv
Date: Thu, 29 Dec 2022 15:35:24 +0300
Subject: [PATCH] Show profile tabs (comments and about)
---
src/components/Views/Author.tsx | 99 +++++++++++++++++++++++----------
src/utils/apiClient.ts | 14 ++++-
2 files changed, 82 insertions(+), 31 deletions(-)
diff --git a/src/components/Views/Author.tsx b/src/components/Views/Author.tsx
index 8eba28d9..a2aa1e99 100644
--- a/src/components/Views/Author.tsx
+++ b/src/components/Views/Author.tsx
@@ -1,4 +1,4 @@
-import { Show, createMemo, createSignal, For, onMount } from 'solid-js'
+import { Show, createMemo, createSignal, Switch, onMount, For, Match, createEffect } from 'solid-js'
import type { Author, Shout } from '../../graphql/types.gen'
import { Row1 } from '../Feed/Row1'
import { Row2 } from '../Feed/Row2'
@@ -17,6 +17,9 @@ import { clsx } from 'clsx'
import Userpic from '../Author/Userpic'
import { Popup } from '../_shared/Popup'
import { AuthorCard } from '../Author/Card'
+import { loadReactionsBy, REACTIONS_AMOUNT_PER_PAGE } from '../../stores/zine/reactions'
+import { apiClient } from '../../utils/apiClient'
+import Comment from '../Article/Comment'
// TODO: load reactions on client
type AuthorProps = {
@@ -28,7 +31,7 @@ type AuthorProps = {
}
type AuthorPageSearchParams = {
- by: '' | 'viewed' | 'rating' | 'commented' | 'recent' | 'followed'
+ by: '' | 'viewed' | 'rating' | 'commented' | 'recent' | 'followed' | 'about' | 'popular'
}
export const PRERENDERED_ARTICLES_COUNT = 12
@@ -75,6 +78,23 @@ export const AuthorView = (props: AuthorProps) => {
splitToPages(sortedArticles(), PRERENDERED_ARTICLES_COUNT, LOAD_MORE_PAGE_SIZE)
)
+ console.log('!!! authorEntities():', author())
+ const [commented, setCommented] = createSignal([])
+ createEffect(async () => {
+ if (searchParams().by === 'commented') {
+ try {
+ const data = await apiClient.getReactionsBy({
+ by: { comment: true, createdBy: props.authorSlug },
+ limit: 100,
+ offset: 0
+ })
+ setCommented(data)
+ } catch (error) {
+ console.log('!!! error:', error)
+ }
+ }
+ })
+
return (
{t('Loading')}
}>
@@ -95,7 +115,17 @@ export const AuthorView = (props: AuthorProps) => {
+
+
+
+
+
+
@@ -115,7 +145,7 @@ export const AuthorView = (props: AuthorProps) => {
>
- {(item) => (
+ {(item: Author) => (
-
@@ -132,33 +162,44 @@ export const AuthorView = (props: AuthorProps) => {
-
-
-
-
-
-
+ дефолтное состояние
}>
+
+ About
+ {JSON.stringify(authorEntities())}
+
+
+ {(comment) => }
+
+
+
+
+
+
+
+
-
- {(page) => (
- <>
-
-
-
-
-
-
- >
- )}
-
+
+ {(page) => (
+ <>
+
+
+
+
+
+
+ >
+ )}
+
-
-
-
-
-
+
+
+
+
+
+
+
)
diff --git a/src/utils/apiClient.ts b/src/utils/apiClient.ts
index 113047bd..a3132aa6 100644
--- a/src/utils/apiClient.ts
+++ b/src/utils/apiClient.ts
@@ -12,7 +12,8 @@ import type {
MutationCreateMessageArgs,
Chat,
QueryLoadRecipientsArgs,
- ProfileInput
+ ProfileInput,
+ ReactionBy
} from '../graphql/types.gen'
import { publicGraphQLClient } from '../graphql/publicGraphQLClient'
import { getToken, privateGraphQLClient } from '../graphql/privateGraphQLClient'
@@ -269,7 +270,16 @@ export const apiClient = {
if (resp.error) console.debug(resp)
return resp.data.loadShouts
},
- getReactionsBy: async ({ by, limit = REACTIONS_AMOUNT_PER_PAGE, offset = 0 }) => {
+
+ getReactionsBy: async ({
+ by,
+ limit = REACTIONS_AMOUNT_PER_PAGE,
+ offset = 0
+ }: {
+ by: ReactionBy
+ limit: number
+ offset: number
+ }) => {
const resp = await publicGraphQLClient.query(reactionsLoadBy, { by, limit, offset }).toPromise()
console.debug(resp)
return resp.data.loadReactionsBy