From 37ab88b65d8bfeba7fac4feec377ce47f9c0144b Mon Sep 17 00:00:00 2001 From: npcdazai Date: Mon, 14 Oct 2024 12:52:37 +0530 Subject: [PATCH] Stepper succeed --- .../ApplyForGiftCard/ApplyForGiftCard.jsx | 38 ++++++++++++--- .../ApplyForGiftCard/SelectCard.jsx | 47 ++++++++++--------- 2 files changed, 58 insertions(+), 27 deletions(-) diff --git a/src/Pages/OptiFiiGifsAndVouchers/ApplyForGiftCard/ApplyForGiftCard.jsx b/src/Pages/OptiFiiGifsAndVouchers/ApplyForGiftCard/ApplyForGiftCard.jsx index d61da36..0fb407b 100644 --- a/src/Pages/OptiFiiGifsAndVouchers/ApplyForGiftCard/ApplyForGiftCard.jsx +++ b/src/Pages/OptiFiiGifsAndVouchers/ApplyForGiftCard/ApplyForGiftCard.jsx @@ -18,12 +18,26 @@ import PrimaryButton from "../../../../src/Components/Buttons/PrimaryButton"; const Stepper = () => { const [step, setStep] = useState(1); const [selectedCardIndex, setSelectedCardIndex] = useState(null); - const [selectionCount, setSelectionCount] = useState(0); // Track selection count - const [showAnotherComponent, setShowAnotherComponent] = useState(false); // Toggle between components + const [selectionCount, setSelectionCount] = useState(0); + const [showAnotherComponent, setShowAnotherComponent] = useState(false); + const [hasProceeded, setHasProceeded] = useState(false); + + // const handleProceed = () => { + // if (selectedCardIndex !== null) { + // setHasProceeded(true); + // } else { + // alert("Please select a card before proceeding."); + // } + // }; const handleNext = () => { - if (step < steps.length) { - setStep(step + 1); + // if (step < steps.length) { + // setStep(step + 1); + // } + if (selectedCardIndex !== null) { + setHasProceeded(true); + } else { + alert("Please select a card before proceeding."); } setShowAnotherComponent(!showAnotherComponent); }; @@ -45,6 +59,8 @@ const Stepper = () => { setSelectionCount={setSelectionCount} showAnotherComponent={showAnotherComponent} setShowAnotherComponent={setShowAnotherComponent} + hasProceeded={hasProceeded} + setHasProceeded={setHasProceeded} /> ), label: "Select card type", @@ -103,9 +119,19 @@ const Stepper = () => { fontSize="xs" mb={0} fontWeight={600} - color={index + 1 === step ? "#3725EA" : index < step ? "green" : "#666666"} + color={ + index + 1 === step + ? "#3725EA" + : index < step + ? "green" + : "#666666" + } > - {index + 1 === step ? "In Progress" : index < step ? "Completed" : "Pending"} + {index + 1 === step + ? "In Progress" + : index < step + ? "Completed" + : "Pending"} diff --git a/src/Pages/OptiFiiGifsAndVouchers/ApplyForGiftCard/SelectCard.jsx b/src/Pages/OptiFiiGifsAndVouchers/ApplyForGiftCard/SelectCard.jsx index c1e23ec..0e5d8a7 100644 --- a/src/Pages/OptiFiiGifsAndVouchers/ApplyForGiftCard/SelectCard.jsx +++ b/src/Pages/OptiFiiGifsAndVouchers/ApplyForGiftCard/SelectCard.jsx @@ -1,12 +1,12 @@ import { Box, Button, Icon, Image, Text, VStack } from "@chakra-ui/react"; -import React, { useEffect, useRef } from "react"; -import VanillaTilt from "vanilla-tilt"; // Ensure this is imported +import React, { useEffect, useRef, useState } from "react"; +import VanillaTilt from "vanilla-tilt"; import mobilepng from "../../../assets/mobileCard.png"; import cardfooter from "../../../assets/cardFooter.png"; import cardfooter2 from "../../../assets/cardFooter2.png"; import cardfooter3 from "../../../assets/cardFooter3.png"; import { IoMdCheckmark } from "react-icons/io"; -import DigiTable from './DigiTable'; +import DigiTable from "./DigiTable"; import WhereToShare from "./WhereToShare"; const SelectCard = ({ @@ -14,8 +14,10 @@ const SelectCard = ({ selectedCardIndex, setSelectedCardIndex, selectionCount, - setSelectionCount, // Added selection count prop + setSelectionCount, + hasProceeded }) => { + const tiltRefs = useRef([]); const cards = [ @@ -26,6 +28,7 @@ const SelectCard = ({ "Choose a plan and get onboard in minutes. Then get $100 credits for your next payment.", image: mobilepng, img: cardfooter, + component: , }, { title: "Save More", @@ -33,6 +36,7 @@ const SelectCard = ({ description: "Choose a plan and get onboard in minutes. Then get $100 credits for your next payment.", img: cardfooter2, + component: , }, { title: "Save More", @@ -40,12 +44,13 @@ const SelectCard = ({ description: "Choose a plan and get onboard in minutes. Then get $100 credits for your next payment.", img: cardfooter3, + component: , }, ]; const handleCardClick = (index) => { setSelectedCardIndex(index); - setSelectionCount(selectionCount + 1); // Track selection count + setSelectionCount(selectionCount + 1); }; // VanillaTilt effect @@ -78,24 +83,19 @@ const SelectCard = ({ }; }, []); - const selectedCardData = [ - { - title: , // For Digital Gift Card - }, - { - title: , // For Physical Gift Card - }, - { - title: , // For Insta Gift Card - }, - ]; + return ( - {selectedCardIndex !== null ? ( - {selectedCardData[selectedCardIndex]?.title} // Show selected card content + {hasProceeded && selectedCardIndex !== null ? ( + {cards[selectedCardIndex].component} ) : ( - + {cards.map((card, index) => ( handleCardClick(index)} // Handle card selection + onClick={() => handleCardClick(index)} > {selectedCardIndex === index ? ( <> - {/* Check icon when selected */} + Selected ) : ( @@ -177,6 +177,11 @@ const SelectCard = ({ ))} )} + {/* + + */} ); };