-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #1323 Add Faq and Faq Category content types to Strapi * #1323 Implement FE sections for Faqs and Faq Categories * #1323 Fix PR comments
- Loading branch information
1 parent
6448437
commit e8c3c3c
Showing
19 changed files
with
989 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
|
||
import Accordion from '@/components/common/Accordion/Accordion' | ||
import Markdown from '@/components/formatting/Markdown/Markdown' | ||
import { FaqEntityFragment } from '@/services/graphql' | ||
import { isDefined } from '@/utils/isDefined' | ||
|
||
export type FaqsGroupProps = { | ||
faqs: FaqEntityFragment[] | ||
} | ||
|
||
const FaqsGroup = ({ faqs }: FaqsGroupProps) => { | ||
return ( | ||
<div className="flex flex-col gap-4"> | ||
{faqs | ||
.map((faq, index) => { | ||
if (!faq.attributes) return null | ||
|
||
return ( | ||
// eslint-disable-next-line react/no-array-index-key | ||
<Accordion key={index} title={faq.attributes.title}> | ||
<Markdown content={faq.attributes.body} variant="small-no-respo" /> | ||
</Accordion> | ||
) | ||
}) | ||
.filter(isDefined)} | ||
</div> | ||
) | ||
} | ||
|
||
export default FaqsGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Typography } from '@bratislava/component-library' | ||
import React from 'react' | ||
|
||
import FaqsGroup from '@/components/common/FaqsGroup/FaqsGroup' | ||
import { FaqCategoriesSectionFragment } from '@/services/graphql' | ||
import { isDefined } from '@/utils/isDefined' | ||
|
||
type Props = { | ||
section: FaqCategoriesSectionFragment | ||
} | ||
|
||
const FaqCategoriesSection = ({ section }: Props) => { | ||
const { title, text, faqCategories } = section ?? {} | ||
|
||
const filteredFaqCategories = faqCategories?.data.filter(isDefined) ?? [] | ||
|
||
return ( | ||
<div className="flex flex-col gap-6 lg:gap-12"> | ||
{title || text ? ( | ||
<div className="col-span-1 flex flex-col gap-3 md:col-span-5"> | ||
{title ? <Typography type="h2">{title}</Typography> : null} | ||
{text ? <Typography type="p">{text}</Typography> : null} | ||
</div> | ||
) : null} | ||
{filteredFaqCategories | ||
.map((faqCategory) => { | ||
if (!faqCategory.attributes) return null | ||
|
||
const { title: categoryTitle, faqs, slug } = faqCategory.attributes | ||
const filteredFaqs = faqs?.data.filter(isDefined) ?? [] | ||
|
||
return ( | ||
<div key={slug} className="flex flex-col gap-8 lg:gap-10"> | ||
<Typography type="h3">{categoryTitle}</Typography> | ||
<FaqsGroup faqs={filteredFaqs} /> | ||
</div> | ||
) | ||
}) | ||
.filter(isDefined)} | ||
</div> | ||
) | ||
} | ||
|
||
export default FaqCategoriesSection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Typography } from '@bratislava/component-library' | ||
import React from 'react' | ||
|
||
import FaqsGroup from '@/components/common/FaqsGroup/FaqsGroup' | ||
import { FaqsSectionFragment } from '@/services/graphql' | ||
import { isDefined } from '@/utils/isDefined' | ||
|
||
type Props = { | ||
section: FaqsSectionFragment | ||
} | ||
|
||
const FaqsSection = ({ section }: Props) => { | ||
const { title, text, faqs } = section ?? {} | ||
|
||
const filteredFaqs = faqs?.data.filter(isDefined) ?? [] | ||
|
||
return ( | ||
<div className="flex flex-col gap-6 lg:gap-12"> | ||
{title || text ? ( | ||
<div className="col-span-1 flex flex-col gap-3 md:col-span-5"> | ||
{title ? <Typography type="h2">{title}</Typography> : null} | ||
{text ? <Typography type="p">{text}</Typography> : null} | ||
</div> | ||
) : null} | ||
|
||
<FaqsGroup faqs={filteredFaqs} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default FaqsSection |
Oops, something went wrong.