-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI Enhancement in Contact Us- issue no - #2393 #2419
Changes from all commits
0bf9707
66aabfa
b4485c3
349fc6b
a8f54fb
2dce660
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,9 @@ const Home = () => { | |
const [suggestions, setSuggestions] = useState([]); | ||
const navigate = useNavigate(); | ||
|
||
const [isSubscribed, setIsSubscribed] = useState(false); | ||
const [email, setEmail] = useState(""); | ||
|
||
const handleSearch = (e) => { | ||
const term = e.target.value; | ||
setSearchTerm(term); | ||
|
@@ -160,6 +163,17 @@ const Home = () => { | |
sectionRef.current.scrollIntoView({ behavior: "smooth" }); | ||
}; | ||
|
||
|
||
const handleSubscribe = (e) => { | ||
e.preventDefault(); | ||
setIsSubscribed(true); // Show the success message | ||
setTimeout(() => { | ||
setIsSubscribed(false); // Hide the message | ||
setEmail(""); // Clear the email input | ||
}, 3000); // 3 seconds | ||
}; | ||
Comment on lines
+167
to
+174
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add proper form validation and error handling. The current implementation has several areas for improvement:
Consider implementing these improvements: const handleSubscribe = (e) => {
e.preventDefault();
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+ if (!email || !emailRegex.test(email)) {
+ // Show error message
+ return;
+ }
+
+ try {
+ // Add API call here
+ // await subscribeToNewsletter(email);
setIsSubscribed(true);
setTimeout(() => {
setIsSubscribed(false);
setEmail("");
- }, 3000);
+ }, process.env.REACT_APP_SUBSCRIPTION_TIMEOUT || 3000);
+ } catch (error) {
+ // Handle error
+ console.error('Subscription failed:', error);
+ }
};
|
||
|
||
|
||
return ( | ||
<div className="bg-[#fff0e3ff]"> | ||
<main className=""> | ||
|
@@ -218,12 +232,14 @@ const Home = () => { | |
</h2> | ||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3 sm:gap-4 md:gap-6"> | ||
{popularCategories.map((category, index) => ( | ||
<div key={index} className="custom-shadow"> | ||
<CategoryCard | ||
key={index} | ||
name={category.name} | ||
image={category.image} | ||
path={category.path} | ||
/> | ||
</div> | ||
Comment on lines
+235
to
+242
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix duplicate key prop and missing CSS class definition. Two issues need attention:
Apply these fixes: -<div key={index} className="custom-shadow">
- <CategoryCard
- key={index}
+<div className="custom-shadow">
+ <CategoryCard
+ key={index}
name={category.name}
image={category.image}
path={category.path}
/>
</div> Also, ensure the .custom-shadow {
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
border-radius: 0.5rem;
} |
||
))} | ||
</div> | ||
</div> | ||
|
@@ -248,6 +264,13 @@ const Home = () => { | |
</div> | ||
</div> | ||
</section> | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
{/* App Download Section */} | ||
<section | ||
className="py-8 sm:py-12 md:py-16 relative mb-[-1px]" | ||
|
@@ -286,20 +309,19 @@ const Home = () => { | |
Subscribe to our newsletter to receive exclusive updates, | ||
promotions, and tips. | ||
</p> | ||
<form> | ||
<form onSubmit={handleSubscribe}> | ||
<input | ||
type="email" | ||
placeholder="Enter your email address" | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
style={{ | ||
color: "black", | ||
width: "100%", | ||
borderRadius: "10px", | ||
padding: "10px", | ||
marginBottom: "10px", | ||
border: "1px solid #ccc", | ||
"@media (maxWidth: 780px)": { | ||
width: "80%", | ||
}, | ||
}} | ||
/> | ||
<button | ||
|
@@ -313,8 +335,13 @@ const Home = () => { | |
cursor: "pointer", | ||
}}> | ||
Subscribe | ||
</button>{" "} | ||
</button> | ||
</form> | ||
{isSubscribed && ( | ||
<div className="popup-message"> | ||
<p>Subscribed successfully!</p> | ||
</div> | ||
)} | ||
</div> | ||
</section> | ||
</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using classes instead of nth-child selectors for better maintainability.
The current implementation has several potential improvements:
Consider refactoring to use specific classes:
Then add appropriate classes (e.g.,
social-hover
) to the social media links in the JSX.