Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Kevin/blog-hide-eu-feature #2079

Merged
6 commits merged into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions src/pages/academy/_recent-featured-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,11 @@ const RecentFeaturedPosts = ({ recent_data, featured_data }) => {
<TagParentWrapper>
{headline_recent.tags.map((article) => {
return (
<>
<TagWrapper key={article.id}>
<StyledCategories>
{article.tags_id.tag_name}
</StyledCategories>
</TagWrapper>
</>
<TagWrapper key={article.id}>
<StyledCategories>
{article.tags_id.tag_name}
</StyledCategories>
</TagWrapper>
)
})}
</TagParentWrapper>
Expand Down Expand Up @@ -125,7 +123,8 @@ const RecentFeaturedPosts = ({ recent_data, featured_data }) => {
className="small-article-bg"
data={article.main_image.imageFile}
alt={
article.main_image.description || ''
article?.main_image?.description ||
''
}
height="102px"
/>
Expand All @@ -142,7 +141,7 @@ const RecentFeaturedPosts = ({ recent_data, featured_data }) => {
.slice(0, 1)
.map((tag) => (
<SmallArticleCategories
key={tag.id}
key={tag?.id}
>
{tag?.tags_id?.tag_name}
</SmallArticleCategories>
Expand Down Expand Up @@ -189,13 +188,11 @@ const RecentFeaturedPosts = ({ recent_data, featured_data }) => {
<TagParentWrapper>
{headline_featured.tags.map((article) => {
return (
<>
<TagWrapper key={article.id}>
<StyledCategories>
{article.tags_id.tag_name}
</StyledCategories>
</TagWrapper>
</>
<TagWrapper key={article.id}>
<StyledCategories>
{article.tags_id.tag_name}
</StyledCategories>
</TagWrapper>
)
})}
</TagParentWrapper>
Expand Down Expand Up @@ -236,7 +233,8 @@ const RecentFeaturedPosts = ({ recent_data, featured_data }) => {
className="small-article-bg"
data={article.main_image.imageFile}
alt={
article.main_image.description || ''
article?.main_image?.description ||
''
}
height="102px"
/>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/academy/blog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Header } from 'components/elements'
import { localize, WithIntl } from 'components/localization'
import HeroImage from 'images/common/blog/deriv-blog.png'
import device from 'themes/device'
import { DerivStore } from 'store'

const SmallContainer = styled(Container)`
width: 60%;
Expand Down Expand Up @@ -51,7 +52,11 @@ const StyledHeader = styled(Header)`
`

const ArticlesPage = ({ data }) => {
const article_data = data.directus.blog
const { is_eu_country } = React.useContext(DerivStore)
const article_data = is_eu_country
? data.directus.blog.filter((item) => item.hide_for_eu == false)
: data.directus.blog

return (
<Layout>
<SEO
Expand Down Expand Up @@ -101,6 +106,7 @@ export const query = graphql`
}
slug
featured
hide_for_eu
tags {
id
tags_id {
Expand Down
165 changes: 159 additions & 6 deletions src/pages/academy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Layout from 'components/layout/layout'
import { Container, SEO, Flex } from 'components/containers'
import { localize, WithIntl, LocalizedLink } from 'components/localization'
import { Carousel, QueryImage } from 'components/elements'
import { DerivStore } from 'store'

const MainWrapper = styled(Flex)`
background-color: var(--color-white);
Expand All @@ -34,7 +35,7 @@ export const query = graphql`
id
}
}
blog(
market_news: blog(
filter: {
tags: { tags_id: { tag_name: { _contains: "Market News" } } }
status: { _eq: "published" }
Expand All @@ -60,6 +61,34 @@ export const query = graphql`
id
}
}
market_news_eu: blog(
filter: {
tags: { tags_id: { tag_name: { _contains: "Market News" } } }
status: { _eq: "published" }
hide_for_eu: { _eq: false }
}
limit: 6
sort: "-published_date"
) {
id
blog_title
slug
hide_for_eu
tags {
tags_id {
tag_name
}
}
read_time_in_minutes
main_image {
imageFile {
childImageSharp {
gatsbyImageData
}
}
id
}
}
videos(limit: 6, filter: { status: { _eq: "published" } }, sort: "-published_date") {
video_title
published_date
Expand All @@ -79,6 +108,30 @@ export const query = graphql`
}
}
}
videos_eu: videos(
limit: 6
filter: { status: { _eq: "published" }, hide_for_eu: { _eq: false } }
sort: "-published_date"
) {
video_title
published_date
video_description
video_duration
featured
hide_for_eu
video_thumbnail {
id
title
}
video_file {
id
}
tags {
tags_id {
tag_name
}
}
}
featured_video: videos(
filter: { status: { _eq: "published" }, featured: { _eq: true } }
sort: "-published_date"
Expand All @@ -89,6 +142,35 @@ export const query = graphql`
video_description
video_duration
featured
hide_for_eu
video_thumbnail {
id
title
}
video_file {
id
}
tags {
tags_id {
tag_name
}
}
}
featured_video_eu: videos(
filter: {
status: { _eq: "published" }
featured: { _eq: true }
hide_for_eu: { _eq: false }
}
sort: "-published_date"
limit: 1
) {
video_title
published_date
video_description
video_duration
featured
hide_for_eu
video_thumbnail {
id
title
Expand Down Expand Up @@ -130,6 +212,35 @@ export const query = graphql`
blog_description
read_time_in_minutes
}
recent_eu: blog(
filter: { status: { _eq: "published" }, hide_for_eu: { _eq: false } }
sort: "-published_date"
limit: 6
) {
id
main_image {
id
description
imageFile {
childImageSharp {
gatsbyImageData
}
}
}
slug
published_date
featured
hide_for_eu
tags {
id
tags_id {
tag_name
}
}
blog_title
blog_description
read_time_in_minutes
}
featured: blog(
filter: { status: { _eq: "published" }, featured: { _eq: true } }
sort: "-published_date"
Expand Down Expand Up @@ -158,6 +269,39 @@ export const query = graphql`
blog_description
read_time_in_minutes
}
featured_eu: blog(
filter: {
status: { _eq: "published" }
featured: { _eq: true }
hide_for_eu: { _eq: false }
}
sort: "-published_date"
limit: 6
) {
id
main_image {
id
description
imageFile {
childImageSharp {
gatsbyImageData
}
}
}
slug
published_date
featured
hide_for_eu
tags {
id
tags_id {
tag_name
}
}
blog_title
blog_description
read_time_in_minutes
}
}
}
`
Expand All @@ -179,13 +323,22 @@ const DerivBlog = ({ data }) => {
nav_color: '--color-grey-5',
},
}

const { is_eu_country } = React.useContext(DerivStore)

const homepage_banner_data = data.directus.homepage_banners
const market_news_data = data.directus.blog
const market_news_data = is_eu_country
? data.directus.market_news_eu
: data.directus.market_news

const recent_data = data.directus.recent
const featured_data = data.directus.featured
const non_featured_video_list_data = data.directus.videos
const featured_video_list_data = data.directus.featured_video
const recent_data = is_eu_country ? data.directus.recent_eu : data.directus.recent
const featured_data = is_eu_country ? data.directus.featured_eu : data.directus.featured
const non_featured_video_list_data = is_eu_country
? data.directus.videos_eu
: data.directus.videos
const featured_video_list_data = is_eu_country
? data.directus.featured_video_eu
: data.directus.featured_video

return (
<Layout type="academy" is_ppc_redirect={true}>
Expand Down
7 changes: 6 additions & 1 deletion src/pages/academy/videos/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Header } from 'components/elements'
import { localize, WithIntl } from 'components/localization'
import HeroImage from 'images/common/blog/video-tutorials.png'
import device from 'themes/device'
import { DerivStore } from 'store'

const SmallContainer = styled(Container)`
width: 60%;
Expand Down Expand Up @@ -51,7 +52,10 @@ const StyledHeader = styled(Header)`
`

const VideosPage = ({ data }) => {
const video_data = data.directus.videos
const { is_eu_country } = React.useContext(DerivStore)
const video_data = is_eu_country
? data.directus.videos.filter((item) => item.hide_for_eu == false)
: data.directus.videos

return (
<Layout>
Expand Down Expand Up @@ -96,6 +100,7 @@ export const query = graphql`
published_date
video_description
video_duration
hide_for_eu
tags {
tags_id {
tag_name
Expand Down