-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from Sahil-Connect/SAH-108
[SAH-108]: Dynamic Contact Form on Website
- Loading branch information
Showing
17 changed files
with
1,766 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RESEND_API_KEY= | ||
RESEND_FROM_DOMAIN_EMAIL= | ||
RESEND_REPLY_TO_EMAIL= | ||
RESEND_TO_EMAIL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use server"; | ||
import { Resend } from "resend"; | ||
import { basePartnerSchema } from "@/lib/schema"; | ||
import PartnerEmail from "@/emails/partners"; | ||
import { FormInputType } from "@/components/shared/partners/type"; | ||
import PartnerMessage from "@/emails/partner-message"; | ||
|
||
const resend = new Resend(process.env.RESEND_API_KEY) | ||
|
||
export async function sendEmail(data: FormInputType) { | ||
const result = basePartnerSchema.safeParse(data) | ||
|
||
if (result.success) { | ||
const { name, email } = result.data | ||
try { | ||
const data = await resend.emails.send({ | ||
from: `Sahil <${process.env.RESEND_FROM_DOMAIN_EMAIL}>`, | ||
to: [email], | ||
replyTo: `${process.env.RESEND_REPLY_TO_EMAIL}`, | ||
subject: 'Partnering with Sahil', | ||
text: `Name: ${name}\nEmail: ${email}`, | ||
react: PartnerEmail({ name }) | ||
}) | ||
return { success: true, data } | ||
} catch (error) { | ||
return { success: false, error } | ||
} | ||
} | ||
|
||
if (result.error) { | ||
return { success: false, error: result.error.format() } | ||
} | ||
} | ||
|
||
export async function storeUserDetails(data: FormInputType) { | ||
const result = basePartnerSchema.safeParse(data) | ||
|
||
if (result.success) { | ||
const { | ||
name, | ||
email, | ||
phoneNumber, | ||
companyName, | ||
supplyDetails, | ||
vehicleDetails | ||
} = result.data | ||
|
||
try { | ||
const data = await resend.emails.send({ | ||
from: `Sahil <${process.env.RESEND_FROM_DOMAIN_EMAIL}>`, | ||
to: `${process.env.RESEND_TO_EMAIL}`, | ||
subject: `New Partner Submission from ${name}`, | ||
react: PartnerMessage({ | ||
name, | ||
email, | ||
phoneNumber, | ||
companyName, | ||
supplyDetails, | ||
vehicleDetails | ||
}) | ||
}) | ||
return { success: true, data } | ||
} catch (error) { | ||
return { success: false, error } | ||
} | ||
} | ||
if (result.error) { | ||
return { success: false, error: result.error.format() } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { Input, PartnerTitle } from "@/components/shared"; | ||
import { HiOutlineArrowUpRight } from "react-icons/hi2"; | ||
import { PartnerBusiness, PartnerTitle } from "@/components/shared"; | ||
|
||
export const metadata = { | ||
title: "Partners - Sahil App", | ||
|
@@ -15,47 +14,7 @@ export default function BusinessesPage() { | |
title="Businesses" | ||
description="Join 100+ businesses (retailers) working with Sahil. Work with trusted suppliers to reduce costs and focus on serving your customers" | ||
/> | ||
<form> | ||
<div className="flex flex-col space-y-8"> | ||
<Input | ||
type="text" | ||
label="Name" | ||
placeholder="John Doe" | ||
required={true} | ||
/> | ||
<div className="grid md:grid-cols-2 gap-3"> | ||
<Input | ||
type="email" | ||
label="Email" | ||
placeholder="[email protected]" | ||
required={true} | ||
/> | ||
<Input | ||
type="phone" | ||
label="Phone Number (optional)" | ||
placeholder="070*****00" | ||
required={false} | ||
/> | ||
</div> | ||
<Input | ||
type="text" | ||
label="Company Name" | ||
placeholder="Sunset Restaurant" | ||
required={true} | ||
/> | ||
</div> | ||
<div className="buttonss mt-8 flex items-center md:justify-end"> | ||
<button | ||
type="submit" | ||
className="group btn btn-primary font-medium text-white rounded-full" | ||
> | ||
Submit | ||
<span className="relative group flex justify-center items-center rounded-full"> | ||
<HiOutlineArrowUpRight className="group-hover:rotate-45 transition" /> | ||
</span> | ||
</button> | ||
</div> | ||
</form> | ||
<PartnerBusiness /> | ||
</div> | ||
</> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { Input, PartnerTitle, Select } from "@/components/shared"; | ||
import { HiOutlineArrowUpRight } from "react-icons/hi2"; | ||
import { PartnerCourier, PartnerSupplier, PartnerTitle } from "@/components/shared"; | ||
|
||
export const metadata = { | ||
title: "Partners - Sahil App", | ||
|
@@ -15,44 +14,7 @@ export default function CouriersPage() { | |
title="Couriers" | ||
description="Become a courier rider at Sahil, delivery goods and packages from suppliers to businesses or directly to consumers." | ||
/> | ||
<form> | ||
<div className="flex flex-col space-y-8"> | ||
<Input | ||
type="text" | ||
label="Name" | ||
placeholder="John Doe" | ||
required={true} | ||
/> | ||
<div className="grid md:grid-cols-2 gap-3"> | ||
<Input | ||
type="email" | ||
label="Email" | ||
placeholder="[email protected]" | ||
required={true} | ||
/> | ||
<Input | ||
type="phone" | ||
label="Phone Number (optional)" | ||
placeholder="070*****00" | ||
required={false} | ||
/> | ||
</div> | ||
<Select | ||
label="Do you own a vehicle?" | ||
/> | ||
</div> | ||
<div className="buttonss mt-8 flex items-center md:justify-end"> | ||
<button | ||
type="submit" | ||
className="group btn btn-primary font-medium text-white rounded-full" | ||
> | ||
Submit | ||
<span className="relative group flex justify-center items-center rounded-full"> | ||
<HiOutlineArrowUpRight className="group-hover:rotate-45 transition" /> | ||
</span> | ||
</button> | ||
</div> | ||
</form> | ||
<PartnerCourier /> | ||
</div> | ||
</> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { Input, PartnerTitle, TextArea } from "@/components/shared"; | ||
import { HiOutlineArrowUpRight } from "react-icons/hi2"; | ||
import { PartnerCourier, PartnerSupplier, PartnerTitle } from "@/components/shared"; | ||
|
||
export const metadata = { | ||
title: "Partners - Sahil App", | ||
|
@@ -15,46 +14,7 @@ export default function SuppliersPage() { | |
title="Suppliers" | ||
description="Join 15+ suppliers (manufacturers) and expand your market reach. Access a diverse network of businesses and streamline your sales" | ||
/> | ||
<form> | ||
<div className="flex flex-col space-y-8"> | ||
<Input | ||
type="text" | ||
label="Name" | ||
placeholder="John Doe" | ||
required={true} | ||
/> | ||
<div className="grid md:grid-cols-2 gap-3"> | ||
<Input | ||
type="email" | ||
label="Email" | ||
placeholder="[email protected]" | ||
required={true} | ||
/> | ||
<Input | ||
type="phone" | ||
label="Phone Number (optional)" | ||
placeholder="070*****00" | ||
required={false} | ||
/> | ||
</div> | ||
<TextArea | ||
label="What supplies do you have?" | ||
placeholder="Crates of soft drinks, fresh vegetables..." | ||
required={true} | ||
/> | ||
</div> | ||
<div className="buttonss mt-8 flex items-center md:justify-end"> | ||
<button | ||
type="submit" | ||
className="group btn btn-primary font-medium text-white rounded-full" | ||
> | ||
Submit | ||
<span className="relative group flex justify-center items-center rounded-full"> | ||
<HiOutlineArrowUpRight className="group-hover:rotate-45 transition" /> | ||
</span> | ||
</button> | ||
</div> | ||
</form> | ||
<PartnerSupplier /> | ||
</div> | ||
</> | ||
); | ||
|
Oops, something went wrong.