Skip to content

Commit

Permalink
Merge pull request #485 from audioverse-org/AV-615-Logged-User-to-see…
Browse files Browse the repository at this point in the history
…-Discover-Section-upon-accessing-website-currently-shows-Home-Page

Av 615 logged user to see discover section upon accessing website currently shows home page
  • Loading branch information
jlaverde77 authored Oct 12, 2023
2 parents 4a030d5 + d374ea3 commit f10640f
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 10 deletions.
18 changes: 18 additions & 0 deletions public/compiled-lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,24 @@
"value": "All Audiobooks"
}
],
"browse__topicsNext": [
{
"type": 0,
"value": "Next topics"
}
],
"browse__topicsPrevious": [
{
"type": 0,
"value": "Previous topics"
}
],
"browse_topicsHeading": [
{
"type": 0,
"value": "Topics"
}
],
"buttonShareRecording__emailSubject": [
{
"type": 1,
Expand Down
9 changes: 9 additions & 0 deletions public/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,15 @@
"books__title": {
"string": "All Audiobooks"
},
"browse__topicsNext": {
"string": "Next topics"
},
"browse__topicsPrevious": {
"string": "Previous topics"
},
"browse_topicsHeading": {
"string": "Topics"
},
"buttonShareRecording__emailSubject": {
"string": "{title} by {presenters}"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/cardSlider/section/topics.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ query getSectionTopics(
language: $language
first: $first
after: $after
orderBy: { field: ID, direction: DESC }
orderBy: { field: FEATURED, direction: ASC }
) {
nodes {
...cardTopic
Expand Down
20 changes: 20 additions & 0 deletions src/components/organisms/cardSlider/section/topicsBrowse.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
query getSectionTopicsBrowse(
$language: Language!
$first: Int! = 6
$after: String = null
) {
topics(
language: $language
first: $first
after: $after
orderBy: { field: FEATURED, direction: DESC }
) {
nodes {
...cardTopic
}
pageInfo {
hasNextPage
endCursor
}
}
}
34 changes: 34 additions & 0 deletions src/components/organisms/cardSlider/section/topicsBrowse.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { useIntl } from 'react-intl';

import { CardTopicFragment } from '~src/components/molecules/card/__generated__/topic';
import CardTopic from '~src/components/molecules/card/topic';
import root from '~src/lib/routes';
import { useLanguageId } from '~src/lib/useLanguageId';

import { useInfiniteGetSectionTopicsBrowseQuery } from './__generated__/topicsBrowse';
import Section from './index';

export default function TopicsBrowse(): JSX.Element {
const intl = useIntl();
const language = useLanguageId();
return (
<Section
infiniteQuery={useInfiniteGetSectionTopicsBrowseQuery}
heading={intl.formatMessage({
id: 'browse_topicsHeading',
defaultMessage: 'Topics',
})}
previous={intl.formatMessage({
id: 'browse__topicsPrevious',
defaultMessage: 'Previous topics',
})}
next={intl.formatMessage({
id: 'browse__topicsNext',
defaultMessage: 'Next topics',
})}
seeAllUrl={root.lang(language).topics.get()}
Card={(p: { node: CardTopicFragment }) => <CardTopic topic={p.node} />}
/>
);
}
10 changes: 3 additions & 7 deletions src/containers/account/loginRedirect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@ import { useRouter } from 'next/router';
import React, { useEffect } from 'react';
import { FormattedMessage } from 'react-intl';

import root, { isRedirectRouteAllowed } from '~lib/routes';
import root from '~lib/routes';
import useLanguageRoute from '~lib/useLanguageRoute';

export default function LoginRedirect(): JSX.Element {
const router = useRouter();
const route = useLanguageRoute();

useEffect(() => {
const backRoute = router.query.back as string;
router.push(
backRoute && isRedirectRouteAllowed(backRoute)
? backRoute
: root.lang(route).discover.get()
);
//const backRoute = router.query.back as string;
router.push(root.lang(route).discover.get());
}, [router, route]);

return (
Expand Down
4 changes: 2 additions & 2 deletions src/containers/discover/collections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ScriptureSongs from '~src/components/organisms/cardSlider/section/scriptu
import Series from '~src/components/organisms/cardSlider/section/series';
import Sponsors from '~src/components/organisms/cardSlider/section/sponsors';
import StorySeasons from '~src/components/organisms/cardSlider/section/storySeasons';
import Topics from '~src/components/organisms/cardSlider/section/topics';
import TopicsBrowse from '~src/components/organisms/cardSlider/section/topicsBrowse';

import { GetDiscoverCollectionsPageDataQuery } from './__generated__/collections';

Expand All @@ -18,7 +18,7 @@ export default function DiscoverCollections(): JSX.Element {
return (
<div>
<Presenters />
<Topics />
<TopicsBrowse />
<Series />
<Audiobooks />
<Conferences
Expand Down
1 change: 1 addition & 0 deletions src/pages/[language]/discover/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export async function getStaticProps({
getSectionScriptureSongs: { language },
getSectionSeries: { language },
getSectionTopics: { language },
getSectionTopicsBrowse: { language },
});

return {
Expand Down
1 change: 1 addition & 0 deletions src/pages/[language]/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function getStaticProps({
getSectionConferences: { language },
getSectionBlogPosts: { language },
getSectionTopics: { language },
getSectionTopicsBrowse: { language },
getSectionPresenters: { language },
getSectionBibleBooks: { language },
getSectionTrendingMusic: { language },
Expand Down

1 comment on commit f10640f

@vercel
Copy link

@vercel vercel bot commented on f10640f Oct 12, 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.