|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { IoDocumentTextOutline } from "react-icons/io5"; |
| 3 | + |
| 4 | +const FeedbackCard = () => { |
| 5 | + const [formData, setFormData] = useState({ message: '', email: '' }); |
| 6 | + |
| 7 | + const handleChange = (e: { target: { id: any; value: any; }; }) => { |
| 8 | + const { id, value } = e.target; |
| 9 | + setFormData({ ...formData, [id]: value }); |
| 10 | + }; |
| 11 | + |
| 12 | + const handleSubmit = (e: { preventDefault: () => void; }) => { |
| 13 | + e.preventDefault(); |
| 14 | + |
| 15 | + const { message, email } = formData; |
| 16 | + |
| 17 | + // Create a well-structured feedback message body |
| 18 | + const mailtoLink = `mailto:[email protected]?subject=Feedback&body=${encodeURIComponent(` |
| 19 | +Hello JiffyScan Team, |
| 20 | +
|
| 21 | +I hope you're doing well. I wanted to provide some feedback on your platform: |
| 22 | +
|
| 23 | +"${message}" |
| 24 | +
|
| 25 | +Thank you for taking the time to consider my input. Please feel free to reach out if you need more details. |
| 26 | +
|
| 27 | +Best regards, |
| 28 | +${email} |
| 29 | + `)}`; |
| 30 | + |
| 31 | + // Open user's email client with pre-filled subject, body, and email address |
| 32 | + window.location.href = mailtoLink; |
| 33 | +}; |
| 34 | + |
| 35 | + return ( |
| 36 | + <div className="m-16 mx-auto md:max-w-2xl lg:max-w-[749px] p-4"> |
| 37 | + <div className="rounded-xl border-2 lg:flex lg:items-center"> |
| 38 | + <div className="sm:w-full sm:max-w-md py-8 px-6 lg:mt-0 lg:flex-1 lg:justify-center lg:items-center space-y-2"> |
| 39 | + <p className="flex gap-2 font-inter font-medium items-center text-md sm:text-xl text-black"> |
| 40 | + <IoDocumentTextOutline /> |
| 41 | + Faced an Issue? Help us improve. |
| 42 | + </p> |
| 43 | + <form onSubmit={handleSubmit} className="space-y-4 sm:space-y-0 sm:flex sm:space-x-3"> |
| 44 | + <div className="w-full"> |
| 45 | + <label htmlFor="message" className="sr-only">Message</label> |
| 46 | + <input |
| 47 | + id="message" |
| 48 | + type="text" |
| 49 | + value={formData.message} |
| 50 | + onChange={handleChange} |
| 51 | + className="w-full md:w-[300px] lg:w-[341px] rounded-md border-1 px-5 py-3 text-black placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-700" |
| 52 | + placeholder="Write Message" |
| 53 | + required |
| 54 | + /> |
| 55 | + </div> |
| 56 | + <div className="w-full"> |
| 57 | + <label htmlFor="email" className="sr-only">Email address</label> |
| 58 | + <input |
| 59 | + id="email" |
| 60 | + type="email" |
| 61 | + value={formData.email} |
| 62 | + onChange={handleChange} |
| 63 | + className="w-full md:w-[200px] lg:w-[220px] rounded-md border-1 px-5 py-3 text-black placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-700" |
| 64 | + placeholder="Your email" |
| 65 | + required |
| 66 | + /> |
| 67 | + </div> |
| 68 | + <button |
| 69 | + type="submit" |
| 70 | + className="mt-3 flex w-full lg:w-[108px] items-center justify-center rounded-md bg-[#2c85df] px-5 py-3 text-base font-medium text-white hover:bg-gray-400 focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-700 sm:mt-0 sm:w-auto" |
| 71 | + > |
| 72 | + Send |
| 73 | + </button> |
| 74 | + </form> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + ); |
| 79 | +} |
| 80 | + |
| 81 | +export default FeedbackCard; |
0 commit comments