|
1 | | -import { useState } from 'react'; |
2 | | -import ContactUsFormSubscribe from '@/components/ContactUs'; |
3 | | -import ContactUsCards from '@/components/ContactUs/ContactUsCards'; |
4 | | -import styles from '@/styles/pages/contact.module.scss'; |
| 1 | +import { useRef, useState } from 'react'; |
| 2 | +import { useSearchParams } from 'next/navigation'; |
5 | 3 | import Bracket from '@/components/decorations/Bracket'; |
6 | 4 | import bracketStyles from '@/components/decorations/Bracket/Bracket.module.scss'; |
| 5 | +import ContactUsCards from '@/components/ContactUs/ContactUsCards'; |
| 6 | +import ContactUsFormSubscribe from '@/components/ContactUs'; |
| 7 | +import styles from '@/styles/pages/contact.module.scss'; |
7 | 8 | export default function ContactUs() { |
| 9 | + const subjectFilled = useRef(false); |
| 10 | + const searchParams = useSearchParams(); |
| 11 | + const subjectParam = searchParams.get('subject'); |
| 12 | + const [param, setParam] = useState(subjectParam || ''); |
8 | 13 | const [message, setMessage] = useState([]); |
9 | 14 |
|
| 15 | + function updateSubject(state, value) { |
| 16 | + subjectFilled.current = state; |
| 17 | + setParam(value); |
| 18 | + } |
| 19 | + |
| 20 | + subjectParam && !subjectFilled.current && updateSubject(true, subjectParam); |
| 21 | + !subjectParam && subjectFilled.current && updateSubject(false, ''); |
| 22 | + |
10 | 23 | return ( |
11 | 24 | <> |
12 | 25 | <div className={styles.contactUsContainer}> |
13 | 26 | <div className={styles.formWrapper}> |
14 | 27 | <div className={styles.formAndDecorations}> |
15 | 28 | <Bracket className={bracketStyles.yellowBracket} /> |
16 | | - <ContactUsFormSubscribe setMsg={setMessage} /> |
| 29 | + <ContactUsFormSubscribe |
| 30 | + key={param} |
| 31 | + subject={param} |
| 32 | + setMsg={setMessage} |
| 33 | + /> |
17 | 34 | <img |
18 | 35 | className={styles.yellowColon} |
19 | 36 | src='/images/svg/yellow-colon.svg' |
|
0 commit comments