|
| 1 | +/* eslint-disable @typescript-eslint/ban-ts-comment */ |
| 2 | +import React, { useLayoutEffect } from 'react'; |
| 3 | +import Layout from '@theme/Layout'; |
| 4 | +import LandingPageWrapper from '../../../components/LandingPageWrapper'; |
| 5 | +import useQueryParams from '../../../hooks/useQueryParams'; |
| 6 | +import Card from '../../../components/Card'; |
| 7 | +import { codeLinks } from './data'; |
| 8 | + |
| 9 | +interface ThankYouParams { |
| 10 | + m?: string; |
| 11 | + code?: string; |
| 12 | +} |
| 13 | + |
| 14 | +function alignCardHeights() { |
| 15 | + let maxHeight = -1; |
| 16 | + const cards = document.querySelectorAll<HTMLElement>('.col-card .card'); |
| 17 | + cards.forEach((el) => { |
| 18 | + if (el.offsetHeight > maxHeight) { |
| 19 | + maxHeight = el.offsetHeight; |
| 20 | + } |
| 21 | + }); |
| 22 | + |
| 23 | + cards.forEach((el) => { |
| 24 | + el.style.height = `${maxHeight}px`; |
| 25 | + }); |
| 26 | +} |
| 27 | + |
| 28 | +export default function ThankYou() { |
| 29 | + const params: ThankYouParams = useQueryParams(); |
| 30 | + |
| 31 | + useLayoutEffect(() => { |
| 32 | + // attempt this for 1 second to make it as snappy as possible |
| 33 | + const timeouts = [ |
| 34 | + setTimeout(alignCardHeights, 50), |
| 35 | + setTimeout(alignCardHeights, 100), |
| 36 | + setTimeout(alignCardHeights, 200), |
| 37 | + setTimeout(alignCardHeights, 300), |
| 38 | + setTimeout(alignCardHeights, 500), |
| 39 | + setTimeout(alignCardHeights, 600), |
| 40 | + setTimeout(alignCardHeights, 700), |
| 41 | + setTimeout(alignCardHeights, 800), |
| 42 | + setTimeout(alignCardHeights, 900), |
| 43 | + setTimeout(alignCardHeights, 1000), |
| 44 | + ]; |
| 45 | + |
| 46 | + return () => { |
| 47 | + timeouts.forEach(clearTimeout); |
| 48 | + }; |
| 49 | + }); |
| 50 | + |
| 51 | + const code = params.code; |
| 52 | + let links: typeof codeLinks.jwt[0][] = []; |
| 53 | + if (!!code) { |
| 54 | + links = codeLinks[code as keyof typeof codeLinks]; |
| 55 | + } |
| 56 | + |
| 57 | + return ( |
| 58 | + <LandingPageWrapper hasForm={false}> |
| 59 | + {/* @ts-ignore */} |
| 60 | + <Layout title="Learn to Earn with Redis!"> |
| 61 | + <article className="padding-top--md"> |
| 62 | + <div className="padding-vert--md"> |
| 63 | + <h1 |
| 64 | + style={{ |
| 65 | + textAlign: 'center', |
| 66 | + }}> |
| 67 | + Thank you! |
| 68 | + </h1> |
| 69 | + <div |
| 70 | + style={{ |
| 71 | + width: '70%', |
| 72 | + minWidth: '370px', |
| 73 | + margin: 'auto', |
| 74 | + textAlign: 'center', |
| 75 | + }}> |
| 76 | + <p>{params.m ?? 'Thank you for your submission!'}</p> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + {!!links && links.length > 0 && ( |
| 80 | + <div |
| 81 | + className="padding-vert--md" |
| 82 | + style={{ |
| 83 | + backgroundColor: 'var(--ifm-color-secondary-lightest)', |
| 84 | + }}> |
| 85 | + <h2 |
| 86 | + style={{ |
| 87 | + textAlign: 'center', |
| 88 | + }}> |
| 89 | + Continue your Redis journey |
| 90 | + </h2> |
| 91 | + <div className="container"> |
| 92 | + <div className="row"> |
| 93 | + {links.map((value) => { |
| 94 | + return ( |
| 95 | + <div key={value.heading} className="col col--4 col-card"> |
| 96 | + <Card {...value} /> |
| 97 | + </div> |
| 98 | + ); |
| 99 | + })} |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + </div> |
| 103 | + )} |
| 104 | + </article> |
| 105 | + </Layout> |
| 106 | + </LandingPageWrapper> |
| 107 | + ); |
| 108 | +} |
0 commit comments