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