diff --git a/src/App.jsx b/src/App.jsx index fb174c7..47a84d3 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -15,6 +15,7 @@ import GlobalStateContext from "./Contexts/GlobalStateContext"; import Cookies from "js-cookie"; import NoInternetScreen from "./Pages/NoInternetScreen"; import OnboardingFrame from "./Pages/Onboarding/OnboardingFrame"; +import StatusCheck from "./Pages/StatusCheck/StatusCheck"; const App = () => { // const { isAuthenticate } = useSelector((state) => state?.auth); @@ -55,6 +56,9 @@ const App = () => { } /> } /> + } /> + + { const { pathname } = useLocation(); + console.log(pathname); // Remove leading slash and split path into parts const pathParts = pathname.replace(/^\//, "").split("/"); + console.log(pathParts); + // Find the current menu item based on the provided path const findMenuItem = (path) => { let menuItem = null; @@ -52,6 +55,8 @@ const CustomBreadcrumb = () => { const breadcrumbs = generateBreadcrumbs(pathParts); + console.log(breadcrumbs); + return ( { size={"xs"} as={"span"} > - Dashboard + Home {breadcrumbs.map((item, index) => ( diff --git a/src/Components/HeaderMain.jsx b/src/Components/HeaderMain.jsx index 2683ae3..26c544a 100644 --- a/src/Components/HeaderMain.jsx +++ b/src/Components/HeaderMain.jsx @@ -36,6 +36,7 @@ const HeaderMain = ({ slideDirecttion, isDrawerOpen, toggleDrawer, + blur }) => { const navigate = useNavigate(); const { colorMode, toggleColorMode } = useContext(GlobalStateContext); @@ -52,6 +53,7 @@ const HeaderMain = ({ slideDirecttion ? " ps-2" : "" } justify-content-between align-items-center`} zIndex={999} + > @@ -66,7 +68,7 @@ const HeaderMain = ({ }} src={mainLogo} alt="Logo" - onClick={() => navigate("/")} + onClick={() => !blur && navigate("/")} cursor={"pointer"} /> @@ -90,7 +92,7 @@ const HeaderMain = ({ - + {!blur&& @@ -102,9 +104,9 @@ const HeaderMain = ({ value={searchTerm} onChange={(e) => setSearchTerm(e.target.value)} /> - + } - + + - ); + + + ); }; export default OnboardingAboutCompany; - - - \ No newline at end of file diff --git a/src/Pages/Onboarding/OnboardingAddCompanyDetails.jsx b/src/Pages/Onboarding/OnboardingAddCompanyDetails.jsx index 78362dc..b70a61d 100644 --- a/src/Pages/Onboarding/OnboardingAddCompanyDetails.jsx +++ b/src/Pages/Onboarding/OnboardingAddCompanyDetails.jsx @@ -1,11 +1,40 @@ -import React, { useCallback, useState } from 'react'; -import { Box, Input, InputGroup, InputLeftElement, Select, Text, VStack, Image, HStack } from '@chakra-ui/react'; +import React from 'react'; +import { Box, Input, Text, VStack, HStack, FormLabel } from '@chakra-ui/react'; import { SlCloudUpload } from 'react-icons/sl'; +import { useForm } from 'react-hook-form'; +import { yupResolver } from '@hookform/resolvers/yup'; +import * as yup from 'yup'; +import { OPACITY_ON_LOAD } from '../../Layout/animations'; + +// Yup validation schema +const schema = yup.object().shape({ + cin: yup + .string() + .required('CIN is required') + .matches(/^[A-Za-z0-9]{21}$/, 'CIN must be exactly 21 characters long'), + pan: yup + .string() + .required('Company PAN is required') + .matches(/[A-Z]{5}[0-9]{4}[A-Z]{1}$/, 'Invalid PAN format'), + gst: yup + .string() + .required('GST number is required') + .matches(/\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}/, 'Invalid GST number format'), + // gstFile: yup.mixed().required('GST certificate is required'), + // panFile: yup.mixed().required('PAN card is required'), +}); const OnboardingAddCompanyDetails = () => { + const { register, handleSubmit, formState: { errors } } = useForm({ + resolver: yupResolver(schema), + }); + + const onSubmit = (data) => { + console.log('Form Data:', data); + }; return ( - + Add company details @@ -13,38 +42,23 @@ const OnboardingAddCompanyDetails = () => { Lorem ipsum dolor sit amet, adipiscing elit. - + {/* CIN Field */} - + CIN - + + {errors.cin && {errors.cin.message}} - {/* Industry Select Field */} - - - Company PAN - - - - - {/* Company PAN Field */} @@ -56,17 +70,35 @@ const OnboardingAddCompanyDetails = () => { borderRadius="md" fontSize={"sm"} fontWeight={500} + {...register('pan')} /> + {errors.pan && {errors.pan.message}} + + + {/* Company GST Number */} + + + Company GST number + + + {errors.gst && {errors.gst.message}} {/* Upload GST Certificate */} - Upload Pan + Upload GST Certificate document.getElementById('GST-file-input').click()} + onClick={() => document.getElementById('gst-file-input').click()} > { + {errors.gstFile && {errors.gstFile.message}} @@ -112,7 +146,7 @@ const OnboardingAddCompanyDetails = () => { {/* Upload PAN Card */} - Upload Pan + Upload PAN Card { + {errors.panFile && {errors.panFile.message}} @@ -158,6 +194,22 @@ const OnboardingAddCompanyDetails = () => { + + {/* Submit Button */} + + + Submit + + ); diff --git a/src/Pages/Onboarding/OnboardingDirectorDetails.jsx b/src/Pages/Onboarding/OnboardingDirectorDetails.jsx index d9b52c2..cf55cf4 100644 --- a/src/Pages/Onboarding/OnboardingDirectorDetails.jsx +++ b/src/Pages/Onboarding/OnboardingDirectorDetails.jsx @@ -1,17 +1,15 @@ -import React, { useCallback, useState } from 'react'; -import { Box, Input, Text, VStack, Image, HStack } from '@chakra-ui/react'; +import React, { useState } from 'react'; +import { Box, Input, Text, VStack, HStack } from '@chakra-ui/react'; import { SlCloudUpload } from 'react-icons/sl'; import PhoneInput from 'react-phone-input-2'; const OnboardingDirectorDetails = () => { - - const [phone, setPhone] = useState(""); - - // Initial state for director forms const [directorForms, setDirectorForms] = useState([ { id: 1, directorName: '', directorEmail: '', directorPhone: '', selectedPanImage: '', selectedAadharImage: '' } ]); + const [directorFormErrors, setDirectorFormErrors] = useState([]); + // Add new director form const handleAddDirector = () => { setDirectorForms([ @@ -20,6 +18,67 @@ const OnboardingDirectorDetails = () => { ]); }; + // Update the form field for a particular director + const handleFieldChange = (index, field, value) => { + const updatedForms = [...directorForms]; + updatedForms[index][field] = value; + setDirectorForms(updatedForms); + }; + + // Handle file upload for PAN and Aadhar + const handleFileUpload = (index, field, event) => { + const file = event.target.files[0]; + if (file) { + const updatedForms = [...directorForms]; + updatedForms[index][field] = file.name; // Store file name (or file object) + setDirectorForms(updatedForms); + } + }; + + // Basic validation for each field + const validateForm = () => { + const errors = directorForms.map((directorForm) => { + let formErrors = {}; + + if (!directorForm.directorName) { + formErrors.directorName = "Director Name is required."; + } + + if (!directorForm.directorEmail || !/\S+@\S+\.\S+/.test(directorForm.directorEmail)) { + formErrors.directorEmail = "Please enter a valid email address."; + } + + if (!directorForm.directorPhone || directorForm.directorPhone.length < 10) { + formErrors.directorPhone = "Phone number is required and should be at least 10 digits."; + } + + if (!directorForm.selectedPanImage) { + formErrors.selectedPanImage = "Please upload a PAN file."; + } + + if (!directorForm.selectedAadharImage) { + formErrors.selectedAadharImage = "Please upload an Aadhar file."; + } + + return formErrors; + }); + + setDirectorFormErrors(errors); + + // Check if all forms are valid (no errors in any form) + const isValid = errors.every((formErrors) => Object.keys(formErrors).length === 0); + return isValid; + }; + + // Handle form submission + const handleSubmit = () => { + if (validateForm()) { + console.log("Form is valid, proceed with submission."); + } else { + console.log("Form has errors."); + } + }; + return ( @@ -53,10 +112,13 @@ const OnboardingDirectorDetails = () => { fontSize={"sm"} fontWeight={500} bg={"#fff"} - placeholder={directorForm.directorNamePlaceholder || " "} + placeholder="Enter director name" value={directorForm.directorName} - onChange={(e) => directorForm.setDirectorName(e.target.value)} + onChange={(e) => handleFieldChange(index, 'directorName', e.target.value)} /> + {directorFormErrors[index]?.directorName && ( + {directorFormErrors[index].directorName} + )} {/* Director Email Field */} @@ -71,10 +133,13 @@ const OnboardingDirectorDetails = () => { fontSize={"sm"} fontWeight={500} bg={"#fff"} - placeholder={directorForm.directorEmailPlaceholder || " "} + placeholder="Enter email" value={directorForm.directorEmail} - onChange={(e) => directorForm.setDirectorEmail(e.target.value)} + onChange={(e) => handleFieldChange(index, 'directorEmail', e.target.value)} /> + {directorFormErrors[index]?.directorEmail && ( + {directorFormErrors[index].directorEmail} + )} {/* Director Phone Number */} @@ -88,9 +153,9 @@ const OnboardingDirectorDetails = () => { Phone Number directorForm.setDirectorPhone(value)} + onChange={(value) => handleFieldChange(index, 'directorPhone', value)} inputStyle={{ width: "100%", borderRadius: "md", @@ -104,6 +169,9 @@ const OnboardingDirectorDetails = () => { backgroundColor: "transparent", }} /> + {directorFormErrors[index]?.directorPhone && ( + {directorFormErrors[index].directorPhone} + )} {/* Upload Pan */} @@ -113,7 +181,7 @@ const OnboardingDirectorDetails = () => { document.getElementById('pan-file-input').click()} + onClick={() => document.getElementById(`pan-file-input-${index}`).click()} > { mt={'2'} mb={0} > - Drag and drop files here or{' '} - - Choose file - + {directorForm.selectedPanImage || "Drag and drop files here or Choose file"} handleFileUpload(index, 'selectedPanImage', e)} /> - - - - Supported formats- jpg, png, svg - - - Maximum size - 20MB - - + {directorFormErrors[index]?.selectedPanImage && ( + {directorFormErrors[index].selectedPanImage} + )} - {/* Upload Aadhar Card */} + {/* Upload Aadhar */} Upload Aadhar document.getElementById('aadhar-file-input').click()} + onClick={() => document.getElementById(`aadhar-file-input-${index}`).click()} > { mt={'2'} mb={0} > - Drag and drop files here or{' '} - - Choose file - + {directorForm.selectedAadharImage || "Drag and drop files here or Choose file"} handleFileUpload(index, 'selectedAadharImage', e)} /> - - - - Supported formats- jpg, png, svg - - - Maximum size - 20MB - - + {directorFormErrors[index]?.selectedAadharImage && ( + {directorFormErrors[index].selectedAadharImage} + )} @@ -217,7 +269,22 @@ const OnboardingDirectorDetails = () => { cursor="pointer" onClick={() => handleAddDirector()} > - + Add director 2 + + Add director {directorForms.length + 1} + + + + + handleSubmit()} + > + Submit diff --git a/src/Pages/Onboarding/OnboardingFrame.jsx b/src/Pages/Onboarding/OnboardingFrame.jsx index 5bdea71..ea65bd0 100644 --- a/src/Pages/Onboarding/OnboardingFrame.jsx +++ b/src/Pages/Onboarding/OnboardingFrame.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Box, Text, Stepper, Step, StepIndicator, StepStatus, StepSeparator, useSteps, StepIcon, StepTitle, Divider, Button, HStack, IconButton, Flex, @@ -15,8 +15,38 @@ import OnboardingDirectorDetails from './OnboardingDirectorDetails'; import OnboardingSelectPackage from './OnboardingSelectPackage'; import OnboardingSelectPackageModal from './OnboardingSelectPackageModal'; // Import your modal component import { OPACITY_ON_LOAD } from '../../Layout/animations'; +import { useSearchParams } from 'react-router-dom'; + + +// Retrieve the active step from localStorage or set it to 0 if it doesn't exist +const initialStep = parseInt(localStorage.getItem("activeStep")) || 0; const OnboardingFrame = () => { + + // Create a searchParams instance + const [searchParams] = useSearchParams(); + const [ corpData, setCorpData ] = useState({}) + + useEffect(() => { + // Extract specific parameters + if (searchParams) { + const codeCorporate = searchParams.get("code_corporate"); + const codeCorporateId = searchParams.get("code_corporateId"); + localStorage?.setItem('codeCorporate', codeCorporate) + localStorage?.setItem('codeCorporateId', codeCorporateId) + } + }, [searchParams]) + + useEffect(() => { + localStorage.setItem("corpData", JSON.stringify(corpData)); + console.log(corpData); + }, [corpData]) + + // Modal state and disclosure hook + const { isOpen, onOpen, onClose } = useDisclosure(); + + + const steps = [ { title: 'Your details', description: 'Lorem ipsum dolor sit amet dolor', icon: FaUser }, { title: 'About Company', description: 'Lorem ipsum dolor sit amet dolor', icon: FaBuilding }, @@ -25,34 +55,40 @@ const OnboardingFrame = () => { { title: 'Select package', description: 'Lorem ipsum dolor sit amet dolor', icon: FaBoxOpen }, ]; - // Stepper configuration - const { activeStep, setActiveStep } = useSteps({ - index: 0, // Initialize the active step at 0 - count: steps.length, - }); + +// Stepper configuration +const { activeStep, setActiveStep } = useSteps({ + index: initialStep, // Initialize the active step from localStorage or 0 + count: steps.length, + }); + +// Function to handle the "Next" button click +const handleNext = () => { + if (activeStep === steps.length - 1) { + // If it's the last step, open the modal + onOpen(); + } else { + // Otherwise, go to the next step + const nextStep = activeStep + 1; + setActiveStep(nextStep); + + // Store the new active step in localStorage + localStorage.setItem("activeStep", nextStep); + } + }; + + // Array of components for each step const stepComponents = [ - , - , - , - , - + , + , + , + , + ]; - // Modal state and disclosure hook - const { isOpen, onOpen, onClose } = useDisclosure(); - - // Function to handle the "Next" button click - const handleNext = () => { - if (activeStep === steps.length - 1) { - // If it's the last step, open the modal - onOpen(); - } else { - // Otherwise, go to the next step - setActiveStep(activeStep + 1); - } - }; + return ( @@ -174,7 +210,7 @@ const OnboardingFrame = () => { {/* Render the current step component */} {stepComponents[activeStep]} - + {/* } @@ -201,7 +237,7 @@ const OnboardingFrame = () => { > {activeStep === steps.length - 1 ? 'Next step' : 'Next step'} - + */} diff --git a/src/Pages/Onboarding/OnboardingSelectPackageModalChild.jsx b/src/Pages/Onboarding/OnboardingSelectPackageModalChild.jsx index 3c0dc36..fa7a2fa 100644 --- a/src/Pages/Onboarding/OnboardingSelectPackageModalChild.jsx +++ b/src/Pages/Onboarding/OnboardingSelectPackageModalChild.jsx @@ -1,9 +1,10 @@ -import React from 'react'; +import React, { useState } from 'react'; import { Box, HStack, Text, Modal, ModalOverlay, ModalHeader, ModalCloseButton, ModalBody, ModalContent,Button } from '@chakra-ui/react'; import { motion } from 'framer-motion'; import PrimaryButton from '../../Components/Buttons/PrimaryButton'; +import { useNavigate } from 'react-router-dom'; // Define motion components const MotionBox = motion(Box); @@ -12,7 +13,19 @@ const MotionCircle = motion.circle; const MotionPolyline = motion.polyline; const OnboardingSelectPackageModalChild = ({isOpen,onClose}) => { + const navigate = useNavigate() + const [ isLoading, setIsLoading ] = useState(false) + + const handleCheckMyStatus = () => { + setIsLoading(true); // Set loading state + + // 3-second delay before navigating + setTimeout(() => { + navigate('/status-check'); + setIsLoading(false); // Reset loading state after navigation + }, 3000); + }; return ( <> @@ -88,7 +101,7 @@ const OnboardingSelectPackageModalChild = ({isOpen,onClose}) => { - + diff --git a/src/Pages/Onboarding/OnboardingYourDetails.jsx b/src/Pages/Onboarding/OnboardingYourDetails.jsx index de83661..e2852d0 100644 --- a/src/Pages/Onboarding/OnboardingYourDetails.jsx +++ b/src/Pages/Onboarding/OnboardingYourDetails.jsx @@ -1,103 +1,194 @@ -import React, { useState } from 'react'; -import { Box, Container, HStack, Image, Input, InputGroup, InputLeftElement, Text } from '@chakra-ui/react'; +import React, { useState } from "react"; +import { + Box, + Container, + HStack, + Image, + Input, + InputGroup, + InputLeftElement, + Text, + Button, + IconButton, + FormLabel, + FormControl, + FormErrorMessage, +} from "@chakra-ui/react"; import { CiUser, CiMail } from "react-icons/ci"; -import optifii_logo from '../../assets/optifii_logo.svg'; +import optifii_logo from "../../assets/optifii_logo.svg"; import PhoneInput from "react-phone-input-2"; import "react-phone-input-2/lib/style.css"; +import { useForm } from "react-hook-form"; +import * as Yup from "yup"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { ArrowBackIcon, ArrowForwardIcon } from "@chakra-ui/icons"; +import { OPACITY_ON_LOAD } from "../../Layout/animations"; +// Validation schema using Yup +const validationSchema = Yup.object().shape({ + full_name_principal: Yup.string().required("Name is required"), + emailAddress_principal: Yup.string() + .email("Invalid email format") + .required("Email is required"), + mobileNumber_principal: Yup.string() + .matches(/^\d{10}$/, "Phone number must be 10 digits") + .required("Phone number is required"), +}); -const OnboardingYourDetails = () => { +const OnboardingYourDetails = ({ + corpData, + setCorpData, + setActiveStep, + activeStep, + steps, + handleNext, +}) => { + const [phone, setPhone] = useState(""); - const [phone, setPhone] = useState(""); + const handlePhoneChange = (value, country) => { + const countryCode = `+${country.dialCode}`; + let numberWithoutISD = value; - return ( + setPhone(numberWithoutISD); + setValue( + "mobileNumber_principal", + value + .split("") + .splice(countryCode.length - 1, 15) + .join("") + ); // Sync phone number + setValue("ISDCode_principal", countryCode); // Sync ISD code + }; - - - - - - Streamlined Solutions for Seamless Reimbursements! - - - Add your details - - - Lorem ipsum dolor sit amet, adipiscing elit. - + // Setup form handling with react-hook-form + const { + register, + handleSubmit, + setValue, + formState: { errors }, + } = useForm({ + resolver: yupResolver(validationSchema), + }); - {/* Form Fields */} - - - - Name - - - - - - - - - - - Email - - - - - - - - - - - Phone Number - + // Handle form submission + const onSubmit = (data) => { + setCorpData({...corpData, ...data}) + handleNext() + // Handle your submit logic here + }; - - + return ( + + + + + + Streamlined Solutions for Seamless Reimbursements! + + + Add your details + + + Lorem ipsum dolor sit amet, adipiscing elit. + - - + {/* Form Fields */} + + + + Name + + + + + + + + {errors.full_name_principal?.message} + + + + + + Email + + + + + + + + {errors.emailAddress_principal?.message} + + + + + + Phone Number + - ); + + + {errors.mobileNumber_principal?.message} + + + + + } + variant="outline" + size="sm" + px={8} + _hover={{ opacity: 0.8 }} + color={"#d0b8ef"} + border={"1px solid #d0b8ef"} + isDisabled={activeStep === 0} + onClick={() => setActiveStep(activeStep - 1)} + /> + + + + + + ); }; export default OnboardingYourDetails; diff --git a/src/Pages/OptiFiiGifsAndVouchers/GiftDashboard.jsx b/src/Pages/OptiFiiGifsAndVouchers/GiftDashboard.jsx new file mode 100644 index 0000000..76d1375 --- /dev/null +++ b/src/Pages/OptiFiiGifsAndVouchers/GiftDashboard.jsx @@ -0,0 +1,12 @@ +import { Box } from '@chakra-ui/react' +import { OPACITY_ON_LOAD } from '../../Layout/animations' + +const GiftDashboard = () => { + return ( + + GiftDashboard + + ) +} + +export default GiftDashboard \ No newline at end of file diff --git a/src/Pages/StatusCheck/StatusCheck.jsx b/src/Pages/StatusCheck/StatusCheck.jsx new file mode 100644 index 0000000..b666565 --- /dev/null +++ b/src/Pages/StatusCheck/StatusCheck.jsx @@ -0,0 +1,452 @@ +import React, { useContext, useEffect, useState } from "react"; +import logo from "../../assets/logo2.png"; +import logoDark from "../../assets/logo.png"; +import logoMini from "../../assets/logo-min.png"; +import logoMiniDark from "../../assets/favicon.png"; +import { useDispatch } from "react-redux"; +import { loginUser } from "../../Redux/Slice/auth"; +// import Button02 from "../Components/Buttons/Button02"; +import { + TbArrowBadgeLeftFilled, + TbBriefcase, + TbBuildingBank, + TbListDetails, + TbReportMoney, + TbTransactionDollar, +} from "react-icons/tb"; +import { TbArrowBadgeRightFilled } from "react-icons/tb"; +import { AddIcon, ArrowBackIcon, ArrowLeftIcon, ArrowRightIcon } from "@chakra-ui/icons"; +import { + Link, + Route, + Routes, + useLocation, + useNavigate, +} from "react-router-dom"; +import { RouteLink } from "../../Routes/Routes"; +import NotFound from "../../Pages/NotFound"; +import { nav } from "../../Routes/Nav"; +import { + Box, + Text, + Accordion, + AccordionItem, + AccordionButton, + AccordionIcon, + AccordionPanel, + Image, + Alert, + AlertIcon, + VStack, + HStack, + Icon, +} from "@chakra-ui/react"; +import GlobalStateContext from "../../Contexts/GlobalStateContext"; +import Cookies from "js-cookie"; // Import the Cookies library +import HeaderMain from "../../Components/HeaderMain"; +import SplashScreen from "../../Pages/SplashScreen"; +import CustomBreadcrumb from "../../Components/CutomBreadcrumb"; +import compLogo from "../../assets/complogo.svg"; +import { OPACITY_ON_LOAD } from "../../Layout/animations"; +import MiniHeader from "../../Components/MiniHeader"; +import { RiUser2Line } from "react-icons/ri"; + +const StatusCheck = ({ isOnline = true }) => { + const navigate = useNavigate(); + const location = useLocation(); + const [isDrawerOpen, setIsDrawerOpen] = useState(true); + const { setIsAuthenticate } = useContext(GlobalStateContext); + const [isSplashVisible, setSplashVisible] = useState(true); + const [openIndex, setOpenIndex] = useState(null); + + useEffect(() => { + const savedIndex = localStorage.getItem("openAccordionIndex"); + if (savedIndex !== null) { + setOpenIndex(parseInt(savedIndex)); + } + }, []); + + const handleAccordionChange = (index) => { + const newIndex = openIndex === index ? null : index; + setOpenIndex(newIndex); + localStorage.setItem("openAccordionIndex", newIndex); + }; + + useEffect(() => { + // Set a timer to hide the splash screen after 3 seconds + const timer = setTimeout(() => { + setSplashVisible(false); + }, 1000); // 3000ms = 3 seconds + + // Cleanup the timer + return () => clearTimeout(timer); + }, []); + + const toggleDrawer = () => { + setIsDrawerOpen(!isDrawerOpen); + }; + + const logOutHandler = () => { + // dispach(loginUser(false)); + setIsAuthenticate(false); + Cookies.remove("isAuthenticated"); + localStorage.removeItem("refreshToken"); + localStorage.removeItem("accessToken"); + localStorage.removeItem("refreshTokenExp"); + navigate("/login"); + }; + + if (isSplashVisible) { + return ; + } + + return ( + + + + + + No Internet ! + + + + + + + + Website Developers India Pvt Ltd + + + + {nav.map( + ({ title, type, Icon, submenu, path, colorCode }, index) => { + if (type === "accordion") { + return ( + + + + {/* {Icon && title === "Admin" ? : } */} + {Icon && ( + + )} + + {title} + + + + + + {submenu?.map( + ( + { + title: subMenuTitle, + path: link, + icon: SubIcon, + colorCode, + }, + i + ) => ( + + + {SubIcon && ( + + )} + + {subMenuTitle} + + + + ) + )} + + + ); + } else if (type === "title") { + return ( + + {title} + + ); + } else if (type === "single") { + return ( + + {Icon && } + + {title} + + + ); + } else { + return null; + } + } + )} + + + + + + + + + + + + You’ve successfully submitted details + + + Out team will review your details , wait for the + verification of documents + + + + + Progress Details : + + + + + + + + + Bank Details + + + (Under review) + + + + + + + + Bank Details + + + (Under review) + + + + + + + + + Business Details + + + (Under review) + + + + + + + + + + + + + + + + + + + + ); +}; + +export default StatusCheck; + +const AppContent = () => { + return ( + + {RouteLink.map(({ path, Component }, index) => ( + } /> + ))} + } /> + + ); +}; diff --git a/src/Routes/Nav.js b/src/Routes/Nav.js index cf29e4f..83596d0 100644 --- a/src/Routes/Nav.js +++ b/src/Routes/Nav.js @@ -106,7 +106,7 @@ export const nav = [ submenu: [ { title: "Dashboard", - path: "/optiFii-expense-dashboard", + path: "/optifii-gifts-dashboard", colorCode:"#70a1ff" }, { diff --git a/src/Routes/Routes.js b/src/Routes/Routes.js index 1133010..336e7bd 100644 --- a/src/Routes/Routes.js +++ b/src/Routes/Routes.js @@ -18,6 +18,7 @@ import Roles from "../Pages/ManageHumanResource/ManageDepartmentAndRoles/Roles"; import OptiFiiExpenseDashboard from "../Pages/OptiFiiExpense/OptiFiiExpenseDashboard"; import GiftCard from "../Pages/OptiFiiGifsAndVouchers/GiftCard"; import ApplicationStatus from "../Pages/OptiFiiGifsAndVouchers/id/ApplicationStatus"; +import GiftDashboard from "../Pages/OptiFiiGifsAndVouchers/GiftDashboard"; export const RouteLink = [ { path: "/", Component: Dashbaord }, { path: "/expenses", Component: Expenses }, @@ -39,4 +40,12 @@ export const RouteLink = [ { path: "/optiFii-expense-dashboard", Component: OptiFiiExpenseDashboard }, { path: "/gift-card", Component: GiftCard }, { path: "/application-status", Component: ApplicationStatus }, + + + + + // =======================[ Gift Voucher ]============== + { path: "/optifii-gifts-dashboard", Component: GiftDashboard }, + + ]; diff --git a/src/Services/Key.merits.service.js b/src/Services/Key.merits.service.js deleted file mode 100644 index eab78ae..0000000 --- a/src/Services/Key.merits.service.js +++ /dev/null @@ -1,26 +0,0 @@ -// io.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = api?.defaults.baseURL; - -export const keyMerits = createApi({ - reducerPath: "ioService", - baseQuery: baseQuery, - tagTypes: ["getKeyMerits"], - endpoints: (builder) => ({ - // =====[get] - getKeyMerits: builder.query({ - query: (id) => `/io/admin/key-merits/${id}`, - providesTags: ["getKeyMerits"], - }), - - }), -}); - -// Export hooks for usage in functional components -export const { - useGetKeyMeritsQuery, -} = -keyMerits; diff --git a/src/Services/bank.details.service.js b/src/Services/bank.details.service.js deleted file mode 100644 index ad2cf57..0000000 --- a/src/Services/bank.details.service.js +++ /dev/null @@ -1,37 +0,0 @@ -// investorDetails.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = api?.defaults.baseURL; - -// Define a service using a base URL and expected endpoints -export const bankDetails = createApi({ - reducerPath: "bankDetails", - baseQuery: baseQuery, - tagTypes: ["getBank"], - - endpoints: (builder) => ({ - - getBank: builder.query({ - query: ({ page, size }) => - `/bankDetails/admin/?page=${page}&size=${size}`, - providesTags: ["getBank"], - }), - - // ========[Update Sponser]======== - - updateBankDetails: builder.mutation({ - query: ({ data, id }) => ({ - url: `/bankDetails/admin/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getBank"], - }), - - }), -}); - -// Export hooks for usage in functional components -export const { useGetBankQuery,useUpdateBankDetailsMutation } = bankDetails; diff --git a/src/Services/contact.service.js b/src/Services/contact.service.js deleted file mode 100644 index 241c657..0000000 --- a/src/Services/contact.service.js +++ /dev/null @@ -1,37 +0,0 @@ -// investorDetails.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = api?.defaults.baseURL; - -// Define a service using a base URL and expected endpoints -export const contact = createApi({ - reducerPath: "contact", - baseQuery: baseQuery, - tagTypes: ["getContact"], - endpoints: (builder) => ({ - - getContact: builder.query({ - query: () => - `/contactDetails/admin`, - providesTags: ["getContact"], - }), - - - // ========[Update Investment]======= - - updateContact: builder.mutation({ - query: (data) => ({ - url: `/contactDetails/admin/`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getContact"], - }), - - }), -}); - -// Export hooks for usage in functional components -export const { useGetContactQuery, useUpdateContactMutation } = contact; diff --git a/src/Services/deposit.request.service.js b/src/Services/deposit.request.service.js deleted file mode 100644 index 2d5ce13..0000000 --- a/src/Services/deposit.request.service.js +++ /dev/null @@ -1,55 +0,0 @@ -// investorDetails.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = api?.defaults.baseURL; - -// Define a service using a base URL and expected endpoints -export const depositRequest = createApi({ - reducerPath: "depositRequest", - baseQuery: baseQuery, - tagTypes: ["getDepositRequest", "getDepositHistory"], - endpoints: (builder) => ({ - getDepositRequest: builder.query({ - query: () => `/deposit/admin/pending-requests`, - providesTags: ["getDepositRequest"], - }), - - getDepositRequestById: builder.query({ - query: (id) => `/deposit/admin/getById/${id}`, - }), - - updateDepositRequest: builder.mutation({ - query: ({ id, data }) => ({ - url: `/deposit/admin/approved/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getDepositRequest", "getDepositHistory"], - }), - - depositReject: builder.mutation({ - query: ({ id, data }) => ({ - url: `/deposit/admin/rejected/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getDepositRequest", "getDepositHistory"], - }), - - getDepositHistory: builder.query({ - query: () => `/deposit/admin/history`, - providesTags: ["getDepositHistory"], - }), - }), -}); - -// Export hooks for usage in functional components -export const { - useGetDepositRequestQuery, - useGetDepositRequestByIdQuery, - useUpdateDepositRequestMutation, - useDepositRejectMutation, - useGetDepositHistoryQuery, -} = depositRequest; diff --git a/src/Services/exchange.rate.service.js b/src/Services/exchange.rate.service.js deleted file mode 100644 index 7ad2095..0000000 --- a/src/Services/exchange.rate.service.js +++ /dev/null @@ -1,51 +0,0 @@ -// exchangeRate.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = api?.defaults.baseURL; - -// Define a service using a base URL and expected endpoints -export const exchangeRate = createApi({ - reducerPath: "exchangeRate", - baseQuery: baseQuery, - tagTypes: ["getAllExchangeRate", "getExchangeById"], - - endpoints: (builder) => ({ - getAllExchangeRates: builder.query({ - query: ({ page, size }) => - `/currencyExchange/admin?page=${page}&size=${size}`, - providesTags: ["getAllExchangeRate"], - }), - - getExchangeRateById: builder.query({ - query: (id) => `/currencyExchange/admin/${id}`, - providesTags: ["getAllExchangeRate"], - }), - - updateExchangeRate: builder.mutation({ - query: ({ data, id }) => ({ - url: `/currencyExchange/admin/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getAllExchangeRate"], - }), - - getCurrencyHistoryById: builder.query({ - query: (id) => `/currencyExchange/admin/history/${id}`, - providesTags: ["getAllExchangeRate"], - }), - - - - }), -}); - -// Export hooks for usage in functional components -export const { - useGetAllExchangeRatesQuery, - useGetExchangeRateByIdQuery, - useUpdateExchangeRateMutation, - useGetCurrencyHistoryByIdQuery, -} = exchangeRate; diff --git a/src/Services/investment.documents.service.js b/src/Services/investment.documents.service.js deleted file mode 100644 index 5577221..0000000 --- a/src/Services/investment.documents.service.js +++ /dev/null @@ -1,61 +0,0 @@ -// io.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = api?.defaults.baseURL; - -export const ioService = createApi({ - reducerPath: "ioService", - baseQuery: baseQuery, - tagTypes: ["getInvestmentDocuments"], - - - - endpoints: (builder) => ({ - // =====[get] - getInvestmentDocuments: builder.query({ - query: ({id}) => `/io/admin/document/${id}`, - providesTags: ["getInvestmentDocuments"], - }), - - - - - - - // =====[create] - createInvestmentDocuments: builder.mutation({ - query: ({data, id}) => ({ - url: `/io/admin/document/${id}`, - method: "POST", - body: data, - }), - - invalidatesTags: ["getInvestmentDocuments"], - }), - - - - updateIO: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getInvestmentDocuments"], - }), - - - - - - - }), -}); - -// Export hooks for usage in functional components -export const { - useCreateInvestmentDocumentsMutation, -} = - ioService; diff --git a/src/Services/investment.type.service.js b/src/Services/investment.type.service.js deleted file mode 100644 index ffdd0dc..0000000 --- a/src/Services/investment.type.service.js +++ /dev/null @@ -1,72 +0,0 @@ -// investmentType.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = api?.defaults.baseURL; - -// Define a service using a base URL and expected endpoints -export const investmentType = createApi({ - reducerPath: "investmentType", - baseQuery: baseQuery, - tagTypes: ["getInvestmentType", "getInvestmentTypeID"], - endpoints: (builder) => ({ - - // ========[Get All]========= - - getInvestmentTypes: builder.query({ - query: ({ page, size }) => - `/investmentType/admin?page=${page}&size=${size}`, - providesTags: ["getInvestmentType"], - }), - - // ========[Get ID]========= - - getInvestmentTypeById: builder.query({ - query: (id) => `/investmentType/admin/${id}`, - providesTags: ["getInvestmentTypeID"], - }), - - // ========[Create Investment]======== - - createInvestmentType: builder.mutation({ - query: (data) => ({ - url: `/investmentType/admin/`, - method: "POST", - body: data, - }), - invalidatesTags: ["getInvestmentType"], - }), - - // ========[Update Investment]======= - - updateInvestmentType: builder.mutation({ - query: ({ data, id }) => ({ - url: `/investmentType/admin/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getInvestmentTypeID", "getInvestmentType"], - }), - - // ========[Delete Investment]======= - - deleteInvestmentType: builder.mutation({ - query: (id) => ({ - url: `/investmentType/admin/delete/${id}`, - method: "DELETE", - }), - invalidatesTags: ["getInvestmentType"], - }), - - }), -}); - -// Export hooks for usage in functional components -export const { - useGetInvestmentTypesQuery, - useGetInvestmentTypeByIdQuery, - useCreateInvestmentTypeMutation, - useUpdateInvestmentTypeMutation, - useDeleteInvestmentTypeMutation, -} = investmentType; diff --git a/src/Services/investor.details.service.js b/src/Services/investor.details.service.js deleted file mode 100644 index a214abe..0000000 --- a/src/Services/investor.details.service.js +++ /dev/null @@ -1,33 +0,0 @@ -// investorDetails.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = api?.defaults.baseURL; - -// Define a service using a base URL and expected endpoints -export const investorDetails = createApi({ - reducerPath: "investorDetails", - baseQuery: baseQuery, - tagTypes: [], - endpoints: (builder) => ({ - - getInvestors: builder.query({ - query: ({ page, size }) => - `/investorDetails/admin?page=${page}&size=${size}`, - providesTags: ["getInvestors"], - }), - - - // =====[get investment details ] - getInvestorsDetailsById: builder.query({ - query: (id) => `/investorDetails/admin/${id}`, - providesTags: ["getInvestors"], - }), - - - }), -}); - -// Export hooks for usage in functional components -export const { useGetInvestorsQuery, useGetInvestorsDetailsByIdQuery } = investorDetails; diff --git a/src/Services/investor.transaction.service.js b/src/Services/investor.transaction.service.js deleted file mode 100644 index 8277f26..0000000 --- a/src/Services/investor.transaction.service.js +++ /dev/null @@ -1,23 +0,0 @@ -// investorTransaction.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = import.meta.env.VITE_API_BASE_URL + "/api"; - -// Define a service using a base URL and expected endpoints -export const investorTransaction = createApi({ - reducerPath: "investorTransaction", - baseQuery: baseQuery, - tagTypes: [], - endpoints: (builder) => ({ - getTransactions: builder.query({ - query: () => '/getTransactions', - }), - getTransactionById: builder.query({ - query: (id) => `/getTransaction/${id}`, - }), - }), -}); - -// Export hooks for usage in functional components -export const { useGetTransactionsQuery, useGetTransactionByIdQuery } = investorTransaction; diff --git a/src/Services/io.service.js b/src/Services/io.service.js deleted file mode 100644 index d200ff3..0000000 --- a/src/Services/io.service.js +++ /dev/null @@ -1,303 +0,0 @@ -// io.service.js -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; - -// const baseUrl = api?.defaults.baseURL; -// Define a service using a base URL and expected endpoints -export const ioService = createApi({ - reducerPath: "ioService", - baseQuery: baseQuery, - tagTypes: [ - "prePopulate", - "getIO", - "getKeyMerits", - "getArtifactsVideo", - "getInvestmentDocuments", - "getIOById", - ], - endpoints: (builder) => ({ - // =====[get prepopulate data] - getIOprepopulateData: builder.query({ - query: () => `/io/admin/pre-populate`, - providesTags: ["prePopulate"], - }), - - // =====[get] - getIOs: builder.query({ - query: ({ page, size }) => `/io/admin?page=${page}&size=${size}`, - providesTags: ["getIO"], - }), - - getIOById: builder.query({ - query: (id) => ({ url: `/io/admin/${id}` }), - providesTags: ["getIOById"], - }), - - // =====[create] - createIO: builder.mutation({ - query: (data) => ({ - url: `/io/admin`, - method: "POST", - body: data, - }), - invalidatesTags: ["getIO"], - }), - - updateIO: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getIOById", "getIO"], - }), - - // =====[Key Merits] - getKeyMerits: builder.query({ - query: (id) => `/io/admin/key-merits/${id}`, - providesTags: ["getKeyMerits"], - }), - - createKeyMerits: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/key-merits/${id}`, - method: "POST", - body: data, - // No need to manually set 'Content-Type' - }), - invalidatesTags: ["getIOById"], - }), - - deleteKeyMerits: builder.mutation({ - query: (id) => ({ - url: `/io/admin/key-merits/hard-delete/${id}`, - method: "DELETE", - }), - invalidatesTags: ["getIOById"], - }), - - updateKeyMerits: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/key-merits/byId/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getIOById"], - }), - - // =====[getIODocument] - createInvestmentDocuments: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/document/${id}`, - method: "POST", - body: data, - }), - - invalidatesTags: ["getIOById"], - }), - - updateInvestmentDocuments: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/document/byId/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getIOById"], - }), - - getInvestmentDocuments: builder.query({ - query: (id) => `/io/admin/document/${id}`, - providesTags: ["getInvestmentDocuments"], - }), - - deleteIODocs: builder.mutation({ - query: (id) => ({ - url: `/io/admin/document/hard-delete/${id}`, - method: "DELETE", - }), - invalidatesTags: ["getIOById"], - }), - - // =====[Artifacts] - getArtifactsVideo: builder.query({ - query: (id) => `/io/artifact/artifactVideo/${id}`, - providesTags: ["getArtifactsVideo"], - }), - - - - - // =====[createImageArtifacts] - createImageArtifacts: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/artifact/image/${id}`, - method: "POST", - body: data, - }), - - invalidatesTags: ["getIOById"], - }), - - - - - updateImageArtifacts: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/artifact/image/byId/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getIOById"], - }), - - - - - // =====[createVideoArtifacts] - createVideoArtifacts: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/artifact/video/${id}`, - method: "POST", - body: data, - }), - - invalidatesTags: ["getIOById"], - }), - - deleteVideoArtifacts: builder.mutation({ - query: (id) => ({ - url: `/io/admin/artifact/video/byId/${id}`, - method: "DELETE", - }), - invalidatesTags: ["getIOById"], - }), - - deleteImageArtifacts: builder.mutation({ - query: (id) => ({ - url: `/io/admin/artifact/image/byId/${id}`, - method: "DELETE", - }), - invalidatesTags: ["getIOById"], - }), - - updateVideoArtifacts: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/artifact/video/byId/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getIOById"], - }), - - setDisplayOrder: builder.mutation({ - query: ({ data }) => ({ - url: `/io/artifact/artifactImage/resetDisplayOrder/`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getIOById"], - }), - - updateStatusIo: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/update-status/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getIOById", 'getIO'], - }), - - createIoCash: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/io-cash/${id}`, - method: "POST", - body: data, - }), - - invalidatesTags: ["getIOById"], - }), - - - createIoNav: builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/io-nav/${id}`, - method: "POST", - body: data, - }), - - invalidatesTags: ["getIOById"], - }), - - - - // =====[ Amount Investment ] - amountIvestment : builder.mutation({ - query: ({ data, id }) => ({ - url: `/io/admin/amount-invested/${id}`, - method: "POST", - body: data, - }), - invalidatesTags: ["getIOById"], - }), - - - - - - - - - - - - - - - - }), -}); - -// Export hooks for usage in functional components -export const { - useGetIOprepopulateDataQuery, - - useGetIOsQuery, - useGetIOByIdQuery, - useCreateIOMutation, - useUpdateIOMutation, - - useGetKeyMeritsQuery, - useCreateKeyMeritsMutation, - useDeleteKeyMeritsMutation, - useUpdateKeyMeritsMutation, - - useGetInvestmentDocumentsQuery, - useCreateInvestmentDocumentsMutation, - useDeleteIODocsMutation, - useUpdateInvestmentDocumentsMutation, - - useCreateImageArtifactsMutation, - useUpdateImageArtifactsMutation, - useUpdateVideoArtifactsMutation, - - useGetArtifactsVideoQuery, - useCreateVideoArtifactsMutation, - useDeleteVideoArtifactsMutation, - useDeleteImageArtifactsMutation, - useSetDisplayOrderMutation, - - - useCreateIoCashMutation, - useCreateIoNavMutation, - - - - useUpdateStatusIoMutation, - - - - - - useAmountIvestmentMutation, -} = ioService; diff --git a/src/Services/on.board.service.js b/src/Services/on.board.service.js new file mode 100644 index 0000000..0ab1728 --- /dev/null +++ b/src/Services/on.board.service.js @@ -0,0 +1,28 @@ +// investorDetails.service.js +import { createApi } from "@reduxjs/toolkit/query/react"; +// import { api } from "./api.service"; +import { baseQuery } from "./token.serivce"; + +// const baseUrl = api?.defaults.baseURL; + +// Define a service using a base URL and expected endpoints +export const onBoarding = createApi({ + reducerPath: "onBoarding", + baseQuery: baseQuery, + tagTypes: ["prePop"], + + endpoints: (builder) => ({ + + + getPrePop: builder.query({ + // query: (searchData) => `/corporate/admin`, + query: () => `/corporate/pre-populate`, + providesTags: ["prePop"], + }), + + + }), +}); + +// Export hooks for usage in functional components +export const { useGetPrePopQuery } = onBoarding; diff --git a/src/Services/sponser.service.js b/src/Services/sponser.service.js deleted file mode 100644 index 5951e8b..0000000 --- a/src/Services/sponser.service.js +++ /dev/null @@ -1,105 +0,0 @@ -//sponser.service -// Need to use the React-specific entry point to import createApi -import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -// import { api } from "./api.service"; -import { baseQuery } from "./token.serivce"; -import { ioService } from "./io.service"; - -// const baseUrl = api?.defaults.baseURL; - - - -// const baseUrl = `${import.meta.env.VITE_API_BASE_URL}/${import.meta.env.VITE_API_VERSION}` - - - -// Define a service using a base URL and expected endpoints -export const sponserMaster = createApi({ - reducerPath: "sponserMaster", - baseQuery: baseQuery, - tagTypes: ["getSponser", "prePopulate"], - endpoints: (builder) => ({ - - - - // ======[Get All]===== - - getSponserMaster: builder.query({ - query: ({ page, size }) => `/sponsor/admin?page=${page}&size=${size}`, - providesTags: ["getSponser"], - }), - - - // ========[Get Active]======== - - getActiveSponserMaster: builder.query({ - query: () => `/sponsor/admin/active`, - }), - - getSponserMasterActive: builder.query({ - query: () => "/sponsor/admin/active", - }), - - - // ======[Get ID]===== - - getSponserById: builder.query({ - query: (id) => `/sponsor/admin/${id}`, - }), - - // ========[Toggle Status]======== - - toggleStatus: builder.mutation({ - query: ({ id }) => ({ - url: `/sponsor/admin/toggle-status/${id}`, - method: "PATCH", - }), - invalidatesTags: ["getSponser"], - }), - - // ========[Create Sponser]======== - - createSponser: builder.mutation({ - query: (data) => ({ - url: `/sponsor/admin`, - method: "POST", - body: data, - }), - invalidatesTags: ["getSponser","prePopulate"], - }), - - // ========[Update Sponser]======== - - updateSponser: builder.mutation({ - query: ({ data, id }) => ({ - url: `/sponsor/admin/${id}`, - method: "PATCH", - body: data, - }), - invalidatesTags: ["getSponser"], - }), - - // ========[Delete Sponser]======== - - deleteSponser: builder.mutation({ - query: (id) => ({ - url: `/sponsor/admin/delete/${id}`, - method: "DELETE", - }), - invalidatesTags: ["getSponser"], - }), - - }), -}); - -// Export hooks for usage in functional components -export const { - useGetSponserMasterQuery, - useGetSponserMasterActiveQuery, - useToggleStatusMutation, - useCreateSponserMutation, - useUpdateSponserMutation, - useGetSponserByIdQuery, - useDeleteSponserMutation, - useGetActiveSponserMasterQuery -} = sponserMaster; diff --git a/src/Services/token.serivce.js b/src/Services/token.serivce.js index 5c2b3f2..01dfb5b 100644 --- a/src/Services/token.serivce.js +++ b/src/Services/token.serivce.js @@ -1,28 +1,13 @@ -import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; +import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; +import Cookies from "js-cookie"; -// Define a base query function with RTK Query -// export const baseQuery = fetchBaseQuery({ -// baseUrl: 'https://sprint4.tanami.betadelivery.com/api/v1', -// prepareHeaders: (headers) => { -// const token = localStorage.getItem('accessToken'); -// if (token) { -// headers.set('x-auth-token', `${token}`); -// } -// return headers; -// }, -// }); - - - - -// Define a base query function with token refresh logic -export const baseQuery = async (args, api, extraOptions) => { +export const baseQuery = async (args, api, extraOptions) => { let result = await fetchBaseQuery({ - baseUrl: 'https://sprint4.tanami.betadelivery.com/api/v1', + baseUrl: import.meta.env.VITE_BASE_URL, prepareHeaders: (headers) => { - const token = localStorage.getItem('accessToken'); + const token = localStorage.getItem("accessToken"); if (token) { - headers.set('x-auth-token', token); + headers.set("x-auth-token", token); } return headers; }, @@ -30,41 +15,55 @@ export const baseQuery = async (args, api, extraOptions) => { if (result.error && result.error.status === 401) { // Handle token refresh - const refreshToken = localStorage.getItem('refreshToken'); - if (refreshToken) { - try { - const refreshResult = await fetchBaseQuery({ - baseUrl: 'https://sprint4.tanami.betadelivery.com/api/v1', - })({ - url: '/auth/user/regenerate-token', - method: 'POST', - body: { refreshToken }, - }, api, extraOptions); + // const refreshToken = localStorage.getItem("refreshToken"); + // if (refreshToken) { + // try { + // const refreshResult = await fetchBaseQuery({ + // baseUrl: import.meta.env.VITE_BASE_URL, + // })( + // { + // url: "/regenerate-token", + // method: "POST", + // body: { refreshToken }, + // }, + // api, + // extraOptions + // ); - if (refreshResult.data) { - - // Save new tokens - localStorage.setItem('accessToken', refreshResult.data.access.token); - localStorage.setItem('refreshToken', refreshResult.data.refresh.token); - localStorage.setItem('refreshTokenExp', refreshResult.data.refresh.expires); + // if (refreshResult.data) { + // // Save new tokens + // localStorage.setItem("accessToken", refreshResult.data.access.token); + // localStorage.setItem( + // "refreshToken", + // refreshResult.data.refresh.token + // ); + // localStorage.setItem( + // "refreshTokenExp", + // refreshResult.data.refresh.expires + // ); - // Retry the original request with the new token - result = await fetchBaseQuery({ - baseUrl: 'https://sprint4.tanami.betadelivery.com/api/v1', - prepareHeaders: (headers) => { - const token = localStorage.getItem('accessToken'); - if (token) { - headers.set('x-auth-token', token); - } - return headers; - }, - })(args, api, extraOptions); - } - } catch (err) { - console.error('Failed to refresh token:', err); - // Handle refresh failure (e.g., redirect to login) - } - } + // // Retry the original request with the new token + // result = await fetchBaseQuery({ + // baseUrl: import.meta.env.VITE_BASE_URL, + // prepareHeaders: (headers) => { + // const token = localStorage.getItem("accessToken"); + // if (token) { + // headers.set("x-auth-token", token); + // } + // return headers; + // }, + // })(args, api, extraOptions); + // } + // } catch (err) { + // console.error("Failed to refresh token:", err); + // // Handle refresh failure (e.g., redirect to login) + // } + // } + + + localStorage.removeItem("accessToken"); + localStorage.removeItem("refreshToken"); + Cookies.remove("isAuthenticated", { path: '/login' }); } return result; @@ -72,36 +71,83 @@ export const baseQuery = async (args, api, extraOptions) => { // Create an RTK Query API slice export const apiSlice = createApi({ - reducerPath: 'api', + reducerPath: "api", baseQuery: baseQuery, endpoints: (builder) => ({ login: builder.mutation({ query: (credentials) => ({ - url: '/auth/admin', - method: 'POST', + url: "/auth/admin", + method: "POST", body: credentials, }), async onQueryStarted(arg, { dispatch, queryFulfilled }) { try { const { data } = await queryFulfilled; // Store tokens in local storage - localStorage.setItem('accessToken', data?.data?.access?.token) ; - localStorage.setItem('refreshToken', data?.data?.refresh?.token); + localStorage.setItem("accessToken", data?.data?.access?.token); + localStorage.setItem("refreshToken", data?.data?.refresh?.token); // localStorage.setItem('refreshTokenExp', data?.data?.refresh?.expires); - localStorage.setItem('accessTokenExp', data?.data?.access?.expires); + localStorage.setItem("accessTokenExp", data?.data?.access?.expires); } catch (error) { - console.error('Login failed:', error); + console.error("Login failed:", error); } }, }), + refreshToken: builder.mutation({ query: (refreshToken) => ({ - url: '/auth/user/regenerate-token', - method: 'POST', + url: "/auth/user/regenerate-token", + method: "POST", body: { refreshToken }, }), }), + + + forgotPassword: builder.mutation({ + query: (data) => ({ + url: "/auth/admin/forget-password", + method: "POST", + body: data , + }), + }), + + + + + resetPassword: builder.mutation({ + query: (data) => ({ + url: "/auth/admin/reset-password", + method: "POST", + body: data , + }), + }), + + setOtp: builder.mutation({ + query: (data) => ({ + url: "/auth/admin/verify-otp", + method: "POST", + body: data , + }), + }), + + + + + + resendOtp: builder.mutation({ + query: (data) => ({ + url: "/auth/admin/resend-otp", + method: "POST", + body: data , + }), + }), + + + + + + }), }); -export const { useLoginMutation, useRefreshTokenMutation } = apiSlice; +export const { useLoginMutation, useRefreshTokenMutation, useForgotPasswordMutation, useResetPasswordMutation,useResendOtpMutation, useSetOtpMutation } = apiSlice; diff --git a/src/Store/Store.js b/src/Store/Store.js index 204f96b..ec40bd4 100644 --- a/src/Store/Store.js +++ b/src/Store/Store.js @@ -1,30 +1,13 @@ + import { configureStore } from "@reduxjs/toolkit"; -import { setupListeners } from "@reduxjs/toolkit/query"; -import { sponserMaster } from "../Services/sponser.service"; -import { investmentType } from "../Services/investment.type.service"; -import { exchangeRate } from "../Services/exchange.rate.service"; -import { ioService } from "../Services/io.service"; -import { investorDetails } from "../Services/investor.details.service"; -import { investorTransaction } from "../Services/investor.transaction.service"; -// import { api } from "../Services/api.service"; -// import { keyMerits } from "../Services/Key.merits.service"; -import { bankDetails } from "../Services/bank.details.service"; -import { contact } from "../Services/contact.service"; -import { depositRequest } from "../Services/deposit.request.service"; +import { onBoarding } from "../Services/on.board.service"; import { apiSlice, baseQuery } from "../Services/token.serivce"; +import { setupListeners } from "@reduxjs/toolkit/query"; export const store = configureStore({ reducer: { [apiSlice.reducerPath]: apiSlice.reducer, - [sponserMaster.reducerPath]: sponserMaster.reducer, - [investmentType.reducerPath]: investmentType.reducer, - [exchangeRate.reducerPath]: exchangeRate.reducer, - [ioService.reducerPath]: ioService.reducer, - [investorDetails.reducerPath]: investorDetails.reducer, - [investorTransaction.reducerPath]: investorTransaction.reducer, - [bankDetails.reducerPath]: bankDetails.reducer, - [contact.reducerPath]: contact.reducer, - [depositRequest.reducerPath]: depositRequest.reducer, + [onBoarding.reducerPath]: onBoarding.reducer, // Add other reducers as needed }, middleware: (getDefaultMiddleware) => @@ -34,15 +17,7 @@ export const store = configureStore({ }, }).concat( apiSlice.middleware, - sponserMaster.middleware, - investmentType.middleware, - exchangeRate.middleware, - ioService.middleware, - investorDetails.middleware, - investorTransaction.middleware, - bankDetails.middleware, - contact.middleware, - depositRequest.middleware, + onBoarding.middleware, ), });