Skip to content

Commit a42023a

Browse files
committed
GoodDollar button depending on markup
1 parent 72fd411 commit a42023a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

.idx/dev.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
pkgs.automake
2222
pkgs.libtool
2323
pkgs.m4
24+
pkgs.patch
2425
];
2526

2627
# Sets environment variables in the workspace
@@ -63,4 +64,3 @@
6364
};
6465
};
6566
}
66-

apps/nextjs/app/[lang]/[pathPrefix]/[pathSuffix]/page.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default function Page({ params }: PageProps) {
5050
const [guideHtml, setGuideHtml] = useState('')
5151
const [creditsHtml, setCreditsHtml] = useState('')
5252
const [isClient, setIsClient] = useState(false)
53+
const [showGoodDollarButton, setShowGoodDollarButton] = useState(false)
5354

5455
const htmlDeMd = useCallback((md: string | undefined) => {
5556
if (!md) return ''
@@ -116,7 +117,11 @@ export default function Page({ params }: PageProps) {
116117

117118
const response = await axios.get(nurl)
118119
if (response.data && response.data.markdown) {
119-
setGuideHtml(htmlDeMd(response.data.markdown))
120+
const markdown = response.data.markdown
121+
const hasGoodDollarButton = markdown.includes('{GoodDollarButton}')
122+
setShowGoodDollarButton(hasGoodDollarButton)
123+
const mdWithoutButton = markdown.replace('{GoodDollarButton}', '')
124+
setGuideHtml(htmlDeMd(mdWithoutButton))
120125
} else if (response.data && response.data.message) {
121126
throw new Error(response.data.message)
122127
}
@@ -168,8 +173,7 @@ export default function Page({ params }: PageProps) {
168173
<div className="mt-8 pt-2 dark:bg-gray-100 dark:text-gray-800">
169174
<div className="container p-2 px-8 md:px-16 mx-auto pt-16 space-y-1">
170175
<h3 className="pb-1 text-1xl font-bold md:text-1xl text-center">
171-
{course.idioma === 'en' ? 'Course: ' : 'Curso: '}
172-
{course.titulo}
176+
{course.idioma === 'en' ? 'Course: ' : 'Curso: '}{course.titulo}
173177
</h3>
174178
</div>
175179
<h1 className="py-3 px-16 text-[2rem] font-bold text-left">
@@ -183,7 +187,7 @@ export default function Page({ params }: PageProps) {
183187
className="py-3 px-16 text-1xl md:text-1xl text-justify **:list-inside"
184188
dangerouslySetInnerHTML={{ __html: guideHtml }}
185189
/>
186-
{isClient && pathPrefix === 'gooddollar' && pathSuffix === 'guide1' && (
190+
{isClient && showGoodDollarButton && (
187191
<GoodDollarClaimButton
188192
lang={course.idioma}
189193
pathPrefix={pathPrefix}
@@ -248,7 +252,8 @@ export default function Page({ params }: PageProps) {
248252
</div>
249253

250254
<div>&nbsp;</div>
251-
</>)
255+
</>
256+
)
252257
}
253258

254259

0 commit comments

Comments
 (0)