Skip to content

Commit bf9099f

Browse files
authored
Merge pull request #296 from Web-Dev-Path/refactor/replace-mailto-links-with-contact
refactor: Replace mailto button links with contact
2 parents 6e0f22c + 7245e9c commit bf9099f

7 files changed

Lines changed: 43 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
194194
- CardsContainers
195195
- NewsletterSubscribe
196196
- Hero
197-
- Removed Styled Components dependency
197+
- Removed Styled Components dependency
198198
- Extracted :root from themes.scss to globals.scss
199199
- Updated ContactUsForm's checkbox wrapper from div to label to enhance its accessibility
200200
- Updated SearchInput width to 100% for better styling
@@ -209,3 +209,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
209209
- Fixed active state bug on the navigation.
210210
- Integrate Mailchimp Marketing API instead of react-mailchimp-subscribe dependency.
211211
- Removed unused props from Hero layout component
212+
- Replace mailto:hello@webdevpath.co button links with /contact

components/ContactUs/ContactUsForm/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import RevealContentContainer from '@/components/containers/RevealContentContain
44
import { SubmitButton } from '@/components/buttons/SubmitButton';
55
import styles from './ContactUsForm.module.scss';
66

7-
function ContactUsForm({ setResponseMessage, getReCaptchaToken }) {
7+
function ContactUsForm({ subject, setResponseMessage, getReCaptchaToken }) {
88
const {
99
register,
1010
handleSubmit,
@@ -14,7 +14,7 @@ function ContactUsForm({ setResponseMessage, getReCaptchaToken }) {
1414
defaultValues: {
1515
Name: '',
1616
Email: '',
17-
Subject: '',
17+
Subject: subject || '',
1818
Message: '',
1919
},
2020
});

components/ContactUs/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import React from 'react';
22
import ReCapchaWrapper from '../Recapcha';
33
import ContactUsForm from '@/components/ContactUs/ContactUsForm';
44

5-
const ContactUs = ({ setMsg }) => {
5+
const ContactUs = ({ subject, setMsg }) => {
66
return (
7-
<ReCapchaWrapper children={<ContactUsForm setResponseMessage={setMsg} />} />
7+
<ReCapchaWrapper
8+
children={<ContactUsForm subject={subject} setResponseMessage={setMsg} />}
9+
/>
810
);
911
};
1012

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import styles from './ButtonLink.module.scss';
2+
import Link from 'next/link';
23
import { combineClasses } from '@/utils/classnames';
34

45
export default function ButtonLink({
@@ -8,14 +9,18 @@ export default function ButtonLink({
89
openNewTab,
910
}) {
1011
const buttonClass = combineClasses(styles.buttonLink, customBtnClass, styles);
11-
return (
12+
return openNewTab ? (
1213
<a
1314
href={link}
1415
className={buttonClass}
15-
target={openNewTab ? '_blank' : undefined}
16+
target='_blank'
1617
rel='noopener noreferrer'
1718
>
1819
{children}
1920
</a>
21+
) : (
22+
<Link href={link} className={buttonClass}>
23+
{children}
24+
</Link>
2025
);
2126
}

components/layout/Nav/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,27 @@ export default function Nav() {
9090
{linksNav.map(({ text, href, id }) => {
9191
return (
9292
<li className={styles.item} key={id}>
93-
<a
93+
<Link
9494
href={href}
9595
className={`${styles.link} ${router.pathname === href ? styles.current : ''}`}
9696
title={text}
9797
>
9898
{text}
99-
</a>
99+
</Link>
100100
</li>
101101
);
102102
})}
103103
<li className={styles.item}>
104-
<a
105-
href='mailto:hello@webdevpath.co?subject=Project collaborator application'
104+
<Link
105+
href='/contact?subject=Application: I want to join the project'
106106
className={`
107107
${active ? styles.active : ''}
108108
${isSticky ? styles.buttonSticky : styles.button}
109109
`}
110110
title='Join us'
111111
>
112112
Join us
113-
</a>
113+
</Link>
114114
</li>
115115
</ul>
116116
<button

pages/about.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export default function AboutUs() {
207207
image='/images/svg/slash.svg'
208208
altTag=''
209209
customInnerClass='get-started'
210-
link='mailto:hello@webdevpath.co'
210+
link='/contact'
211211
linkText='Ping us'
212212
customBtnClass='inverted-grey'
213213
/>

pages/contact.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
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';
53
import Bracket from '@/components/decorations/Bracket';
64
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';
78
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 || '');
813
const [message, setMessage] = useState([]);
914

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+
1023
return (
1124
<>
1225
<div className={styles.contactUsContainer}>
1326
<div className={styles.formWrapper}>
1427
<div className={styles.formAndDecorations}>
1528
<Bracket className={bracketStyles.yellowBracket} />
16-
<ContactUsFormSubscribe setMsg={setMessage} />
29+
<ContactUsFormSubscribe
30+
key={param}
31+
subject={param}
32+
setMsg={setMessage}
33+
/>
1734
<img
1835
className={styles.yellowColon}
1936
src='/images/svg/yellow-colon.svg'

0 commit comments

Comments
 (0)