diff options
| author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-01-07 01:21:06 -0700 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-01-07 01:21:06 -0700 |
| commit | db671d26c43e47b8285d319a0fd758df60d729c7 (patch) | |
| tree | 4cfc7e7b719d246637818e83feb8981255c19c67 /src/routes | |
| parent | e1905622d7d8657aa7cd5bdfe9d06e4fbe40dc70 (diff) | |
| download | mistymountainstherapy-db671d26c43e47b8285d319a0fd758df60d729c7.tar.gz mistymountainstherapy-db671d26c43e47b8285d319a0fd758df60d729c7.zip | |
initial update with nodemailer
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/contact/submit.js | 94 | ||||
| -rw-r--r-- | src/routes/index.svelte | 143 | ||||
| -rw-r--r-- | src/routes/team/index.svelte | 57 |
3 files changed, 152 insertions, 142 deletions
diff --git a/src/routes/contact/submit.js b/src/routes/contact/submit.js index da1ab59..24f4559 100644 --- a/src/routes/contact/submit.js +++ b/src/routes/contact/submit.js @@ -1,58 +1,56 @@ import 'dotenv/config'; -import sgMail from '@sendgrid/mail'; -sgMail.setApiKey(process.env.SENDGRID_API_KEY); +import { EnvMistyMountainsMailerFactory } from '$lib/utils'; export async function post({ request }) { - const body = await request.json(); - const { HCAPTCHA_SECRET, FORM_FROM_EMAIL, FORM_TO_EMAIL } = process.env; + const body = await request.json(); + const { HCAPTCHA_SECRET, FORM_TO_EMAIL } = process.env; + const mailer = EnvMistyMountainsMailerFactory(); - const captchaVerified = await fetch(`https://hcaptcha.com/siteverify?response=${body.captchaToken}&secret=${HCAPTCHA_SECRET}`, { - method: 'POST', - }) - .then((res) => res.json()) - .then((json) => json.success) - .catch(() => false); + const captchaVerified = await fetch( + `https://hcaptcha.com/siteverify?response=${body.captchaToken}&secret=${HCAPTCHA_SECRET}`, + { + method: 'POST' + } + ) + .then((res) => res.json()) + .then((json) => json.success) + .catch(() => false); - if (!captchaVerified) { - return { - statusCode: 400, - body: { - error: 'Captcha verification failed', - }, - }; - } + if (!captchaVerified) { + return { + statusCode: 400, + body: { + error: 'Captcha verification failed' + } + }; + } - const msg = { - to: FORM_TO_EMAIL, - from: FORM_FROM_EMAIL, - subject: `Form Submission from ${body.name}`, - text: ` - Name: ${body.name} - Phone Number: ${body.phone || "Not Given"} - Email: ${body.email} - Message: ${body.message} - `, - }; + const text = `Name: ${body.name} +Phone Number: ${body.phone || 'Not Given'} +Email: ${body.email} +Message: ${body.message} +`; - const messageSent = await sgMail.send(msg) - .then(() => true) - .catch((error) => { - console.error(error); - return false; - }); + const messageSent = await mailer + .sendMail(FORM_TO_EMAIL, `Form Submission from ${body.name}`, text) + .then(() => true) + .catch((error) => { + console.error(error); + return false; + }); - if (!messageSent) { - return { - statusCode: 500, - body: { - error: 'Message could not be sent', - }, - }; - } + if (!messageSent) { + return { + statusCode: 500, + body: { + error: 'Message could not be sent' + } + }; + } - return { - body: { - success: true, - }, - }; + return { + body: { + success: true + } + }; } diff --git a/src/routes/index.svelte b/src/routes/index.svelte index 55eb4ac..146dbb6 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -1,73 +1,82 @@ +<script> + import { setImageUrl } from '$lib/utils'; + import { Navigation, Pagination, Scrollbar, A11y, Autoplay } from 'swiper'; + import { Swiper, SwiperSlide } from 'swiper/svelte'; + import 'swiper/css'; + import 'swiper/css/navigation'; + import 'swiper/css/pagination'; + import 'swiper/css/scrollbar'; + import 'swiper/css/autoplay'; + + const images = [ + { image: 'mountains.png', alt: 'Cloudy mountains in a light sky' }, + { image: 'office-1-1.jpeg', alt: 'Office room one' }, + { image: 'office-1-2.jpeg', alt: 'Office room one angle two' } + ].map(setImageUrl); +</script> + <div class="row align-items-center py-2"> - <div class="col-md-7"> - <Swiper - modules={[Navigation, Pagination, Scrollbar, A11y, Autoplay]} - class="rounded shadow" - spaceBetween={50} - slidesPerView={1} - autoHeight={true} - loop={true} - navigation - pagination={{ clickable: true }} - autoplay={true} - speed={1000} - on:slideChange={() => console.log('slide change')} - on:swiper={(e) => console.log(e.detail[0])} - > - {#each images as { image, alt } (image)} - <SwiperSlide> - <img class="image-fluid" style="width:100%" src={image} alt={alt} /> - </SwiperSlide> - {/each} - </Swiper> - </div> - <div class="col-md-5 my-2"> - <h2>Helping you conquer Mount Doom</h2> - <p><a href="/contact" class="btn btn-success shadow">FREE 15 Minute Consultation</a></p> - </div> + <div class="col-md-7"> + <Swiper + modules={[Navigation, Pagination, Scrollbar, A11y, Autoplay]} + class="rounded shadow" + spaceBetween={50} + slidesPerView={1} + autoHeight={true} + loop={true} + navigation + pagination={{ clickable: true }} + autoplay={true} + speed={1000} + on:slideChange={() => console.log('slide change')} + on:swiper={(e) => console.log(e.detail[0])} + > + {#each images as { image, alt } (image)} + <SwiperSlide> + <img class="image-fluid" style="width:100%" src={image} {alt} /> + </SwiperSlide> + {/each} + </Swiper> + </div> + <div class="col-md-5 my-2"> + <h2>Helping you conquer Mount Doom</h2> + <p><a href="/contact" class="btn btn-success shadow">FREE 15 Minute Consultation</a></p> + </div> </div> <div class="bg-light rounded p-3 shadow"> - <div class="d-flex justify-content-center"> - <div class="col-md-8 mt-2 border-bottom"> - <h3>"Darkness must pass, a new day will come, and when the sun shines, it will shine out the clearer."</h3> - <div class="d-flex justify-content-end"> - - Samwise Gamgee - </div> - <br> - <p> - Misty Mountains Therapy is a privately owned, high quality, specialty therapy clinic, founded in January 2020 by Jefferson Hunt. We are dedicated to providing comprehensive therapy evaluation and treatment services to children and adults for a wide variety of disorders in the most efficient and effective manner possible in the Rexburg area. We believe that therapy should be fun, engaging, and most importantly, useful to our clients. - </p> - <p> - We are currently accepting new clients and offer a variety of services to help you live the life you desire. To find the right fit for you, schedule a <a href="/contact">free 15-minute consultation</a>. - </p> - </div> - </div> + <div class="d-flex justify-content-center"> + <div class="col-md-8 mt-2 border-bottom"> + <h3> + "Darkness must pass, a new day will come, and when the sun shines, it will shine out the + clearer." + </h3> + <div class="d-flex justify-content-end">- Samwise Gamgee</div> + <br /> + <p> + Misty Mountains Therapy is a privately owned, high quality, specialty therapy clinic, + founded in January 2020 by Jefferson Hunt. We are dedicated to providing comprehensive + therapy evaluation and treatment services to children and adults for a wide variety of + disorders in the most efficient and effective manner possible in the Rexburg area. We + believe that therapy should be fun, engaging, and most importantly, useful to our clients. + </p> + <p> + We are currently accepting new clients and offer a variety of services to help you live the + life you desire. To find the right fit for you, schedule a <a href="/contact" + >free 15-minute consultation</a + >. + </p> + </div> + </div> - <div class="d-flex justify-content-center"> - <div class="col-md-8 mt-2"> - <div> - We do not have a crisis line. If you or someone you know is in danger please call 911, visit your nearest emergency room, call the National Suicide Prevention Lifeline for free crisis counseling at <a href="tel:18002738255">(800)273-TALK</a> (8255), or text HELLO to 741-741. - </div> - </div> - </div> - <br> + <div class="d-flex justify-content-center"> + <div class="col-md-8 mt-2"> + <div> + We do not have a crisis line. If you or someone you know is in danger please call 911, visit + your nearest emergency room, call the National Suicide Prevention Lifeline for free crisis + counseling at <a href="tel:18002738255">(800)273-TALK</a> (8255), or text HELLO to 741-741. + </div> + </div> + </div> + <br /> </div> - -<script> - import { supabase } from '$lib/supabase'; - import setImageUrl from '$lib/utils'; - import { Navigation, Pagination, Scrollbar, A11y, Autoplay } from 'swiper'; - import { Swiper, SwiperSlide } from 'swiper/svelte'; - import 'swiper/css'; - import 'swiper/css/navigation'; - import 'swiper/css/pagination'; - import 'swiper/css/scrollbar'; - import 'swiper/css/autoplay'; - - const images = [ - { image: 'mountains.png', alt: 'Cloudy mountains in a light sky' }, - { image: 'office-1-1.jpeg', alt: 'Office room one' }, - { image: 'office-1-2.jpeg', alt: 'Office room one angle two' }, - ].map(setImageUrl); -</script> diff --git a/src/routes/team/index.svelte b/src/routes/team/index.svelte index 04c62b9..88e5db0 100644 --- a/src/routes/team/index.svelte +++ b/src/routes/team/index.svelte @@ -1,35 +1,38 @@ <script> - import DirectionCard from '../../components/DirectionCard.svelte'; + import DirectionCard from '../../components/DirectionCard.svelte'; - import { onMount } from 'svelte'; - import { supabase } from '$lib/supabase'; - import setImageUrl from '$lib/utils'; + import { onMount } from 'svelte'; + import { supabase } from '$lib/supabase'; + import { setImageUrl } from '$lib/utils'; - const getPeople = async () => { - const { data, error } = await supabase.from('people').select().order('id'); - if (!error) { - return data; - } - return []; - } + const getPeople = async () => { + const { data, error } = await supabase.from('people').select().order('id'); + if (!error) { + return data; + } + return []; + }; - let people = []; - onMount(async () => { - people = await getPeople().then((people) => people.map(setImageUrl)); - }); + let people = []; + onMount(async () => { + people = await getPeople().then((people) => people.map(setImageUrl)); + }); </script> <main> - <h1 class="text-center">Our Team</h1> - {#if people.length} - {#each people as person, i} - <div class="row border-bottom"> - <DirectionCard imageSpec={{image: person.image, alt: person.name}} direction={i % 2 ? 'left' : 'right'}> - <h2>{person.name}, {person.position}</h2> - <p style="white-space: pre-line">{person.bio}</p> - <a href="mailto:{person.email}"><p>{person.email}</p></a> - </DirectionCard> - </div> - {/each} - {/if} + <h1 class="text-center">Our Team</h1> + {#if people.length} + {#each people as person, i} + <div class="row border-bottom"> + <DirectionCard + imageSpec={{ image: person.image, alt: person.name }} + direction={i % 2 ? 'left' : 'right'} + > + <h2>{person.name}, {person.position}</h2> + <p style="white-space: pre-line">{person.bio}</p> + <a href="mailto:{person.email}"><p>{person.email}</p></a> + </DirectionCard> + </div> + {/each} + {/if} </main> |
