Skip to content

Commit a25e6a4

Browse files
authored
Merge pull request #54 from Ankit-Kum-ar/fix/top-footer-minor-changes
fix: implement-minor-suggestion-for-better-UX
2 parents e721be3 + b69a111 commit a25e6a4

2 files changed

Lines changed: 46 additions & 13 deletions

File tree

src/components/Footer/TopFooter.jsx

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useState } from 'react';
22
import { ArrowRight } from 'lucide-react';
3+
import { Link } from 'react-router';
4+
import { toast } from 'react-toastify';
35

46
const customerCare = [
57
{ name: 'My Account', href: '/login' },
@@ -21,24 +23,41 @@ export default function TopFooter() {
2123

2224
const handleSubmit = (e) => {
2325
e.preventDefault();
24-
if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
25-
console.log('Subscribed:', email);
26-
setEmail('');
27-
} else {
28-
alert('Enter a valid email.');
26+
27+
const isValidEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.trim());
28+
29+
if (!isValidEmail) {
30+
toast.error('Please enter a valid email address.');
31+
return;
2932
}
33+
34+
// Simulate subscription success (e.g., API call here)
35+
console.log('Subscribed:', email);
36+
37+
// Show success toast notification
38+
toast.success(
39+
'Thank you for subscribing! Your email has been received. You’ll now get our latest deals and discounts.'
40+
);
41+
42+
setEmail('');
3043
};
3144

3245
return (
3346
<footer className="bg-neutral-900 text-neutral-200 px-6 py-12">
3447
<div className="max-w-7xl mx-auto grid gap-12 md:grid-cols-3">
3548
{/* Logo + Address */}
3649
<div>
37-
<img
38-
src="/images/official-logo-core-x-footer.svg"
39-
alt="CoreX"
40-
className="mb-4 w-32"
41-
/>
50+
<Link
51+
to="/"
52+
className="inline-block mb-4"
53+
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
54+
>
55+
<img
56+
src="/images/official-logo-core-x-footer.svg"
57+
alt="CoreX"
58+
className="mb-4 w-32"
59+
/>
60+
</Link>
4261
<ul className="flex space-x-2 mb-4">
4362
<li>
4463
<a
@@ -97,7 +116,7 @@ export default function TopFooter() {
97116
</a>
98117
</li>
99118
</ul>
100-
<address className="underline not-italic text-sm leading-relaxed">
119+
<address className="hover:underline cursor-pointer not-italic text-sm leading-relaxed">
101120
1234 N Main St,
102121
<br /> Chicago, IL 60607
103122
</address>
@@ -148,12 +167,12 @@ export default function TopFooter() {
148167
value={email}
149168
onChange={(e) => setEmail(e.target.value)}
150169
placeholder="Enter your email"
151-
className="flex-grow p-3 bg-neutral-800 text-neutral-200 placeholder-neutral-400 outline-none"
170+
className="flex-grow p-3 bg-neutral-800 text-neutral-200 placeholder-neutral-400 outline-none hover:bg-neutral-700 hover:ring-1 hover:ring-neutral-500 focus:ring-2 focus:ring-white transition duration-200 ease-in-out"
152171
required
153172
/>
154173
<button
155174
type="submit"
156-
className="p-3 rounded-full bg-white hover:bg-neutral-400 text-neutral-900 transition"
175+
className="p-3 rounded-full bg-white hover:bg-neutral-400 text-neutral-900 transition cursor-pointer flex items-center justify-center"
157176
aria-label="Subscribe"
158177
>
159178
<ArrowRight className="w-5 h-5 text-neutral-900" />

src/layouts/RootLayout.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Suspense } from 'react';
22
import { Outlet } from 'react-router-dom';
3+
import { ToastContainer } from 'react-toastify';
4+
import 'react-toastify/dist/ReactToastify.css';
35
import SEO from '../components/SEO';
46
import TopFooter from '../components/Footer';
57
import MainHeader from '../components/Header';
@@ -33,6 +35,18 @@ function RootLayout() {
3335
</main>
3436
<TopFooter />
3537
{/* <Footer /> */}
38+
39+
<ToastContainer
40+
position="top-right"
41+
autoClose={5000}
42+
hideProgressBar={false}
43+
newestOnTop={false}
44+
closeOnClick
45+
rtl={false}
46+
pauseOnFocusLoss
47+
draggable
48+
pauseOnHover
49+
/>
3650
</>
3751
);
3852
}

0 commit comments

Comments
 (0)