|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import styles from './styles.module.css'; |
| 3 | + |
| 4 | +export default function Movement() { |
| 5 | + const [formData, setFormData] = useState({ |
| 6 | + email: '', |
| 7 | + socialLink: '', |
| 8 | + }); |
| 9 | + const [isSubmitted, setIsSubmitted] = useState(false); |
| 10 | + |
| 11 | + const handleInputChange = (e) => { |
| 12 | + const { name, value } = e.target; |
| 13 | + setFormData(prev => ({ |
| 14 | + ...prev, |
| 15 | + [name]: value |
| 16 | + })); |
| 17 | + }; |
| 18 | + |
| 19 | + const handleSubmit = async (e) => { |
| 20 | + e.preventDefault(); |
| 21 | + |
| 22 | + try { |
| 23 | + const response = await fetch('http://automation.riskfirst.org:8080/api/movement/submit', { |
| 24 | + method: 'POST', |
| 25 | + headers: { |
| 26 | + 'Content-Type': 'application/json', |
| 27 | + }, |
| 28 | + body: JSON.stringify(formData), |
| 29 | + }); |
| 30 | + |
| 31 | + if (response.ok) { |
| 32 | + setIsSubmitted(true); |
| 33 | + } else { |
| 34 | + console.error('Form submission failed'); |
| 35 | + alert('There was an error submitting the form. Please try again.'); |
| 36 | + } |
| 37 | + } catch (error) { |
| 38 | + console.error('Error submitting form:', error); |
| 39 | + alert('There was an error submitting the form. Please try again.'); |
| 40 | + } |
| 41 | + }; |
| 42 | + |
| 43 | + const shareLinks = { |
| 44 | + linkedin: 'https://www.linkedin.com/sharing/share-offsite/?url=' + encodeURIComponent(window.location.href), |
| 45 | + twitter: 'https://twitter.com/intent/tweet?url=' + encodeURIComponent(window.location.href) + '&text=' + encodeURIComponent('Check out Risk-First Software Development - a new way of thinking about how software really gets built!'), |
| 46 | + facebook: 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(window.location.href) |
| 47 | + }; |
| 48 | + |
| 49 | + if (isSubmitted) { |
| 50 | + return ( |
| 51 | + <section className={styles.movementSection}> |
| 52 | + <div className={styles.container}> |
| 53 | + <div className={styles.content}> |
| 54 | + <h2 className={styles.title}>Thank You! 🎉</h2> |
| 55 | + <p className={styles.message}> |
| 56 | + Thanks for helping spread the Risk-First movement! Check your email for your special discount code. |
| 57 | + </p> |
| 58 | + <button |
| 59 | + className={styles.button} |
| 60 | + onClick={() => setIsSubmitted(false)} |
| 61 | + > |
| 62 | + Share Again |
| 63 | + </button> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + </section> |
| 67 | + ); |
| 68 | + } |
| 69 | + |
| 70 | + return ( |
| 71 | + <section className={styles.movementSection}> |
| 72 | + <div className={styles.container}> |
| 73 | + <div className={styles.content}> |
| 74 | + <h2 className={styles.title}>Let's Create a Movement 🚀</h2> |
| 75 | + <div className={styles.text}> |
| 76 | + <p> |
| 77 | + Risk-First is more than just a book — it's a different way to think about how software really gets built. |
| 78 | + And movements only grow when people share them. |
| 79 | + </p> |
| 80 | + <p> |
| 81 | + Here's how you can get in on the ground floor of a new movement and help spread the word and get rewarded: |
| 82 | + </p> |
| 83 | + <ol className={styles.steps}> |
| 84 | + <li>Share this page on LinkedIn, X (Twitter), or your favorite platform.</li> |
| 85 | + <li>Fill out this quick form with your email address and a link to your post.</li> |
| 86 | + <li>Get rewarded — I'll send you a special discount code to grab a <strong>free</strong> digital copy of Risk-First Software Development, Second Edition (Beta).</li> |
| 87 | + </ol> |
| 88 | + </div> |
| 89 | + |
| 90 | + <div className={styles.shareButtons}> |
| 91 | + <a |
| 92 | + href={shareLinks.linkedin} |
| 93 | + target="_blank" |
| 94 | + rel="noopener noreferrer" |
| 95 | + className={styles.shareButton} |
| 96 | + > |
| 97 | + Share on LinkedIn |
| 98 | + </a> |
| 99 | + <a |
| 100 | + href={shareLinks.twitter} |
| 101 | + target="_blank" |
| 102 | + rel="noopener noreferrer" |
| 103 | + className={styles.shareButton} |
| 104 | + > |
| 105 | + Share on X (Twitter) |
| 106 | + </a> |
| 107 | + <a |
| 108 | + href={shareLinks.facebook} |
| 109 | + target="_blank" |
| 110 | + rel="noopener noreferrer" |
| 111 | + className={styles.shareButton} |
| 112 | + > |
| 113 | + Share on Facebook |
| 114 | + </a> |
| 115 | + </div> |
| 116 | + |
| 117 | + <form className={styles.form} onSubmit={handleSubmit}> |
| 118 | + <h3 className={styles.formTitle}>👉 Share the Page & Claim Your Free Copy</h3> |
| 119 | + |
| 120 | + <div className={styles.formGroup}> |
| 121 | + <label htmlFor="email" className={styles.label}> |
| 122 | + Email Address * |
| 123 | + </label> |
| 124 | + <input |
| 125 | + type="email" |
| 126 | + id="email" |
| 127 | + name="email" |
| 128 | + value={formData.email} |
| 129 | + onChange={handleInputChange} |
| 130 | + className={styles.input} |
| 131 | + required |
| 132 | + |
| 133 | + /> |
| 134 | + </div> |
| 135 | + |
| 136 | + <div className={styles.formGroup}> |
| 137 | + <label htmlFor="socialLink" className={styles.label}> |
| 138 | + Link to Your Post * |
| 139 | + </label> |
| 140 | + <input |
| 141 | + type="url" |
| 142 | + id="socialLink" |
| 143 | + name="socialLink" |
| 144 | + value={formData.socialLink} |
| 145 | + onChange={handleInputChange} |
| 146 | + className={styles.input} |
| 147 | + required |
| 148 | + placeholder="https://linkedin.com/posts/..." |
| 149 | + /> |
| 150 | + </div> |
| 151 | + |
| 152 | + <button type="submit" className={styles.submitButton}> |
| 153 | + Claim My Discount Code |
| 154 | + </button> |
| 155 | + </form> |
| 156 | + |
| 157 | + <p className={styles.footerText}> |
| 158 | + Together, we can build a community that puts risk where it belongs: at the center of how we understand software. |
| 159 | + </p> |
| 160 | + </div> |
| 161 | + </div> |
| 162 | + </section > |
| 163 | + ); |
| 164 | +} |
0 commit comments