fixes
This commit is contained in:
parent
539c0454ff
commit
7bd9320d24
|
@ -43,7 +43,6 @@ const formatDate = (date: Date) => {
|
||||||
export const FullArticle = (props: ArticleProps) => {
|
export const FullArticle = (props: ArticleProps) => {
|
||||||
const { session } = useSession()
|
const { session } = useSession()
|
||||||
const formattedDate = createMemo(() => formatDate(new Date(props.article.createdAt)))
|
const formattedDate = createMemo(() => formatDate(new Date(props.article.createdAt)))
|
||||||
const [isSharePopupVisible, setIsSharePopupVisible] = createSignal(false)
|
|
||||||
|
|
||||||
const mainTopic = () =>
|
const mainTopic = () =>
|
||||||
(props.article.topics?.find((topic) => topic?.slug === props.article.mainTopic)?.title || '').replace(
|
(props.article.topics?.find((topic) => topic?.slug === props.article.mainTopic)?.title || '').replace(
|
||||||
|
@ -127,9 +126,6 @@ export const FullArticle = (props: ArticleProps) => {
|
||||||
{/*</div>*/}
|
{/*</div>*/}
|
||||||
<div class={styles.shoutStatsItem}>
|
<div class={styles.shoutStatsItem}>
|
||||||
<SharePopup
|
<SharePopup
|
||||||
onVisibilityChange={(isVisible) => {
|
|
||||||
setIsSharePopupVisible(isVisible)
|
|
||||||
}}
|
|
||||||
containerCssClass={stylesHeader.control}
|
containerCssClass={stylesHeader.control}
|
||||||
trigger={<Icon name="share" class={styles.icon} />}
|
trigger={<Icon name="share" class={styles.icon} />}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -2,20 +2,23 @@ import { useSession } from '../../context/session'
|
||||||
import type { PopupProps } from '../_shared/Popup'
|
import type { PopupProps } from '../_shared/Popup'
|
||||||
import { Popup } from '../_shared/Popup'
|
import { Popup } from '../_shared/Popup'
|
||||||
import styles from '../_shared/Popup/Popup.module.scss'
|
import styles from '../_shared/Popup/Popup.module.scss'
|
||||||
|
import { getPagePath } from '@nanostores/router'
|
||||||
|
import { router } from '../../stores/router'
|
||||||
|
|
||||||
type ProfilePopupProps = Omit<PopupProps, 'children'>
|
type ProfilePopupProps = Omit<PopupProps, 'children'>
|
||||||
|
|
||||||
export const ProfilePopup = (props: ProfilePopupProps) => {
|
export const ProfilePopup = (props: ProfilePopupProps) => {
|
||||||
const {
|
const {
|
||||||
session,
|
userSlug,
|
||||||
actions: { signOut }
|
actions: { signOut }
|
||||||
} = useSession()
|
} = useSession()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popup {...props} horizontalAnchor="right">
|
<Popup {...props} horizontalAnchor="right">
|
||||||
|
{/*TODO: l10n*/}
|
||||||
<ul class="nodash">
|
<ul class="nodash">
|
||||||
<li>
|
<li>
|
||||||
<a href={`/author/${session().user?.slug}`}>Профиль</a>
|
<a href={getPagePath(router, 'author', { slug: userSlug() })}>Профиль</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="#">Черновики</a>
|
<a href="#">Черновики</a>
|
||||||
|
@ -30,7 +33,7 @@ export const ProfilePopup = (props: ProfilePopupProps) => {
|
||||||
<a href="#">Закладки</a>
|
<a href="#">Закладки</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/profile/settings/">Настройки</a>
|
<a href={getPagePath(router, 'profileSettings')}>Настройки</a>
|
||||||
</li>
|
</li>
|
||||||
<li class={styles.topBorderItem}>
|
<li class={styles.topBorderItem}>
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
import { PageWrap } from '../../_shared/PageWrap'
|
|
||||||
import { AuthorView, PRERENDERED_ARTICLES_COUNT } from '../../Views/Author'
|
|
||||||
import type { PageProps } from '../../types'
|
|
||||||
import { createMemo, createSignal, onCleanup, onMount, Show } from 'solid-js'
|
|
||||||
import { loadShouts, resetSortedArticles } from '../../../stores/zine/articles'
|
|
||||||
import { loadAuthor } from '../../../stores/zine/authors'
|
|
||||||
import { Loading } from '../../Loading'
|
|
||||||
import { useSession } from '../../../context/session'
|
|
||||||
import type { Author } from '../../../graphql/types.gen'
|
|
||||||
|
|
||||||
export const ProfilePage = (props: PageProps) => {
|
|
||||||
const [isLoaded, setIsLoaded] = createSignal(Boolean(props.shouts))
|
|
||||||
const { session } = useSession()
|
|
||||||
const profile = createMemo(() => session().user)
|
|
||||||
|
|
||||||
// TODO: ass editing controls
|
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
if (isLoaded()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
await loadShouts({ filters: { author: profile().slug }, limit: PRERENDERED_ARTICLES_COUNT })
|
|
||||||
await loadAuthor({ slug: profile().slug })
|
|
||||||
setIsLoaded(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
onCleanup(() => resetSortedArticles())
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PageWrap>
|
|
||||||
<Show when={isLoaded()} fallback={<Loading />}>
|
|
||||||
<AuthorView author={profile() as Author} shouts={props.shouts} />
|
|
||||||
</Show>
|
|
||||||
</PageWrap>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// for lazy loading
|
|
||||||
export default ProfilePage
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { PageWrap } from '../../_shared/PageWrap'
|
import { PageWrap } from '../../_shared/PageWrap'
|
||||||
import type { PageProps } from '../../types'
|
import type { PageProps } from '../../types'
|
||||||
import { createSignal, onMount, Show } from 'solid-js'
|
|
||||||
import { Loading } from '../../Loading'
|
|
||||||
import styles from './Settings.module.scss'
|
import styles from './Settings.module.scss'
|
||||||
import { Icon } from '../../_shared/Icon'
|
import { Icon } from '../../_shared/Icon'
|
||||||
import { clsx } from 'clsx'
|
import { clsx } from 'clsx'
|
||||||
|
@ -12,7 +10,7 @@ export const ProfileSettingsPage = (props: PageProps) => {
|
||||||
<div class="wide-container">
|
<div class="wide-container">
|
||||||
<div class="shift-content">
|
<div class="shift-content">
|
||||||
<div class="left-col">
|
<div class="left-col">
|
||||||
<div class="left-navigation">zhopa</div>
|
<div class="left-navigation">WIP</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -59,13 +57,13 @@ export const ProfileSettingsPage = (props: PageProps) => {
|
||||||
|
|
||||||
<h4>Представление</h4>
|
<h4>Представление</h4>
|
||||||
<div class="pretty-form__item">
|
<div class="pretty-form__item">
|
||||||
<textarea name="presentation" id="presentation" placeholder="Представление"></textarea>
|
<textarea name="presentation" id="presentation" placeholder="Представление" />
|
||||||
<label for="presentation">Представление</label>
|
<label for="presentation">Представление</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h4>О себе</h4>
|
<h4>О себе</h4>
|
||||||
<div class="pretty-form__item">
|
<div class="pretty-form__item">
|
||||||
<textarea name="about" id="about" placeholder="О себе"></textarea>
|
<textarea name="about" id="about" placeholder="О себе" />
|
||||||
<label for="about">О себе</label>
|
<label for="about">О себе</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ import { InboxPage } from './Pages/InboxPage'
|
||||||
import { LayoutShoutsPage } from './Pages/LayoutShoutsPage'
|
import { LayoutShoutsPage } from './Pages/LayoutShoutsPage'
|
||||||
import { SessionProvider } from '../context/session'
|
import { SessionProvider } from '../context/session'
|
||||||
import { ProfileSettingsPage } from './Pages/profile/ProfileSettingsPage'
|
import { ProfileSettingsPage } from './Pages/profile/ProfileSettingsPage'
|
||||||
import { ProfilePage } from './Pages/profile/ProfilePage'
|
|
||||||
|
|
||||||
// TODO: lazy load
|
// TODO: lazy load
|
||||||
// const SomePage = lazy(() => import('./Pages/SomePage'))
|
// const SomePage = lazy(() => import('./Pages/SomePage'))
|
||||||
|
@ -61,8 +60,7 @@ const pagesMap: Record<keyof Routes, Component<PageProps>> = {
|
||||||
principles: PrinciplesPage,
|
principles: PrinciplesPage,
|
||||||
termsOfUse: TermsOfUsePage,
|
termsOfUse: TermsOfUsePage,
|
||||||
thanks: ThanksPage,
|
thanks: ThanksPage,
|
||||||
profileSettings: ProfileSettingsPage,
|
profileSettings: ProfileSettingsPage
|
||||||
profile: ProfilePage
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Root = (props: PageProps) => {
|
export const Root = (props: PageProps) => {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { resetToken, setToken } from '../graphql/privateGraphQLClient'
|
||||||
|
|
||||||
type SessionContextType = {
|
type SessionContextType = {
|
||||||
session: InitializedResource<AuthResult>
|
session: InitializedResource<AuthResult>
|
||||||
|
userSlug: Accessor<string>
|
||||||
isAuthenticated: Accessor<boolean>
|
isAuthenticated: Accessor<boolean>
|
||||||
actions: {
|
actions: {
|
||||||
refreshSession: () => AuthResult | Promise<AuthResult>
|
refreshSession: () => AuthResult | Promise<AuthResult>
|
||||||
|
@ -42,6 +43,8 @@ export const SessionProvider = (props: { children: JSX.Element }) => {
|
||||||
initialValue: null
|
initialValue: null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const userSlug = createMemo(() => session()?.user?.slug)
|
||||||
|
|
||||||
const isAuthenticated = createMemo(() => Boolean(session()?.user?.slug))
|
const isAuthenticated = createMemo(() => Boolean(session()?.user?.slug))
|
||||||
|
|
||||||
const signIn = async ({ email, password }: { email: string; password: string }) => {
|
const signIn = async ({ email, password }: { email: string; password: string }) => {
|
||||||
|
@ -71,7 +74,7 @@ export const SessionProvider = (props: { children: JSX.Element }) => {
|
||||||
confirmEmail
|
confirmEmail
|
||||||
}
|
}
|
||||||
|
|
||||||
const value: SessionContextType = { session, isAuthenticated, actions }
|
const value: SessionContextType = { session, userSlug, isAuthenticated, actions }
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
refetchRefreshSession()
|
refetchRefreshSession()
|
||||||
|
|
|
@ -27,7 +27,6 @@ export interface Routes {
|
||||||
thanks: void
|
thanks: void
|
||||||
expo: 'layout'
|
expo: 'layout'
|
||||||
inbox: void // TODO: добавить ID текущего юзера
|
inbox: void // TODO: добавить ID текущего юзера
|
||||||
profile: void
|
|
||||||
profileSettings: void
|
profileSettings: void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +55,6 @@ const routerStore = createRouter<Routes>(
|
||||||
termsOfUse: '/about/terms-of-use',
|
termsOfUse: '/about/terms-of-use',
|
||||||
thanks: '/about/thanks',
|
thanks: '/about/thanks',
|
||||||
expo: '/expo/:layout',
|
expo: '/expo/:layout',
|
||||||
profile: '/profile',
|
|
||||||
profileSettings: '/profile/settings'
|
profileSettings: '/profile/settings'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user