// GlobalStateContext.js
import React, { useState } from "react";
import GlobalStateContext from "./GlobalStateContext";

const getRandomDate = (start, end) => {
  const date = new Date(
    start.getTime() + Math.random() * (end.getTime() - start.getTime())
  );
  return date.toISOString();
};

const startDate = new Date(2020, 0, 1); // January 1, 2020
const endDate = new Date(); // Current date

export const generateUniqueId = () => {
  const letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  const digits = "0123456789";

  let id = "";

  // Generate three random uppercase letters
  for (let i = 0; i < 3; i++) {
    id += letters[Math.floor(Math.random() * letters.length)];
  }

  // Generate seven random digits
  for (let i = 0; i < 7; i++) {
    id += digits[Math.floor(Math.random() * digits.length)];
  }

  return id;
};

const GlobalStateProvider = ({ children }) => {
  const [isAuthenticate, setIsAuthenticate] = useState(false);


  const [requestsTable, setRequestTable] = useState([
    {
      "id": 1,
      "transactionType": "Dine In",
      "date": "25-08-2024 01:15 pm",
      "walletType": "Food",
      "amountSpent": "₹ 3200"
    },
    {
      "id": 2,
      "transactionType": "Take Away",
      "date": "22-07-2024 03:30 pm",
      "walletType": "Travel",
      "amountSpent": "₹ 1500"
    },
    {
      "id": 3,
      "transactionType": "Delivery",
      "date": "15-06-2024 11:00 am",
      "walletType": "Shopping",
      "amountSpent": "₹ 2450"
    },
    {
      "id": 4,
      "transactionType": "Dine In",
      "date": "09-05-2024 08:45 pm",
      "walletType": "Groceries",
      "amountSpent": "₹ 5400"
    },
    {
      "id": 5,
      "transactionType": "Take Away",
      "date": "02-07-2024 12:30 pm",
      "walletType": "Entertainment",
      "amountSpent": "₹ 1300"
    },
    {
      "id": 6,
      "transactionType": "Delivery",
      "date": "10-03-2024 06:15 pm",
      "walletType": "Electronics",
      "amountSpent": "₹ 6800"
    },
    {
      "id": 7,
      "transactionType": "Dine In",
      "date": "18-09-2024 05:20 pm",
      "walletType": "Utilities",
      "amountSpent": "₹ 4000"
    },
    {
      "id": 8,
      "transactionType": "Delivery",
      "date": "12-04-2024 02:50 pm",
      "walletType": "Food",
      "amountSpent": "₹ 2700"
    },
    {
      "id": 9,
      "transactionType": "Dine In",
      "date": "05-11-2024 07:10 pm",
      "walletType": "Health",
      "amountSpent": "₹ 4900"
    },
    {
      "id": 10,
      "transactionType": "Take Away",
      "date": "19-08-2024 09:40 am",
      "walletType": "Food",
      "amountSpent": "₹ 2200"
    },
    {
      "id": 11,
      "transactionType": "Dine In",
      "date": "18-09-2024 05:20 pm",
      "walletType": "Utilities",
      "amountSpent": "₹ 4000"
    }
  ]

  )


  const [corpData, setCorpData] = useState([
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
    {
      "id": 1,
      "CorpId": "WD09",
      "CompanyName": "Olivia Ipsum",
      "DateOfOnbaording": "25 Jan 2023",
      "EmailAddress": "info@wdimails.com",
      "Industry": "Fintech",
      "Type": "LLP",
      "Subscription": "Gifts , Benefit",
      "Status": "Registered"
    },
  ]

  )

  return (
    <GlobalStateContext.Provider
      value={{
        isAuthenticate,
        setIsAuthenticate,
        requestsTable, 
        setRequestTable,
        corpData, 
        setCorpData
      }}
    >
      {children}
    </GlobalStateContext.Provider>
  );
};
export default GlobalStateProvider;
