Skip to content

Commit

Permalink
update Posts Features page cta for signed in users (#2031)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitoo1 authored Oct 19, 2023
1 parent 2156cb6 commit 7ac7735
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions apps/web/src/scenes/ContentPages/PostsFeaturePage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Head from 'next/head';
import { Route } from 'nextjs-routes';
import { useMemo } from 'react';
import { graphql, useLazyLoadQuery } from 'react-relay';
import styled from 'styled-components';

import breakpoints, { pageGutter } from '~/components/core/breakpoints';
Expand All @@ -7,6 +10,7 @@ import GalleryLink from '~/components/core/GalleryLink/GalleryLink';
import Markdown from '~/components/core/Markdown/Markdown';
import { VStack } from '~/components/core/Spacer/Stack';
import { TitleCondensed, TitleDiatypeL, TitleXS } from '~/components/core/Text/Text';
import { PostsFeaturePageContentQuery } from '~/generated/PostsFeaturePageContentQuery.graphql';
import { contexts, flows } from '~/shared/analytics/constants';
import colors from '~/shared/theme/colors';

Expand All @@ -30,6 +34,24 @@ export default function PostsFeaturePage({ pageContent }: Props) {
}

export function PostsFeaturePageContent({ pageContent }: Props) {
const query = useLazyLoadQuery<PostsFeaturePageContentQuery>(
graphql`
query PostsFeaturePageContentQuery {
viewer {
__typename
}
}
`,
{}
);

const isAuthenticated = query.viewer?.__typename === 'Viewer';
const ctaButtonRoute: Route = useMemo(() => {
if (!isAuthenticated) return { pathname: '/auth' };

return { pathname: '/home', query: { composer: 'true' } };
}, [isAuthenticated]);

return (
<StyledPage gap={96}>
<StyledContent align="center" gap={96}>
Expand All @@ -49,7 +71,7 @@ export function PostsFeaturePageContent({ pageContent }: Props) {
<StyledSubheading>{pageContent.introText}</StyledSubheading>
</VStack>
<GalleryLink
to={{ pathname: '/auth' }}
to={ctaButtonRoute}
eventElementId="Posts Feature Page: Get Started"
eventName="Posts Feature Page: Get Started Click"
eventContext={contexts.Posts}
Expand All @@ -73,7 +95,7 @@ export function PostsFeaturePageContent({ pageContent }: Props) {
</StyledSubheading>
)}
<GalleryLink
to={{ pathname: '/auth' }}
to={ctaButtonRoute}
eventElementId="Posts Feature Page: Get Started"
eventName="Posts Feature Page: Get Started Click"
eventContext={contexts.Posts}
Expand Down

1 comment on commit 7ac7735

@vercel
Copy link

@vercel vercel bot commented on 7ac7735 Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.