-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Feat incentive offers #258
Closed
Closed
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a929efc
Incenetive Offfers
dev129 e2ad349
docs(contributor): contrib-readme-action has updated readme
github-actions[bot] ead4632
Merge branch 'RamakrushnaBiswal:main' into feat-IncentiveOffers
dev129 8184d36
docs(contributor): contrib-readme-action has updated readme
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,87 @@ | ||
import React, { useEffect } from 'react'; | ||
import { RxCross1 } from "react-icons/rx"; | ||
import { useNavigate } from 'react-router-dom'; // Import useNavigate from react-router-dom | ||
|
||
const Offers = ({ isVisible, onClose }) => { | ||
const navigate = useNavigate(); // Initialize the useNavigate hook | ||
|
||
// useEffect to add/remove class to body for disabling scroll when modal is visible | ||
useEffect(() => { | ||
if (isVisible) { | ||
document.body.style.overflow = 'hidden'; | ||
} else { | ||
document.body.style.overflow = 'auto'; | ||
} | ||
return () => { | ||
document.body.style.overflow = 'auto'; | ||
}; | ||
}, [isVisible]); | ||
|
||
if (!isVisible) return null; // Modal is only visible when isVisible is true | ||
|
||
// Function to handle redirect and modal close | ||
const handleTakeMeThere = () => { | ||
onClose(); // Close the modal first | ||
navigate('/menu'); // Then navigate to /menu | ||
}; | ||
|
||
return ( | ||
<div className='fixed inset-0 bg-white bg-opacity-25 backdrop-blur-lg flex justify-center items-center z-30'> | ||
<div className='w-[600px] flex p-4 rounded-lg shadow-lg bg-white relative z-20'> | ||
|
||
{/* Close Button */} | ||
<button | ||
className="absolute top-2 right-2 text-black text-xl" | ||
onClick={() => onClose()} // onClick event to trigger onClose | ||
> | ||
<RxCross1 color='black' /> | ||
</button> | ||
|
||
{/* Modal Content in two sections */} | ||
<div className="flex flex-row w-full"> | ||
{/* Left Section: Image */} | ||
<div className="w-1/2"> | ||
<img | ||
src="https://www.leocoffee.co.in/cdn/shop/files/F0470AC5-D46D-4112-834D-7C5C1F9EF9CF.jpg?v=1673668314" | ||
alt="Offer" | ||
className="rounded-lg object-cover h-full w-full" | ||
/> | ||
</div> | ||
|
||
{/* Right Section: Text and Buttons */} | ||
<div className="w-1/2 flex flex-col justify-center px-4"> | ||
{/* Title */} | ||
<h2 className="text-2xl font-bold mb-4 text-black"> | ||
So what are you waiting for? <br /> | ||
Grab the Offer now! | ||
</h2> | ||
|
||
{/* Buttons */} | ||
<div className="flex justify-between mt-4 gap-2 "> | ||
{/* No thanks button (left) */} | ||
<button | ||
className="bg-[#f5deb3] text-black py-2 px-4 rounded-lg hover:bg-[#eed19b] transition" | ||
onClick={() => onClose()} // Close modal on No thanks | ||
> | ||
No thanks | ||
</button> | ||
|
||
{/* Yes, Take Me There button (right) */} | ||
<button | ||
className="bg-[#d2b48c] text-black py-2 px-4 rounded-lg hover:bg-[#c8a682] transition" | ||
onClick={handleTakeMeThere} // Handle both close and navigation | ||
> | ||
Take Me There | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
{/* Backdrop blur layer */} | ||
<div className='absolute inset-0 bg-black bg-opacity-50 backdrop-blur-sm z-0'></div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Offers; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 CSS classes for managing body overflow.
While the current implementation works, directly manipulating the DOM can sometimes lead to unexpected behavior, especially in more complex applications. Consider using CSS classes to manage the body overflow instead.
Here's an alternative approach using CSS classes:
This approach is more declarative and easier to maintain, especially if you need to add more styles to the body when the modal is open.