[
  {
    "path": ".gitignore",
    "content": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pnp\n.pnp.js\n\n# testing\n/coverage\n\n# next.js\n/.next/\n/out/\n\n# production\n/build\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# local env files\n.env*.local\n\n# vercel\n.vercel\n\n# typescript\n*.tsbuildinfo\nnext-env.d.ts\n"
  },
  {
    "path": "README.md",
    "content": "This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).\n\n## Getting Started\n\nFirst, run the development server:\n\n```bash\nnpm run dev\n# or\nyarn dev\n# or\npnpm dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) with your browser to see the result.\n\nYou can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.\n\nThis project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.\n\n## Learn More\n\nTo learn more about Next.js, take a look at the following resources:\n\n- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.\n- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.\n\nYou can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!\n\n## Deploy on Vercel\n\nThe easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.\n\nCheck out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.\n"
  },
  {
    "path": "jsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"paths\": {\n      \"@/*\": [\"./src/*\"]\n    }\n  }\n}\n"
  },
  {
    "path": "next.config.js",
    "content": "/** @type {import('next').NextConfig} */\nconst nextConfig = {}\n\nmodule.exports = nextConfig\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"ecommerce\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"scripts\": {\n    \"dev\": \"next dev\",\n    \"build\": \"next build\",\n    \"start\": \"next start\",\n    \"lint\": \"next lint\"\n  },\n  \"dependencies\": {\n    \"@headlessui/react\": \"^1.7.15\",\n    \"@stripe/stripe-js\": \"^1.54.1\",\n    \"autoprefixer\": \"10.4.14\",\n    \"bcryptjs\": \"^2.4.3\",\n    \"firebase\": \"^10.0.0\",\n    \"joi\": \"^17.9.2\",\n    \"js-cookie\": \"^3.0.5\",\n    \"jsonwebtoken\": \"^9.0.1\",\n    \"mongoose\": \"^7.3.2\",\n    \"next\": \"13.4.9\",\n    \"postcss\": \"8.4.25\",\n    \"react\": \"18.2.0\",\n    \"react-dom\": \"18.2.0\",\n    \"react-spinners\": \"^0.13.8\",\n    \"react-toastify\": \"^9.1.3\",\n    \"stripe\": \"^12.12.0\",\n    \"tailwindcss\": \"3.3.2\"\n  },\n  \"devDependencies\": {\n    \"encoding\": \"^0.1.13\"\n  }\n}\n"
  },
  {
    "path": "postcss.config.js",
    "content": "module.exports = {\n  plugins: {\n    tailwindcss: {},\n    autoprefixer: {},\n  },\n}\n"
  },
  {
    "path": "src/app/account/page.js",
    "content": "\"use client\";\n\nimport InputComponent from \"@/components/FormElements/InputComponent\";\nimport ComponentLevelLoader from \"@/components/Loader/componentlevel\";\nimport Notification from \"@/components/Notification\";\nimport { GlobalContext } from \"@/context\";\nimport {\n  addNewAddress,\n  deleteAddress,\n  fetchAllAddresses,\n  updateAddress,\n} from \"@/services/address\";\nimport { addNewAddressFormControls } from \"@/utils\";\nimport { useRouter } from \"next/navigation\";\nimport { useContext, useEffect, useState } from \"react\";\nimport { PulseLoader } from \"react-spinners\";\nimport { toast } from \"react-toastify\";\n\nexport default function Account() {\n  const {\n    user,\n    addresses,\n    setAddresses,\n    addressFormData,\n    setAddressFormData,\n    componentLevelLoader,\n    setComponentLevelLoader,\n    pageLevelLoader,\n    setPageLevelLoader,\n  } = useContext(GlobalContext);\n\n  const [showAddressForm, setShowAddressForm] = useState(false);\n  const [currentEditedAddressId, setCurrentEditedAddressId] = useState(null);\n  const router = useRouter()\n\n  async function extractAllAddresses() {\n    setPageLevelLoader(true);\n    const res = await fetchAllAddresses(user?._id);\n\n    if (res.success) {\n      setPageLevelLoader(false);\n\n      setAddresses(res.data);\n    }\n  }\n\n  async function handleAddOrUpdateAddress() {\n    setComponentLevelLoader({ loading: true, id: \"\" });\n    const res =\n      currentEditedAddressId !== null\n        ? await updateAddress({\n            ...addressFormData,\n            _id: currentEditedAddressId,\n          })\n        : await addNewAddress({ ...addressFormData, userID: user?._id });\n\n    console.log(res);\n\n    if (res.success) {\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setAddressFormData({\n        fullName: \"\",\n        city: \"\",\n        country: \"\",\n        postalCode: \"\",\n        address: \"\",\n      });\n      extractAllAddresses();\n      setCurrentEditedAddressId(null);\n    } else {\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setAddressFormData({\n        fullName: \"\",\n        city: \"\",\n        country: \"\",\n        postalCode: \"\",\n        address: \"\",\n      });\n    }\n  }\n\n  function handleUpdateAddress(getCurrentAddress) {\n    setShowAddressForm(true);\n    setAddressFormData({\n      fullName: getCurrentAddress.fullName,\n      city: getCurrentAddress.city,\n      country: getCurrentAddress.country,\n      postalCode: getCurrentAddress.postalCode,\n      address: getCurrentAddress.address,\n    });\n    setCurrentEditedAddressId(getCurrentAddress._id);\n  }\n\n  async function handleDelete(getCurrentAddressID) {\n    setComponentLevelLoader({ loading: true, id: getCurrentAddressID });\n\n    const res = await deleteAddress(getCurrentAddressID);\n\n    if (res.success) {\n      setComponentLevelLoader({ loading: false, id: \"\" });\n\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      extractAllAddresses();\n    } else {\n      setComponentLevelLoader({ loading: false, id: \"\" });\n\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n    }\n  }\n\n  useEffect(() => {\n    if (user !== null) extractAllAddresses();\n  }, [user]);\n\n  return (\n    <section>\n      <div className=\"mx-auto bg-gray-100 px-4 sm:px-6 lg:px-8\">\n        <div className=\"bg-white shadow\">\n          <div className=\"p-6 sm:p-12\">\n            <div className=\"flex flex-col space-y-4 md:space-y-0 md:space-x-6 md:flex-row\">\n              {/* we have render random user image here */}\n            </div>\n            <div className=\"flex flex-col flex-1\">\n              <h4 className=\"text-lg font-semibold text-center md:text-left\">\n                {user?.name}\n              </h4>\n              <p>{user?.email}</p>\n              <p>{user?.role}</p>\n            </div>\n            <button onClick={()=>router.push('/orders')} className=\"mt-5  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\">\n              View Your Orders\n            </button>\n            <div className=\"mt-6\">\n              <h1 className=\"font-bold text-lg\">Your Addresses :</h1>\n              {pageLevelLoader ? (\n                <PulseLoader\n                  color={\"#000000\"}\n                  loading={pageLevelLoader}\n                  size={15}\n                  data-testid=\"loader\"\n                />\n              ) : (\n                <div className=\"mt-4 flex flex-col gap-4\">\n                  {addresses && addresses.length ? (\n                    addresses.map((item) => (\n                      <div className=\"border p-6\" key={item._id}>\n                        <p>Name : {item.fullName}</p>\n                        <p>Address : {item.address}</p>\n                        <p>City : {item.city}</p>\n                        <p>Country : {item.country}</p>\n                        <p>PostalCode : {item.postalCode}</p>\n                        <button\n                          onClick={() => handleUpdateAddress(item)}\n                          className=\"mt-5 mr-5 inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n                        >\n                          Update\n                        </button>\n                        <button\n                          onClick={() => handleDelete(item._id)}\n                          className=\"mt-5  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n                        >\n                          {componentLevelLoader &&\n                          componentLevelLoader.loading &&\n                          componentLevelLoader.id === item._id ? (\n                            <ComponentLevelLoader\n                              text={\"Deleting\"}\n                              color={\"#ffffff\"}\n                              loading={\n                                componentLevelLoader &&\n                                componentLevelLoader.loading\n                              }\n                            />\n                          ) : (\n                            \"Delete\"\n                          )}\n                        </button>\n                      </div>\n                    ))\n                  ) : (\n                    <p>No address found ! Please add a new address below</p>\n                  )}\n                </div>\n              )}\n            </div>\n            <div className=\"mt-4\">\n              <button\n                onClick={() => setShowAddressForm(!showAddressForm)}\n                className=\"mt-5  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n              >\n                {showAddressForm ? \"Hide Address Form\" : \"Add New Address\"}\n              </button>\n            </div>\n            {showAddressForm ? (\n              <div className=\"flex flex-col mt-5 justify-center pt-4 items-center\">\n                <div className=\"w-full mt-6 mr-0 mb-0 ml-0 space-y-8\">\n                  {addNewAddressFormControls.map((controlItem) => (\n                    <InputComponent\n                      type={controlItem.type}\n                      placeholder={controlItem.placeholder}\n                      label={controlItem.label}\n                      value={addressFormData[controlItem.id]}\n                      onChange={(event) =>\n                        setAddressFormData({\n                          ...addressFormData,\n                          [controlItem.id]: event.target.value,\n                        })\n                      }\n                    />\n                  ))}\n                </div>\n                <button\n                  onClick={handleAddOrUpdateAddress}\n                  className=\"mt-5  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n                >\n                  {componentLevelLoader && componentLevelLoader.loading ? (\n                    <ComponentLevelLoader\n                      text={\"Saving\"}\n                      color={\"#ffffff\"}\n                      loading={\n                        componentLevelLoader && componentLevelLoader.loading\n                      }\n                    />\n                  ) : (\n                    \"Save\"\n                  )}\n                </button>\n              </div>\n            ) : null}\n          </div>\n        </div>\n      </div>\n      <Notification />\n    </section>\n  );\n}\n"
  },
  {
    "path": "src/app/admin-view/add-product/page.js",
    "content": "\"use client\";\n\nimport InputComponent from \"@/components/FormElements/InputComponent\";\nimport SelectComponent from \"@/components/FormElements/SelectComponent\";\nimport TileComponent from \"@/components/FormElements/TileComponent\";\nimport ComponentLevelLoader from \"@/components/Loader/componentlevel\";\nimport Notification from \"@/components/Notification\";\nimport { GlobalContext } from \"@/context\";\nimport { addNewProduct, updateAProduct } from \"@/services/product\";\nimport {\n  AvailableSizes,\n  adminAddProductformControls,\n  firebaseConfig,\n  firebaseStroageURL,\n} from \"@/utils\";\nimport { initializeApp } from \"firebase/app\";\nimport {\n  getDownloadURL,\n  getStorage,\n  ref,\n  uploadBytesResumable,\n} from \"firebase/storage\";\nimport { useRouter } from \"next/navigation\";\nimport { useContext, useEffect, useState } from \"react\";\nimport { toast } from \"react-toastify\";\nimport { resolve } from \"styled-jsx/css\";\n\nconst app = initializeApp(firebaseConfig);\nconst storage = getStorage(app, firebaseStroageURL);\n\nconst createUniqueFileName = (getFile) => {\n  const timeStamp = Date.now();\n  const randomStringValue = Math.random().toString(36).substring(2, 12);\n\n  return `${getFile.name}-${timeStamp}-${randomStringValue}`;\n};\n\nasync function helperForUPloadingImageToFirebase(file) {\n  const getFileName = createUniqueFileName(file);\n  const storageReference = ref(storage, `ecommerce/${getFileName}`);\n  const uploadImage = uploadBytesResumable(storageReference, file);\n\n  return new Promise((resolve, reject) => {\n    uploadImage.on(\n      \"state_changed\",\n      (snapshot) => {},\n      (error) => {\n        console.log(error);\n        reject(error);\n      },\n      () => {\n        getDownloadURL(uploadImage.snapshot.ref)\n          .then((downloadUrl) => resolve(downloadUrl))\n          .catch((error) => reject(error));\n      }\n    );\n  });\n}\n\nconst initialFormData = {\n  name: \"\",\n  price: 0,\n  description: \"\",\n  category: \"men\",\n  sizes: [],\n  deliveryInfo: \"\",\n  onSale: \"no\",\n  imageUrl: \"\",\n  priceDrop: 0,\n};\n\nexport default function AdminAddNewProduct() {\n  const [formData, setFormData] = useState(initialFormData);\n\n  const {\n    componentLevelLoader,\n    setComponentLevelLoader,\n    currentUpdatedProduct,\n    setCurrentUpdatedProduct,\n  } = useContext(GlobalContext);\n\n  console.log(currentUpdatedProduct);\n\n  const router = useRouter();\n\n  useEffect(() => {\n    if (currentUpdatedProduct !== null) setFormData(currentUpdatedProduct);\n  }, [currentUpdatedProduct]);\n\n  async function handleImage(event) {\n    const extractImageUrl = await helperForUPloadingImageToFirebase(\n      event.target.files[0]\n    );\n\n    if (extractImageUrl !== \"\") {\n      setFormData({\n        ...formData,\n        imageUrl: extractImageUrl,\n      });\n    }\n  }\n\n  function handleTileClick(getCurrentItem) {\n    let cpySizes = [...formData.sizes];\n    const index = cpySizes.findIndex((item) => item.id === getCurrentItem.id);\n\n    if (index === -1) {\n      cpySizes.push(getCurrentItem);\n    } else {\n      cpySizes = cpySizes.filter((item) => item.id !== getCurrentItem.id);\n    }\n\n    setFormData({\n      ...formData,\n      sizes: cpySizes,\n    });\n  }\n\n  async function handleAddProduct() {\n    setComponentLevelLoader({ loading: true, id: \"\" });\n    const res =\n      currentUpdatedProduct !== null\n        ? await updateAProduct(formData)\n        : await addNewProduct(formData);\n\n    console.log(res);\n\n    if (res.success) {\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n\n      setFormData(initialFormData);\n      setCurrentUpdatedProduct(null)\n      setTimeout(() => {\n        router.push(\"/admin-view/all-products\");\n      }, 1000);\n    } else {\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      setFormData(initialFormData);\n    }\n  }\n\n  console.log(formData);\n\n  return (\n    <div className=\"w-full mt-5 mr-0 mb-0 ml-0 relative\">\n      <div className=\"flex flex-col items-start justify-start p-10 bg-white shadow-2xl rounded-xl relative\">\n        <div className=\"w-full mt-6 mr-0 mb-0 ml-0 space-y-8\">\n          <input\n            accept=\"image/*\"\n            max=\"1000000\"\n            type=\"file\"\n            onChange={handleImage}\n          />\n\n          <div className=\"flex gap-2 flex-col\">\n            <label>Available sizes</label>\n            <TileComponent\n              selected={formData.sizes}\n              onClick={handleTileClick}\n              data={AvailableSizes}\n            />\n          </div>\n          {adminAddProductformControls.map((controlItem) =>\n            controlItem.componentType === \"input\" ? (\n              <InputComponent\n                type={controlItem.type}\n                placeholder={controlItem.placeholder}\n                label={controlItem.label}\n                value={formData[controlItem.id]}\n                onChange={(event) => {\n                  setFormData({\n                    ...formData,\n                    [controlItem.id]: event.target.value,\n                  });\n                }}\n              />\n            ) : controlItem.componentType === \"select\" ? (\n              <SelectComponent\n                label={controlItem.label}\n                options={controlItem.options}\n                value={formData[controlItem.id]}\n                onChange={(event) => {\n                  setFormData({\n                    ...formData,\n                    [controlItem.id]: event.target.value,\n                  });\n                }}\n              />\n            ) : null\n          )}\n          <button\n            onClick={handleAddProduct}\n            className=\"inline-flex w-full items-center justify-center bg-black px-6 py-4 text-lg text-white font-medium uppercase tracking-wide\"\n          >\n            {componentLevelLoader && componentLevelLoader.loading ? (\n              <ComponentLevelLoader\n                text={currentUpdatedProduct !== null ? 'Updating Product' : \"Adding Product\"}\n                color={\"#ffffff\"}\n                loading={componentLevelLoader && componentLevelLoader.loading}\n              />\n            ) : currentUpdatedProduct !== null ? (\n              \"Update Product\"\n            ) : (\n              \"Add Product\"\n            )}\n          </button>\n        </div>\n      </div>\n      <Notification />\n    </div>\n  );\n}\n"
  },
  {
    "path": "src/app/admin-view/all-products/page.js",
    "content": "import CommonListing from \"@/components/CommonListing\";\nimport { getAllAdminProducts } from \"@/services/product\";\n\n\n\nexport default async function AdminAllProducts() {\n\n  const allAdminProducts = await getAllAdminProducts()\n\n  return <CommonListing data={allAdminProducts && allAdminProducts.data}/>\n}\n"
  },
  {
    "path": "src/app/admin-view/page.js",
    "content": "\"use client\";\n\nimport ComponentLevelLoader from \"@/components/Loader/componentlevel\";\nimport { GlobalContext } from \"@/context\";\nimport { getAllOrdersForAllUsers, updateStatusOfOrder } from \"@/services/order\";\nimport { useContext, useEffect } from \"react\";\nimport { PulseLoader } from \"react-spinners\";\n\nexport default function AdminView() {\n  const {\n    allOrdersForAllUsers,\n    setAllOrdersForAllUsers,\n    user,\n    pageLevelLoader,\n    setPageLevelLoader,\n    componentLevelLoader,\n    setComponentLevelLoader,\n  } = useContext(GlobalContext);\n\n  async function extractAllOrdersForAllUsers() {\n    setPageLevelLoader(true);\n    const res = await getAllOrdersForAllUsers();\n\n    console.log(res);\n\n    if (res.success) {\n      setPageLevelLoader(false);\n      setAllOrdersForAllUsers(\n        res.data && res.data.length\n          ? res.data.filter((item) => item.user._id !== user._id)\n          : []\n      );\n    } else {\n      setPageLevelLoader(false);\n    }\n  }\n\n  useEffect(() => {\n    if (user !== null) extractAllOrdersForAllUsers();\n  }, [user]);\n\n  console.log(allOrdersForAllUsers);\n\n  async function handleUpdateOrderStatus(getItem) {\n    setComponentLevelLoader({ loading: true, id: getItem._id });\n    const res = await updateStatusOfOrder({\n      ...getItem,\n      isProcessing: false,\n    });\n\n    if (res.success) {\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      extractAllOrdersForAllUsers();\n    } else {\n      setComponentLevelLoader({ loading: true, id: \"\" });\n    }\n  }\n\n  if (pageLevelLoader) {\n    return (\n      <div className=\"w-full min-h-screen flex justify-center items-center\">\n        <PulseLoader\n          color={\"#000000\"}\n          loading={pageLevelLoader}\n          size={30}\n          data-testid=\"loader\"\n        />\n      </div>\n    );\n  }\n\n  return (\n    <section>\n      <div className=\"mx-auto px-4 sm:px-6 lg:px-8\">\n        <div>\n          <div className=\"px-4 py-6 sm:px-8 sm:py-10\">\n            <div className=\"flow-root\">\n              {allOrdersForAllUsers && allOrdersForAllUsers.length ? (\n                <ul className=\"flex flex-col gap-4\">\n                  {allOrdersForAllUsers.map((item) => (\n                    <li\n                      key={item._id}\n                      className=\"bg-gray-200 shadow p-5 flex flex-col space-y-3 py-6 text-left\"\n                    >\n                      <div className=\"flex\">\n                        <h1 className=\"font-bold text-lg mb-3 flex-1\">\n                          #order: {item._id}\n                        </h1>\n                        <div className=\"flex flex-col gap-2\">\n                          <div className=\"flex items-center\">\n                            <p className=\"mr-3 text-sm font-medium text-gray-900\">\n                              User Name :\n                            </p>\n                            <p className=\"text-sm  font-semibold text-gray-900\">\n                              {item?.user?.name}\n                            </p>\n                          </div>\n                          <div className=\"flex items-center\">\n                            <p className=\"mr-3 text-sm font-medium text-gray-900\">\n                              User Email :\n                            </p>\n                            <p className=\"text-sm  font-semibold text-gray-900\">\n                              {item?.user?.email}\n                            </p>\n                          </div>\n                          <div className=\"flex items-center\">\n                            <p className=\"mr-3 text-sm font-medium text-gray-900\">\n                              Total Paid Amount :\n                            </p>\n                            <p className=\"text-sm  font-semibold text-gray-900\">\n                              ${item?.totalPrice}\n                            </p>\n                          </div>\n                        </div>\n                      </div>\n                      <div className=\"flex gap-2\">\n                        {item.orderItems.map((orderItem, index) => (\n                          <div key={index} className=\"shrink-0\">\n                            <img\n                              alt=\"Order Item\"\n                              className=\"h-24 w-24 max-w-full rounded-lg object-cover\"\n                              src={\n                                orderItem &&\n                                orderItem.product &&\n                                orderItem.product.imageUrl\n                              }\n                            />\n                          </div>\n                        ))}\n                      </div>\n                      <div className=\"flex gap-5\">\n                        <button className=\"disabled:opacity-50 mt-5 mr-5  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\">\n                          {item.isProcessing\n                            ? \"Order is Processing\"\n                            : \"Order is delivered\"}\n                        </button>\n                        <button\n                          onClick={() => handleUpdateOrderStatus(item)}\n                          disabled={!item.isProcessing}\n                          className=\"disabled:opacity-50 mt-5 mr-5  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n                        >\n                          {componentLevelLoader &&\n                          componentLevelLoader.loading &&\n                          componentLevelLoader.id === item._id ? (\n                            <ComponentLevelLoader\n                              text={\"Updating Order Status\"}\n                              color={\"#ffffff\"}\n                              loading={\n                                componentLevelLoader &&\n                                componentLevelLoader.loading\n                              }\n                            />\n                          ) : (\n                            \"Update Order Status\"\n                          )}\n                        </button>\n                      </div>\n                    </li>\n                  ))}\n                </ul>\n              ) : null}\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
  },
  {
    "path": "src/app/api/address/add-new-address/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Address from \"@/models/address\";\nimport Joi from \"joi\";\nimport { NextResponse } from \"next/server\";\n\nconst AddNewAddress = Joi.object({\n  fullName: Joi.string().required(),\n  address: Joi.string().required(),\n  city: Joi.string().required(),\n  country: Joi.string().required(),\n  postalCode: Joi.string().required(),\n  userID: Joi.string().required(),\n});\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function POST(req) {\n  try {\n    await connectToDB();\n\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser) {\n      const data = await req.json();\n\n      const { fullName, address, city, country, postalCode, userID } = data;\n\n      const { error } = AddNewAddress.validate({\n        fullName,\n        address,\n        city,\n        country,\n        postalCode,\n        userID,\n      });\n\n      if (error) {\n        return NextResponse.json({\n          success: false,\n          message: error.details[0].message,\n        });\n      }\n\n      const newlyAddedAddress = await Address.create(data);\n\n      if (newlyAddedAddress) {\n        return NextResponse.json({\n          success: true,\n          message: \"Address added successfully\",\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"failed to add an address ! Please try again later\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (e) {\n    console.log(e);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/address/delete-address/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Address from \"@/models/address\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function DELETE(req) {\n  try {\n    await connectToDB();\n    const { searchParams } = new URL(req.url);\n    const id = searchParams.get(\"id\");\n\n    if (!id) {\n      return NextResponse.json({\n        success: false,\n        message: \"Address ID is required\",\n      });\n    }\n\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser) {\n      const deletedAddress = await Address.findByIdAndDelete(id);\n\n      if (deletedAddress) {\n        return NextResponse.json({\n          success: true,\n          message: \"Address is deleted successfully\",\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"failed to delete address ! Please try again\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (e) {\n    console.log(e);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/address/get-all-address/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Address from \"@/models/address\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(req) {\n  try {\n    await connectToDB();\n\n    const { searchParams } = new URL(req.url);\n    const id = searchParams.get(\"id\");\n\n    if (!id) {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not logged In\",\n      });\n    }\n\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser) {\n      const getAllAddresses = await Address.find({ userID: id });\n\n      if (getAllAddresses) {\n        return NextResponse.json({\n          success: true,\n          data: getAllAddresses,\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"failed to get addresses ! Please try again\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (e) {\n    console.log(e);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/address/update-address/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Address from \"@/models/address\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function PUT(req) {\n  try {\n    await connectToDB();\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser) {\n      const data = await req.json();\n      const { _id, fullName, city, address, country, postalCode } = data;\n\n      const updateAddress = await Address.findOneAndUpdate(\n        {\n          _id: _id,\n        },\n        { fullName, city, address, country, postalCode },\n        { new: true }\n      );\n\n      if (updateAddress) {\n        return NextResponse.json({\n          success: true,\n          message: \"Address updated successfully!\",\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"failed to update address ! Please try again\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (e) {\n    console.log(e);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/admin/add-product/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Product from \"@/models/product\";\nimport Joi from \"joi\";\nimport { NextResponse } from \"next/server\";\n\nconst AddNewProductSchema = Joi.object({\n  name: Joi.string().required(),\n  description: Joi.string().required(),\n  price: Joi.number().required(),\n  category: Joi.string().required(),\n  sizes: Joi.array().required(),\n  deliveryInfo: Joi.string().required(),\n  onSale: Joi.string().required(),\n  priceDrop: Joi.number().required(),\n  imageUrl: Joi.string().required(),\n});\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function POST(req) {\n  try {\n    await connectToDB();\n\n    const isAuthUser = await AuthUser(req)\n\n    console.log(isAuthUser , 'sangam');\n\n    if (isAuthUser?.role === \"admin\") {\n      const extractData = await req.json();\n\n      const {\n        name,\n        description,\n        price,\n        imageUrl,\n        category,\n        sizes,\n        deliveryInfo,\n        onSale,\n        priceDrop,\n      } = extractData;\n\n      const { error } = AddNewProductSchema.validate({\n        name,\n        description,\n        price,\n        imageUrl,\n        category,\n        sizes,\n        deliveryInfo,\n        onSale,\n        priceDrop,\n      });\n\n      if (error) {\n        return NextResponse.json({\n          success: false,\n          message: error.details[0].message,\n        });\n      }\n\n      const newlyCreatedProduct = await Product.create(extractData);\n\n      if (newlyCreatedProduct) {\n        return NextResponse.json({\n          success: true,\n          message: \"Product added successfully\",\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"Failed to add the product ! please try again\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not autorized !\",\n      });\n    }\n  } catch (error) {\n    console.log(error);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/admin/all-products/route.js",
    "content": "import connectToDB from \"@/database\";\nimport Product from \"@/models/product\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(req) {\n  try {\n    await connectToDB();\n\n      const extractAllproducts = await Product.find({});\n\n      if (extractAllproducts) {\n        return NextResponse.json({\n          success: true,\n          data: extractAllproducts,\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          status: 204,\n          message: \"No Products found\",\n        });\n      }\n  } catch (error) {\n    console.log(error);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/admin/delete-product/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Product from \"@/models/product\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function DELETE(req) {\n  try {\n    await connectToDB();\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser?.role === \"admin\") {\n      const { searchParams } = new URL(req.url);\n      const id = searchParams.get(\"id\");\n\n      if (!id)\n        return NextResponse.json({\n          success: false,\n          message: \"Product ID is required\",\n        });\n\n      const deletedProduct = await Product.findByIdAndDelete(id);\n\n      if (deletedProduct) {\n        return NextResponse.json({\n          success: true,\n          message: \"Product deleted successfully\",\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"Failed to delete the product ! Please try again\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (e) {\n    console.log(error);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/admin/orders/get-all-orders/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Order from \"@/models/order\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(req) {\n  try {\n    await connectToDB();\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser?.role === \"admin\") {\n      const getAllOrders = await Order.find({})\n        .populate(\"orderItems.product\")\n        .populate(\"user\");\n\n      if (getAllOrders) {\n        return NextResponse.json({\n          success: true,\n          data: getAllOrders,\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message:\n            \"failed to fetch the orders ! Please try again after some time.\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not autorized !\",\n      });\n    }\n  } catch (e) {\n    console.log(e);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/admin/orders/update-order/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Order from \"@/models/order\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function PUT(req) {\n  try {\n    await connectToDB();\n    const isAuthUser = await AuthUser(req);\n    const data = await req.json();\n\n    if (isAuthUser?.role === \"admin\") {\n      const {\n        _id,\n        shippingAddress,\n        orderItems,\n        paymentMethod,\n        isPaid,\n        paidAt,\n        isProcessing,\n      } = data;\n\n      const updateOrder = await Order.findOneAndUpdate(\n        { _id: _id },\n        {\n          shippingAddress,\n          orderItems,\n          paymentMethod,\n          isPaid,\n          paidAt,\n          isProcessing,\n        },\n        { new: true }\n      );\n\n      if (updateOrder) {\n        return NextResponse.json({\n          success: true,\n          message: \"Order status updated successfully! \",\n        });\n      } else {\n        return NextResponse.json({\n          success: true,\n          message: \"failed to update the status of order\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not autorized !\",\n      });\n    }\n  } catch (e) {\n    console.log(e);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/admin/product-by-category/route.js",
    "content": "import connectToDB from \"@/database\";\nimport Product from \"@/models/product\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(req) {\n  try {\n    await connectToDB();\n    const { searchParams } = new URL(req.url);\n    const id = searchParams.get(\"id\");\n    const getData = await Product.find({ category: id });\n\n    if (getData) {\n      return NextResponse.json({\n        success: true,\n        data: getData,\n      });\n    } else {\n      return NextResponse.json({\n        success: false,\n        status: 204,\n        message: \"No Products found !\",\n      });\n    }\n  } catch (e) {\n    console.log(error);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/admin/product-by-id/route.js",
    "content": "import connectToDB from \"@/database\";\nimport Product from \"@/models/product\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(req) {\n  try {\n    await connectToDB();\n    const { searchParams } = new URL(req.url);\n    const productId = searchParams.get(\"id\");\n\n    if (!productId) {\n      return NextResponse.json({\n        success: false,\n        status: 400,\n        message: \"Product id is required\",\n      });\n    }\n    const getData = await Product.find({ _id: productId });\n\n    if (getData && getData.length) {\n      return NextResponse.json({ success: true, data: getData[0] });\n    } else {\n      return NextResponse.json({\n        success: false,\n        status: 204,\n        message: \"No Product found\",\n      });\n    }\n  } catch (error) {\n    console.log(error);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/admin/update-product/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Product from \"@/models/product\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function PUT(req) {\n  try {\n    await connectToDB();\n\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser?.role === \"admin\") {\n      const extractData = await req.json();\n      const {\n        _id,\n        name,\n        price,\n        description,\n        category,\n        sizes,\n        deliveryInfo,\n        onSale,\n        priceDrop,\n        imageUrl,\n      } = extractData;\n\n      const updatedProduct = await Product.findOneAndUpdate(\n        {\n          _id: _id,\n        },\n        {\n          name,\n          price,\n          description,\n          category,\n          sizes,\n          deliveryInfo,\n          onSale,\n          priceDrop,\n          imageUrl,\n        },\n        { new: true }\n      );\n\n      if (updatedProduct) {\n        return NextResponse.json({\n          success: true,\n          message: \"Product updated successfully\",\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"Failed to update the product ! Please try again later\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (e) {\n    console.log(error);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/cart/add-to-cart/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Cart from \"@/models/cart\";\nimport Joi from \"joi\";\nimport { NextResponse } from \"next/server\";\n\nconst AddToCart = Joi.object({\n  userID: Joi.string().required(),\n  productID: Joi.string().required(),\n});\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function POST(req) {\n  try {\n    await connectToDB();\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser) {\n      const data = await req.json();\n      const {productID , userID} = data;\n\n      const { error } = AddToCart.validate({ userID, productID });\n\n      if (error) {\n        return NextResponse.json({\n          success: false,\n          message: error.details[0].message,\n        });\n      }\n\n      console.log(productID, userID);\n\n      const isCurrentCartItemAlreadyExists = await Cart.find({\n        productID: productID,\n        userID: userID,\n      });\n\n      console.log(isCurrentCartItemAlreadyExists);\n      \n\n      if (isCurrentCartItemAlreadyExists?.length > 0) {\n        return NextResponse.json({\n          success: false,\n          message:\n            \"Product is already added in cart! Please add different product\",\n        });\n      }\n\n      const saveProductToCart = await Cart.create(data);\n\n      console.log(saveProductToCart);\n\n      if (saveProductToCart) {\n        return NextResponse.json({\n          success: true,\n          message: \"Product is added to cart !\",\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"failed to add the product to cart ! Please try again.\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (e) {\n    console.log(e);\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/cart/all-cart-items/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Cart from \"@/models/cart\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(req) {\n  try {\n    await connectToDB();\n\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser) {\n      const { searchParams } = new URL(req.url);\n      const id = searchParams.get(\"id\");\n\n      if (!id)\n        return NextResponse.json({\n          success: false,\n          message: \"Please login in!\",\n        });\n      const extractAllCartItems = await Cart.find({ userID: id }).populate(\n        \"productID\"\n      );\n\n      if (extractAllCartItems) {\n        return NextResponse.json({ success: true, data: extractAllCartItems });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"No Cart items are found !\",\n          status: 204,\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (e) {\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/cart/delete-from-cart/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Cart from \"@/models/cart\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function DELETE(req) {\n  try {\n    await connectToDB();\n    const isAuthUser = await AuthUser(req);\n    if (isAuthUser) {\n      const { searchParams } = new URL(req.url);\n      const id = searchParams.get(\"id\");\n      if (!id)\n        return NextResponse.json({\n          success: false,\n          message: \"Cart Item ID is required\",\n        });\n\n      const deleteCartItem = await Cart.findByIdAndDelete(id);\n\n      if (deleteCartItem) {\n        return NextResponse.json({\n          success: true,\n          message: \"Cart Item deleted successfully\",\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"Failed to delete Cart item ! Please try again.\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (error) {\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/login/route.js",
    "content": "import connectToDB from \"@/database\";\nimport User from \"@/models/user\";\nimport { compare } from \"bcryptjs\";\nimport Joi from \"joi\";\nimport jwt from \"jsonwebtoken\";\nimport { NextResponse } from \"next/server\";\n\nconst schema = Joi.object({\n  email: Joi.string().email().required(),\n  password: Joi.string().required(),\n});\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function POST(req) {\n  await connectToDB();\n\n  const { email, password } = await req.json();\n\n  const { error } = schema.validate({ email, password });\n\n  if (error) {\n    return NextResponse.json({\n      success: false,\n      message: error.details[0].message,\n    });\n  }\n\n  try {\n    const checkUser = await User.findOne({ email });\n    if (!checkUser) {\n      return NextResponse.json({\n        success: false,\n        message: \"Account not found with this email\",\n      });\n    }\n\n    const checkPassword = await compare(password, checkUser.password);\n    if (!checkPassword) {\n      return NextResponse.json({\n        success: false,\n        message: \"Incorrect password. Please try again !\",\n      });\n    }\n\n    const token = jwt.sign(\n      {\n        id: checkUser._id,\n        email: checkUser?.email,\n        role: checkUser?.role,\n      },\n      \"default_secret_key\",\n      { expiresIn: \"1d\" }\n    );\n\n    const finalData = {\n      token,\n      user: {\n        email: checkUser.email,\n        name: checkUser.name,\n        _id: checkUser._id,\n        role: checkUser.role,\n      },\n    };\n\n    return NextResponse.json({\n      success: true,\n      message: \"Login successfull!\",\n      finalData,\n    });\n  } catch (e) {\n    console.log(\"Error while logging In. Please try again\");\n\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/order/create-order/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Cart from \"@/models/cart\";\nimport Order from \"@/models/order\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function POST(req) {\n  try {\n    await connectToDB();\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser) {\n      const data = await req.json();\n      const { user } = data;\n\n      const saveNewOrder = await Order.create(data);\n\n      if (saveNewOrder) {\n        await Cart.deleteMany({ userID: user });\n\n        return NextResponse.json({\n          success: true,\n          message: \"Products are on the way !\",\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"Failed to create a order ! Please try again\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authticated\",\n      });\n    }\n  } catch (e) {\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/order/get-all-orders/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Order from \"@/models/order\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(req) {\n  try {\n    await connectToDB();\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser) {\n      const { searchParams } = new URL(req.url);\n      const id = searchParams.get(\"id\");\n\n      const extractAllOrders = await Order.find({ user: id }).populate(\n        \"orderItems.product\"\n      );\n\n      if (extractAllOrders) {\n        return NextResponse.json({\n          success: true,\n          data: extractAllOrders,\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"Failed to get all orders ! Please try again\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authticated\",\n      });\n    }\n  } catch (e) {\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/order/order-details/route.js",
    "content": "import connectToDB from \"@/database\";\nimport AuthUser from \"@/middleware/AuthUser\";\nimport Order from \"@/models/order\";\nimport { NextResponse } from \"next/server\";\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function GET(req) {\n  try {\n    await connectToDB();\n    const isAuthUser = await AuthUser(req);\n\n    if (isAuthUser) {\n      const { searchParams } = new URL(req.url);\n      const id = searchParams.get(\"id\");\n\n      if (!id)\n        return NextResponse.json({\n          success: false,\n          message: \"Product ID is required\",\n        });\n\n      const extractOrderDetails = await Order.findById(id).populate(\n        \"orderItems.product\"\n      );\n\n      if (extractOrderDetails) {\n        return NextResponse.json({\n          success: true,\n          data: extractOrderDetails,\n        });\n      } else {\n        return NextResponse.json({\n          success: false,\n          message: \"Failed to get order details ! Please try again\",\n        });\n      }\n    } else {\n      return NextResponse.json({\n        success: false,\n        message: \"You are not authticated\",\n      });\n    }\n  } catch (e) {\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/register/route.js",
    "content": "import connectToDB from \"@/database\";\nimport User from \"@/models/user\";\nimport { hash } from \"bcryptjs\";\nimport Joi from \"joi\";\nimport { NextResponse } from \"next/server\";\n\nconst schema = Joi.object({\n  name: Joi.string().required(),\n  email: Joi.string().email().required(),\n  password: Joi.string().min(6).required(),\n  role: Joi.string().required(),\n});\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function POST(req) {\n  await connectToDB();\n\n  const { name, email, password, role } = await req.json();\n  //validate the schema\n\n  const { error } = schema.validate({ name, email, password, role });\n\n  if (error) {\n    console.log(error);\n    return NextResponse.json({\n      success: false,\n      message: error.details[0].message,\n    });\n  }\n\n  try {\n    //check if the user is exists or not\n\n    const isUserAlreadyExists = await User.findOne({ email });\n\n    if (isUserAlreadyExists) {\n      return NextResponse.json({\n        success: false,\n        message: \"User is already exists. Please try with different email.\",\n      });\n    } else {\n      const hashPassword = await hash(password, 12);\n\n      const newlyCreatedUser = await User.create({\n        name,\n        email,\n        password: hashPassword,\n        role,\n      });\n\n      if (newlyCreatedUser) {\n        return NextResponse.json({\n          success: true,\n          message: \"Account created successfully.\",\n        });\n      }\n    }\n  } catch (error) {\n    console.log(\"Error while new user registration. Please try again\");\n\n    return NextResponse.json({\n      success: false,\n      message: \"Something went wrong ! Please try again later\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/api/stripe/route.js",
    "content": "import AuthUser from \"@/middleware/AuthUser\";\nimport { NextResponse } from \"next/server\";\n\nconst stripe = require(\"stripe\")(\n  \"sk_test_51NMv6ZSC6E6fnyMeTYV3h3Xge6Tot3xYQVEO6KMpiB5A6bKIrRS9YymIBEupAFqF0XM274IwwU2Zq7EXx1Pn8LiA00SyPEZqk9\"\n);\n\nexport const dynamic = \"force-dynamic\";\n\nexport async function POST(req) {\n  try {\n    const isAuthUser = await AuthUser(req);\n    if (isAuthUser) {\n      const res = await req.json();\n\n      const session = await stripe.checkout.sessions.create({\n        payment_method_types: [\"card\"],\n        line_items: res,\n        mode: \"payment\",\n        success_url: \"http://localhost:3000/checkout\" + \"?status=success\",\n        cancel_url: \"http://localhost:3000/checkout\" + \"?status=cancel\",\n      });\n\n      return NextResponse.json({\n        success: true,\n        id: session.id,\n      });\n    } else {\n      return NextResponse.json({\n        success: true,\n        message: \"You are not authenticated\",\n      });\n    }\n  } catch (e) {\n    console.log(e);\n    return NextResponse.json({\n      status: 500,\n      success: false,\n      message: \"Something went wrong ! Please try again\",\n    });\n  }\n}\n"
  },
  {
    "path": "src/app/cart/page.js",
    "content": "\"use client\";\n\nimport CommonCart from \"@/components/CommonCart\";\nimport { GlobalContext } from \"@/context\";\nimport { deleteFromCart, getAllCartItems } from \"@/services/cart\";\nimport { useContext, useEffect } from \"react\";\nimport { PulseLoader } from \"react-spinners\";\nimport { toast } from \"react-toastify\";\n\nexport default function Cart() {\n  const {\n    user,\n    setCartItems,\n    cartItems,\n    pageLevelLoader,\n    setPageLevelLoader,\n    setComponentLevelLoader,\n    componentLevelLoader,\n  } = useContext(GlobalContext);\n\n  async function extractAllCartItems() {\n    setPageLevelLoader(true);\n    const res = await getAllCartItems(user?._id);\n\n    if (res.success) {\n      const updatedData =\n        res.data && res.data.length\n          ? res.data.map((item) => ({\n              ...item,\n              productID: {\n                ...item.productID,\n                price:\n                  item.productID.onSale === \"yes\"\n                    ? parseInt(\n                        (\n                          item.productID.price -\n                          item.productID.price * (item.productID.priceDrop / 100)\n                        ).toFixed(2)\n                      )\n                    : item.productID.price,\n              },\n            }))\n          : [];\n      setCartItems(updatedData);\n      setPageLevelLoader(false);\n      localStorage.setItem(\"cartItems\", JSON.stringify(updatedData));\n    }\n\n    console.log(res);\n  }\n\n  useEffect(() => {\n    if (user !== null) extractAllCartItems();\n  }, [user]);\n\n  async function handleDeleteCartItem(getCartItemID) {\n    setComponentLevelLoader({ loading: true, id: getCartItemID });\n    const res = await deleteFromCart(getCartItemID);\n\n    if (res.success) {\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n\n      extractAllCartItems();\n    } else {\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setComponentLevelLoader({ loading: false, id: getCartItemID });\n    }\n  }\n\n  if (pageLevelLoader) {\n    return (\n      <div className=\"w-full min-h-screen flex justify-center items-center\">\n        <PulseLoader\n          color={\"#000000\"}\n          loading={pageLevelLoader}\n          size={30}\n          data-testid=\"loader\"\n        />\n      </div>\n    );\n  }\n\n  return (\n    <CommonCart\n      componentLevelLoader={componentLevelLoader}\n      handleDeleteCartItem={handleDeleteCartItem}\n      cartItems={cartItems}\n    />\n  );\n}\n"
  },
  {
    "path": "src/app/checkout/page.js",
    "content": "\"use client\";\n\nimport Notification from \"@/components/Notification\";\nimport { GlobalContext } from \"@/context\";\nimport { fetchAllAddresses } from \"@/services/address\";\nimport { createNewOrder } from \"@/services/order\";\nimport { callStripeSession } from \"@/services/stripe\";\nimport { loadStripe } from \"@stripe/stripe-js\";\nimport { useRouter, useSearchParams } from \"next/navigation\";\nimport { useContext, useEffect, useState } from \"react\";\nimport { PulseLoader } from \"react-spinners\";\nimport { toast } from \"react-toastify\";\n\nexport default function Checkout() {\n  const {\n    cartItems,\n    user,\n    addresses,\n    setAddresses,\n    checkoutFormData,\n    setCheckoutFormData,\n  } = useContext(GlobalContext);\n\n  const [selectedAddress, setSelectedAddress] = useState(null);\n  const [isOrderProcessing, setIsOrderProcessing] = useState(false);\n  const [orderSuccess, setOrderSuccess] = useState(false);\n\n  const router = useRouter();\n  const params = useSearchParams();\n\n  const publishableKey =\n    \"pk_test_51NMv6ZSC6E6fnyMeRIEb9oEXdGRCC9yrBTT4xWHgcjWOuFcqFiAHErvaS50K1hl5t5WJXVGfLLWxvb705IWJhA3300yCcrMnlM\";\n  const stripePromise = loadStripe(publishableKey);\n\n  console.log(cartItems);\n\n  async function getAllAddresses() {\n    const res = await fetchAllAddresses(user?._id);\n\n    if (res.success) {\n      setAddresses(res.data);\n    }\n  }\n\n  useEffect(() => {\n    if (user !== null) getAllAddresses();\n  }, [user]);\n\n  useEffect(() => {\n    async function createFinalOrder() {\n      const isStripe = JSON.parse(localStorage.getItem(\"stripe\"));\n\n      if (\n        isStripe &&\n        params.get(\"status\") === \"success\" &&\n        cartItems &&\n        cartItems.length > 0\n      ) {\n        setIsOrderProcessing(true);\n        const getCheckoutFormData = JSON.parse(\n          localStorage.getItem(\"checkoutFormData\")\n        );\n\n        const createFinalCheckoutFormData = {\n          user: user?._id,\n          shippingAddress: getCheckoutFormData.shippingAddress,\n          orderItems: cartItems.map((item) => ({\n            qty: 1,\n            product: item.productID,\n          })),\n          paymentMethod: \"Stripe\",\n          totalPrice: cartItems.reduce(\n            (total, item) => item.productID.price + total,\n            0\n          ),\n          isPaid: true,\n          isProcessing: true,\n          paidAt: new Date(),\n        };\n\n        const res = await createNewOrder(createFinalCheckoutFormData);\n\n        if (res.success) {\n          setIsOrderProcessing(false);\n          setOrderSuccess(true);\n          toast.success(res.message, {\n            position: toast.POSITION.TOP_RIGHT,\n          });\n        } else {\n          setIsOrderProcessing(false);\n          setOrderSuccess(false);\n          toast.error(res.message, {\n            position: toast.POSITION.TOP_RIGHT,\n          });\n        }\n      }\n    }\n\n    createFinalOrder();\n  }, [params.get(\"status\"), cartItems]);\n\n  function handleSelectedAddress(getAddress) {\n    if (getAddress._id === selectedAddress) {\n      setSelectedAddress(null);\n      setCheckoutFormData({\n        ...checkoutFormData,\n        shippingAddress: {},\n      });\n\n      return;\n    }\n\n    setSelectedAddress(getAddress._id);\n    setCheckoutFormData({\n      ...checkoutFormData,\n      shippingAddress: {\n        ...checkoutFormData.shippingAddress,\n        fullName: getAddress.fullName,\n        city: getAddress.city,\n        country: getAddress.country,\n        postalCode: getAddress.postalCode,\n        address: getAddress.address,\n      },\n    });\n  }\n\n  async function handleCheckout() {\n    const stripe = await stripePromise;\n\n    const createLineItems = cartItems.map((item) => ({\n      price_data: {\n        currency: \"usd\",\n        product_data: {\n          images: [item.productID.imageUrl],\n          name: item.productID.name,\n        },\n        unit_amount: item.productID.price * 100,\n      },\n      quantity: 1,\n    }));\n\n    const res = await callStripeSession(createLineItems);\n    setIsOrderProcessing(true);\n    localStorage.setItem(\"stripe\", true);\n    localStorage.setItem(\"checkoutFormData\", JSON.stringify(checkoutFormData));\n\n    const { error } = await stripe.redirectToCheckout({\n      sessionId: res.id,\n    });\n\n    console.log(error);\n  }\n\n  console.log(checkoutFormData);\n\n  useEffect(() => {\n    if (orderSuccess) {\n      setTimeout(() => {\n        // setOrderSuccess(false);\n        router.push(\"/orders\");\n      }, [2000]);\n    }\n  }, [orderSuccess]);\n\n  if (orderSuccess) {\n    return (\n      <section className=\"h-screen bg-gray-200\">\n        <div className=\"mx-auto px-4 sm:px-6 lg:px-8\">\n          <div className=\"mx-auto mt-8 max-w-screen-xl px-4 sm:px-6 lg:px-8 \">\n            <div className=\"bg-white shadow\">\n              <div className=\"px-4 py-6 sm:px-8 sm:py-10 flex flex-col gap-5\">\n                <h1 className=\"font-bold text-lg\">\n                  Your payment is successfull and you will be redirected to\n                  orders page in 2 seconds !\n                </h1>\n              </div>\n            </div>\n          </div>\n        </div>\n      </section>\n    );\n  }\n\n  if (isOrderProcessing) {\n    return (\n      <div className=\"w-full min-h-screen flex justify-center items-center\">\n        <PulseLoader\n          color={\"#000000\"}\n          loading={isOrderProcessing}\n          size={30}\n          data-testid=\"loader\"\n        />\n      </div>\n    );\n  }\n\n  return (\n    <div>\n      <div className=\"grid sm:px-10 lg:grid-cols-2 lg:px-20 xl:px-32\">\n        <div className=\"px-4 pt-8\">\n          <p className=\"font-medium text-xl\">Cart Summary</p>\n          <div className=\"mt-8 space-y-3 rounded-lg border bg-white px-2 py-4 sm:px-5\">\n            {cartItems && cartItems.length ? (\n              cartItems.map((item) => (\n                <div\n                  className=\"flex flex-col rounded-lg bg-white sm:flex-row\"\n                  key={item._id}\n                >\n                  <img\n                    src={item && item.productID && item.productID.imageUrl}\n                    alt=\"Cart Item\"\n                    className=\"m-2 h-24 w-28 rounded-md border object-cover object-center\"\n                  />\n                  <div className=\"flex w-full flex-col px-4 py-4\">\n                    <span className=\"font-bold\">\n                      {item && item.productID && item.productID.name}\n                    </span>\n                    <span className=\"font-semibold\">\n                      {item && item.productID && item.productID.price}\n                    </span>\n                  </div>\n                </div>\n              ))\n            ) : (\n              <div>Your cart is empty</div>\n            )}\n          </div>\n        </div>\n        <div className=\"mt-10 bg-gray-50 px-4 pt-8 lg:mt-0\">\n          <p className=\"text-xl font-medium\">Shipping address details</p>\n          <p className=\"text-gray-400 font-bold\">\n            Complete your order by selecting address below\n          </p>\n          <div className=\"w-full mt-6 mr-0 mb-0 ml-0 space-y-6\">\n            {addresses && addresses.length ? (\n              addresses.map((item) => (\n                <div\n                  onClick={() => handleSelectedAddress(item)}\n                  key={item._id}\n                  className={`border p-6 ${\n                    item._id === selectedAddress ? \"border-red-900\" : \"\"\n                  }`}\n                >\n                  <p>Name : {item.fullName}</p>\n                  <p>Address : {item.address}</p>\n                  <p>City : {item.city}</p>\n                  <p>Country : {item.country}</p>\n                  <p>PostalCode : {item.postalCode}</p>\n                  <button className=\"mt-5 mr-5 inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\">\n                    {item._id === selectedAddress\n                      ? \"Selected Address\"\n                      : \"Select Address\"}\n                  </button>\n                </div>\n              ))\n            ) : (\n              <p>No addresses added</p>\n            )}\n          </div>\n          <button\n            onClick={() => router.push(\"/account\")}\n            className=\"mt-5 mr-5 inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n          >\n            Add new address\n          </button>\n          <div className=\"mt-6 border-t border-b py-2\">\n            <div className=\"flex items-center justify-between\">\n              <p className=\"text-sm font-medium text-gray-900\">Subtotal</p>\n              <p className=\"text-lg font-bold text-gray-900\">\n                $\n                {cartItems && cartItems.length\n                  ? cartItems.reduce(\n                      (total, item) => item.productID.price + total,\n                      0\n                    )\n                  : \"0\"}\n              </p>\n            </div>\n            <div className=\"flex items-center justify-between\">\n              <p className=\"text-sm font-medium text-gray-900\">Shipping</p>\n              <p className=\"text-lg font-bold text-gray-900\">Free</p>\n            </div>\n            <div className=\"flex items-center justify-between\">\n              <p className=\"text-sm font-medium text-gray-900\">Total</p>\n              <p className=\"text-lg font-bold text-gray-900\">\n                $\n                {cartItems && cartItems.length\n                  ? cartItems.reduce(\n                      (total, item) => item.productID.price + total,\n                      0\n                    )\n                  : \"0\"}\n              </p>\n            </div>\n            <div className=\"pb-10\">\n              <button\n                disabled={\n                  (cartItems && cartItems.length === 0) ||\n                  Object.keys(checkoutFormData.shippingAddress).length === 0\n                }\n                onClick={handleCheckout}\n                className=\"disabled:opacity-50 mt-5 mr-5 w-full  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n              >\n                Checkout\n              </button>\n            </div>\n          </div>\n        </div>\n      </div>\n      <Notification />\n    </div>\n  );\n}\n"
  },
  {
    "path": "src/app/globals.css",
    "content": "@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\n:root {\n  --foreground-rgb: 0, 0, 0;\n  --background-start-rgb: 214, 219, 220;\n  --background-end-rgb: 255, 255, 255;\n}\n\n@media (prefers-color-scheme: dark) {\n  :root {\n    --foreground-rgb: 255, 255, 255;\n    --background-start-rgb: 0, 0, 0;\n    --background-end-rgb: 0, 0, 0;\n  }\n}\n\nbody {\n  color: rgb(var(--foreground-rgb));\n  min-height: 100vh;\n  height: 100%;\n}\n\nbody::-webkit-scrollbar {\n  width: 5px;\n}\n \nbody::-webkit-scrollbar-track {\n  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);\n}\n \nbody::-webkit-scrollbar-thumb {\n  background-color: darkgrey;\n  outline: 1px solid slategrey;\n}\n"
  },
  {
    "path": "src/app/layout.js",
    "content": "import GlobalState from '@/context'\nimport './globals.css'\nimport { Inter } from 'next/font/google'\nimport Navbar from '@/components/Navbar'\n\nconst inter = Inter({ subsets: ['latin'] })\n\nexport const metadata = {\n  title: 'Create Next App',\n  description: 'Generated by create next app',\n}\n\nexport default function RootLayout({ children }) {\n  return (\n    <html lang=\"en\">\n      <body className={inter.className}>\n        <GlobalState>\n          <Navbar/>\n          <main className='flex min-h-screen flex-col mt-[80px]'>{children}</main>\n        </GlobalState>\n      </body>\n    </html>\n  )\n}\n"
  },
  {
    "path": "src/app/login/page.js",
    "content": "\"use client\";\n\nimport InputComponent from \"@/components/FormElements/InputComponent\";\nimport ComponentLevelLoader from \"@/components/Loader/componentlevel\";\nimport Notification from \"@/components/Notification\";\nimport { GlobalContext } from \"@/context\";\nimport { login } from \"@/services/login\";\nimport { loginFormControls } from \"@/utils\";\nimport Cookies from \"js-cookie\";\nimport { useRouter } from \"next/navigation\";\nimport { useContext, useEffect, useState } from \"react\";\nimport { toast } from \"react-toastify\";\n\nconst initialFormdata = {\n  email: \"\",\n  password: \"\",\n};\n\nexport default function Login() {\n  const [formData, setFormData] = useState(initialFormdata);\n  const {\n    isAuthUser,\n    setIsAuthUser,\n    user,\n    setUser,\n    componentLevelLoader,\n    setComponentLevelLoader,\n  } = useContext(GlobalContext);\n\n  const router = useRouter();\n\n  console.log(formData);\n\n  function isValidForm() {\n    return formData &&\n      formData.email &&\n      formData.email.trim() !== \"\" &&\n      formData.password &&\n      formData.password.trim() !== \"\"\n      ? true\n      : false;\n  }\n\n  async function handleLogin() {\n    setComponentLevelLoader({ loading: true, id: \"\" });\n    const res = await login(formData);\n\n    console.log(res);\n\n    if (res.success) {\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setIsAuthUser(true);\n      setUser(res?.finalData?.user);\n      setFormData(initialFormdata);\n      Cookies.set(\"token\", res?.finalData?.token);\n      localStorage.setItem(\"user\", JSON.stringify(res?.finalData?.user));\n      setComponentLevelLoader({ loading: false, id: \"\" });\n    } else {\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setIsAuthUser(false);\n      setComponentLevelLoader({ loading: false, id: \"\" });\n    }\n  }\n\n  console.log(isAuthUser, user);\n\n  useEffect(() => {\n    if (isAuthUser) router.push(\"/\");\n  }, [isAuthUser]);\n\n  return (\n    <div className=\"bg-white relative\">\n      <div className=\"flex flex-col items-center justify-between pt-0 pr-10 pb-0 pl-10 mt-8 mr-auto xl:px-5 lg:flex-row\">\n        <div className=\"flex flex-col justify-center items-center w-full pr-10 pl-10 lg:flex-row\">\n          <div className=\"w-full mt-10 mr-0 mb-0 ml-0 relative max-w-2xl lg:mt-0 lg:w-5/12\">\n            <div className=\"flex flex-col items-center justify-start pt-10 pr-10 pb-10 pl-10 bg-white shadow-2xl rounded-xl relative z-10\">\n              <p className=\"w-full text-4xl font-medium text-center font-serif\">\n                Login\n              </p>\n              <div className=\"w-full mt-6 mr-0 mb-0 ml-0 relative space-y-8\">\n                {loginFormControls.map((controlItem) =>\n                  controlItem.componentType === \"input\" ? (\n                    <InputComponent\n                      type={controlItem.type}\n                      placeholder={controlItem.placeholder}\n                      label={controlItem.label}\n                      value={formData[controlItem.id]}\n                      onChange={(event) => {\n                        setFormData({\n                          ...formData,\n                          [controlItem.id]: event.target.value,\n                        });\n                      }}\n                    />\n                  ) : null\n                )}\n                <button\n                  className=\"disabled:opacity-50 inline-flex w-full items-center justify-center bg-black px-6 py-4 text-lg \n                     text-white transition-all duration-200 ease-in-out focus:shadow font-medium uppercase tracking-wide\n                     \"\n                  disabled={!isValidForm()}\n                  onClick={handleLogin}\n                >\n                  {componentLevelLoader && componentLevelLoader.loading ? (\n                    <ComponentLevelLoader\n                      text={\"Logging In\"}\n                      color={\"#ffffff\"}\n                      loading={\n                        componentLevelLoader && componentLevelLoader.loading\n                      }\n                    />\n                  ) : (\n                    \"Login\"\n                  )}\n                </button>\n                <div className=\"flex flex-col gap-2\">\n                  <p>New to website ?</p>\n                  <button\n                    className=\"inline-flex w-full items-center justify-center bg-black px-6 py-4 text-lg \n                     text-white transition-all duration-200 ease-in-out focus:shadow font-medium uppercase tracking-wide\n                     \"\n                    onClick={() => router.push(\"/register\")}\n                  >\n                    Register\n                  </button>\n                </div>\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n      <Notification />\n    </div>\n  );\n}\n"
  },
  {
    "path": "src/app/orders/[order-details]/page.js",
    "content": "\"use client\";\n\nimport { GlobalContext } from \"@/context\";\nimport { getOrderDetails } from \"@/services/order\";\nimport { useParams, useRouter } from \"next/navigation\";\nimport { useContext, useEffect } from \"react\";\nimport { PulseLoader } from \"react-spinners\";\n\nexport default function OrderDetails() {\n  const {\n    pageLevelLoader,\n    setPageLevelLoader,\n    orderDetails,\n    setOrderDetails,\n    user,\n  } = useContext(GlobalContext);\n\n  const params = useParams();\n  const router = useRouter()\n\n  async function extractOrderDetails() {\n    setPageLevelLoader(true);\n\n    const res = await getOrderDetails(params[\"order-details\"]);\n\n    if (res.success) {\n      setPageLevelLoader(false);\n      setOrderDetails(res.data);\n    } else {\n      setPageLevelLoader(false);\n    }\n\n    console.log(res);\n  }\n\n  useEffect(() => {\n    extractOrderDetails();\n  }, []);\n\n  if (pageLevelLoader) {\n    return (\n      <div className=\"w-full min-h-screen flex justify-center items-center\">\n        <PulseLoader\n          color={\"#000000\"}\n          loading={pageLevelLoader}\n          size={30}\n          data-testid=\"loader\"\n        />\n      </div>\n    );\n  }\n\n  return (\n    <div className=\"py-14 px-4 md:px-6\">\n      <div className=\"flex justify-start items-start space-y-2 flex-col\">\n        <h1 className=\"text-3xl lg:text-4xl font-bold leading-7 lg:leading-9 text-gray-900\">\n          Order #{orderDetails && orderDetails._id}\n        </h1>\n        <p className=\"text-base font-medium leadong-6 text-gray-600\">\n          {orderDetails &&\n            orderDetails.createdAt &&\n            orderDetails.createdAt.split(\"T\")[0]}{\" \"}\n          |{\" \"}\n          {orderDetails &&\n            orderDetails.createdAt &&\n            orderDetails.createdAt.split(\"T\")[1].split(\".\")[0]}\n        </p>\n      </div>\n      <div className=\"mt-10 flex flex-col justify-center xl:flex-row items-stretch w-full xl:space-x-8 md:space-y-6 xl:space-y-0\">\n        <div className=\"flex flex-col justify-start items-start w-full space-y-4 md:space-y-6 xl:space-y-8\">\n          <div className=\"flex flex-col justify-start items-start bg-gray-50 px-4 py-4 md:p-6 xl:p-8 w-full\">\n            <p className=\"font-bol text-lg \">Your order summary</p>\n            {orderDetails &&\n            orderDetails.orderItems &&\n            orderDetails.orderItems.length\n              ? orderDetails.orderItems.map((item) => (\n                  <div\n                    key={item._id}\n                    className=\"mt-4 md:mt-6 flex flex-col md:flex-row justify-start items-start md:items-center md:space-x-6 xl:space-x-8 w-full\"\n                  >\n                    <div className=\"pb-4 md:pb-8 w-full md:w-40\">\n                      <img\n                        src={item && item.product && item.product.imageUrl}\n                        className=\"w-full hidden md:block\"\n                      />\n                    </div>\n                    <div className=\"border-b border-gray-300 md:flex-row flex-col flex justify-between items-start w-full pb-8 space-y-4 md:space-y-0\">\n                      <div className=\"w-full flex flex-col justify-start items-start space-y-8\">\n                        <h3 className=\"text-xl font-semibold leading-6 text-gray-900\">\n                          {item && item.product && item.product.name}\n                        </h3>\n                      </div>\n                      <div className=\"w-full flex justify-between items-start space-x-8\">\n                        <h3 className=\"text-xl font-semibold leading-6 text-gray-900\">\n                          ${item && item.product && item.product.price}\n                        </h3>\n                      </div>\n                    </div>\n                  </div>\n                ))\n              : null}\n          </div>\n          <div className=\"flex justify-center flex-col md:flex-row items-stretch w-full space-y-4 md:space-y-0 md:space-x-5 xl:space-x-8\">\n            <div className=\"flex flex-col px-4 py-6 md:p-6 xl:p-8 w-full bg-gray-50 space-y-6\">\n              <h3 className=\"text-xl font-semibold leading-6 text-gray-900\">\n                Summary\n              </h3>\n              <div className=\"flex justify-center items-center w-full space-y-4 flex-col border-gray-200 border-b pb-4\">\n                <div className=\"flex justify-between w-full\">\n                  <p className=\"text-base leading-5 text-gray-800\">Subtotal</p>\n                  <p className=\"text-base leading-5 text-gray-900\">\n                    ${orderDetails && orderDetails.totalPrice}\n                  </p>\n                </div>\n                <div className=\"flex justify-between w-full\">\n                  <p className=\"text-base leading-5 text-gray-800\">Shipping</p>\n                  <p className=\"text-base leading-5 text-gray-900\">Free</p>\n                </div>\n                <div className=\"flex justify-between w-full\">\n                  <p className=\"text-base leading-5 text-gray-800\">Subtotal</p>\n                  <p className=\"text-base leading-5 text-gray-900\">\n                    ${orderDetails && orderDetails.totalPrice}\n                  </p>\n                </div>\n              </div>\n            </div>\n          </div>\n        </div>\n        <div className=\"flex flex-col gap-5\">\n          <div className=\"bg-gray-50 w-full xl:w-96 flex  items-center md:items-start px-4 py-6 flex-col\">\n            <h3 className=\"text-xl font-semibold leading-6 text-gray-900\">\n              Customer Details\n            </h3>\n            <div className=\"flex flex-col justify-start items-start flex-shrink-0\">\n              <div className=\"flex gap-4 justify-center flex-col w-full md:justify-start   py-8 border-b border-gray-200\">\n                <p className=\"text-base font-semibold leading-4 text-left text-gray-950\">\n                  Name: {user?.name}\n                </p>\n                <p className=\"text-base font-semibold leading-4 text-left text-gray-950\">\n                  Email: {user?.email}\n                </p>\n              </div>\n            </div>\n          </div>\n          <div className=\"flex justify-between xl:h-full items-stretch w-full flex-col mt-6 md:mt-0\">\n            <div className=\"flex justify-center md:justify-start xl:flex-col flex-col md:space-x-6 lg:space-x-8 xl:space-x-0 space-y-4 md:space-y-0 xl:space-y-12 md:flex-row items-center md:items-start \">\n              <div className=\"flex justify-center md:justify-start items-center md:items-start flex-col space-y-4 xl:mt-8\">\n                <p>Shipping Address</p>\n                <p>\n                  Address :{\" \"}\n                  {orderDetails && orderDetails.shippingAddress.address}\n                </p>\n                <p>City :{orderDetails && orderDetails.shippingAddress.city}</p>\n                <p>\n                  Country :{\" \"}\n                  {orderDetails && orderDetails.shippingAddress.country}\n                </p>\n                <p>\n                  Postal Code :{\" \"}\n                  {orderDetails && orderDetails.shippingAddress.postalCode}\n                </p>\n              </div>\n            </div>\n          </div>\n          <button\n            onClick={() => router.push(`/`)}\n            className=\"mt-5 mr-5  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n          >\n            Shop Again\n          </button>\n        </div>\n      </div>\n    </div>\n  );\n}\n"
  },
  {
    "path": "src/app/orders/page.js",
    "content": "\"use client\";\n\nimport Notification from \"@/components/Notification\";\nimport { GlobalContext } from \"@/context\";\nimport { getAllOrdersForUser } from \"@/services/order\";\nimport { useRouter } from \"next/navigation\";\nimport { useContext, useEffect } from \"react\";\nimport { PulseLoader } from \"react-spinners\";\nimport { toast } from \"react-toastify\";\n\nexport default function Orders() {\n  const {\n    user,\n    pageLevelLoader,\n    setPageLevelLoader,\n    allOrdersForUser,\n    setAllOrdersForUser,\n  } = useContext(GlobalContext);\n\n  const router = useRouter();\n\n  async function extractAllOrders() {\n    setPageLevelLoader(true);\n    const res = await getAllOrdersForUser(user?._id);\n\n    if (res.success) {\n      setPageLevelLoader(false);\n\n      setAllOrdersForUser(res.data);\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n    } else {\n      setPageLevelLoader(false);\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n    }\n  }\n\n  useEffect(() => {\n    if (user !== null) extractAllOrders();\n  }, [user]);\n\n  console.log(allOrdersForUser);\n\n  if (pageLevelLoader) {\n    return (\n      <div className=\"w-full min-h-screen flex justify-center items-center\">\n        <PulseLoader\n          color={\"#000000\"}\n          loading={pageLevelLoader}\n          size={30}\n          data-testid=\"loader\"\n        />\n      </div>\n    );\n  }\n\n  return (\n    <section>\n      <div className=\"mx-auto px-4 sm:px-6 lg:px-8\">\n        <div className=\"mt-8 mx-auto max-w-screen-xl px-4 sm:px-6 lg:px-8\">\n          <div>\n            <div className=\"px-4 py-6 sm:px-8 sm:py-10\">\n              <div className=\"flow-root\">\n                {allOrdersForUser && allOrdersForUser.length ? (\n                  <ul className=\"flex flex-col gap-4\">\n                    {allOrdersForUser.map((item) => (\n                      <li\n                        key={item._id}\n                        className=\"bg-gray-200 shadow p-5 flex flex-col space-y-3 py-6 text-left\"\n                      >\n                        <div className=\"flex\">\n                          <h1 className=\"font-bold text-lg mb-3 flex-1\">\n                            #order: {item._id}\n                          </h1>\n                          <div className=\"flex items-center\">\n                            <p className=\"mr-3 text-sm font-medium text-gray-900\">\n                              Total paid amount\n                            </p>\n                            <p className=\"mr-3 text-2xl  font-semibold text-gray-900\">\n                              ${item.totalPrice}\n                            </p>\n                          </div>\n                        </div>\n                        <div className=\"flex gap-2\">\n                          {item.orderItems.map((orderItem, index) => (\n                            <div key={index} className=\"shrink-0\">\n                              <img\n                                alt=\"Order Item\"\n                                className=\"h-24 w-24 max-w-full rounded-lg object-cover\"\n                                src={\n                                  orderItem &&\n                                  orderItem.product &&\n                                  orderItem.product.imageUrl\n                                }\n                              />\n                            </div>\n                          ))}\n                        </div>\n                        <div className=\"flex gap-5\">\n                          <button className=\"disabled:opacity-50 mt-5 mr-5  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\">\n                            {item.isProcessing\n                              ? \"Order is Processing\"\n                              : \"Order is delivered\"}\n                          </button>\n                          <button\n                            onClick={() => router.push(`/orders/${item._id}`)}\n                            className=\" mt-5 mr-5  inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n                          >\n                            View Order Details\n                          </button>\n                        </div>\n                      </li>\n                    ))}\n                  </ul>\n                ) : null}\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n      <Notification />\n    </section>\n  );\n}\n"
  },
  {
    "path": "src/app/page.js",
    "content": "\"use client\";\n\nimport { GlobalContext } from \"@/context\";\nimport { getAllAdminProducts } from \"@/services/product\";\nimport { useRouter } from \"next/navigation\";\nimport { useContext, useEffect, useState } from \"react\";\n\nexport default function Home() {\n  const { isAuthUser } = useContext(GlobalContext);\n\n  const [products, setProducts] = useState([]);\n  const router = useRouter();\n\n  async function getListOfProducts() {\n    const res = await getAllAdminProducts();\n\n    if (res.success) {\n      setProducts(res.data);\n    }\n  }\n\n  useEffect(() => {\n    getListOfProducts();\n  }, []);\n\n  console.log(products);\n\n  return (\n    <main className=\"flex min-h-screen flex-col items-center justify-between p-24\">\n      <section className=\"\">\n        <div className=\"grid max-w-screen-xl px-4 py-8 mx-suto  lg:gap-8 xl:gap-0 lg:py-16 lg:grid-cols-12\">\n          <div className=\"mr-auto place-self-center lg:col-span-7\">\n            <h1 className=\"max-w-2xl mb-4 text-4xl font-extrabold tracking-tight leading-none md:text-5xl xl:text-6xl\">\n              Best Fashion Collection\n            </h1>\n            <p className=\"max-w-2xl mb-6 font-light text-gray-500 lg:mb-8 md:text-lg lg:text-xl\">\n              Quisquemos sodales suscipit tortor ditaemcos condimentum de cosmo\n              lacus meleifend menean diverra loremous.\n            </p>\n\n            <button\n              type=\"button\"\n              onClick={() => router.push(\"/product/listing/all-products\")}\n              className=\"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium uppercase tracking-wide text-white\"\n            >\n              Explore Shop Collection\n            </button>\n          </div>\n          <div className=\"hidden lg:mt-0 lg:col-span-5 lg:flex\">\n            <img\n              src=\"https://images.unsplash.com/photo-1483985988355-763728e1935b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1170&q=80\"\n              alt=\"Explore Shop Collection\"\n            />\n          </div>\n        </div>\n        <div className=\"max-w-screen-xl px-4 py-8 mx-auto sm:py-12 sm:px-6 lg:px-8\">\n          <div className=\"grid grid-cols-1 gap-4 lg:grid-cols-3 lg:items-stretch\">\n            <div className=\"grid p-6 bg-gray-100 rounded place-content-center sm:p-8\">\n              <div className=\"max-w-md mx-auto text-center lg:text-left\">\n                <div>\n                  <h2 className=\"text-xl font-bold text-gray-900 sm:text-3xl\">\n                    Summer Sale Collection\n                  </h2>\n                </div>\n                <button\n                  onClick={() => router.push(\"/product/listing/all-products\")}\n                  className=\"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium uppercase tracking-wide text-white\"\n                >\n                  Shop ALL\n                </button>\n              </div>\n            </div>\n            <div className=\"lg:col-span-2 lg:py-8\">\n              <ul className=\"grid grid-cols-2 gap-4\">\n                {products && products.length\n                  ? products\n                      .filter((item) => item.onSale === \"yes\")\n                      .splice(0, 2)\n                      .map((productItem) => (\n                        <li\n                          onClick={() =>\n                            router.push(`/product/${productItem._id}`)\n                          }\n                          className=\"cursor-pointer\"\n                          key={productItem._id}\n                        >\n                          <div>\n                            <img\n                              src={productItem.imageUrl}\n                              alt=\"Sale Product Item\"\n                              className=\"object-cover w-full rounded aspect-square\"\n                            />\n                          </div>\n                          <div className=\"mt-3\">\n                            <h3 className=\"font-medium text-gray-900\">\n                              {productItem.name}\n                            </h3>\n                            <p className=\"mt-1 text-sm text-gray-800\">\n                              ${productItem.price}{\" \"}\n                              <span className=\"text-red-700\">{`(-${productItem.priceDrop}%) Off`}</span>\n                            </p>\n                          </div>\n                        </li>\n                      ))\n                  : null}\n              </ul>\n            </div>\n          </div>\n        </div>\n        <div className=\"max-w-screen-xl px-4 py-8 mx-auto sm:px-6 sm:py-12 lg:px-8\">\n          <div className=\"text-center\">\n            <h2 className=\"text-xl font-bold text-gray-950 sm:text-3xl\">\n              SHOP BY CATEGORY\n            </h2>\n          </div>\n          <ul className=\"grid grid-cols-1 gap-4 mt-8 lg:grid-cols-3\">\n            <li>\n              <div className=\"relative block group\">\n                <img\n                  src=\"https://images.unsplash.com/photo-1618898909019-010e4e234c55?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80\"\n                  className=\"object-cover w-full aspect-square\"\n                />\n                <div className=\"absolute inset-0 flex flex-col items-start justify-end p-6\">\n                  <h3 className=\"text-xl font-medium text-white\">KIDS</h3>\n                  <button\n                    onClick={() => router.push(\"/product/listing/kids\")}\n                    className=\"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium uppercase tracking-wide text-white\"\n                  >\n                    Shop Now\n                  </button>\n                </div>\n              </div>\n            </li>\n            <li>\n              <div className=\"relative block group\">\n                <img\n                  src=\"https://images.unsplash.com/photo-1624623278313-a930126a11c3?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=774&q=80\"\n                  className=\"object-cover w-full aspect-square\"\n                />\n                <div className=\"absolute inset-0 flex flex-col items-start justify-end p-6\">\n                  <h3 className=\"text-xl font-medium text-white\">WOMEN</h3>\n                  <button\n                    onClick={() => router.push(\"/product/listing/women\")}\n                    className=\"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium uppercase tracking-wide text-white\"\n                  >\n                    Shop Now\n                  </button>\n                </div>\n              </div>\n            </li>\n            <li className=\"lg:col-span-2 lg:col-start-2 lg:row-span-2 lg:row-start-1\">\n              <div className=\"relative block group\">\n                <img\n                  src=\"https://images.unsplash.com/photo-1593795899768-947c4929449d?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2672&q=80\"\n                  className=\"object-cover w-full aspect-square\"\n                />\n                <div className=\"absolute inset-0 flex flex-col items-start justify-end p-6\">\n                  <h3 className=\"text-xl font-medium text-white\">MEN</h3>\n                  <button\n                    onClick={() => router.push(\"/product/listing/men\")}\n                    className=\"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium uppercase tracking-wide text-white\"\n                  >\n                    Shop Now\n                  </button>\n                </div>\n              </div>\n            </li>\n          </ul>\n        </div>\n      </section>\n    </main>\n  );\n}\n"
  },
  {
    "path": "src/app/product/[details]/page.js",
    "content": "import CommonDetails from \"@/components/CommonDetails\";\nimport { productById } from \"@/services/product\";\n\nexport default async function ProductDetails({ params }) {\n  const productDetailsData = await productById(params.details);\n\n  console.log(productDetailsData, \"sangam\");\n\n  return <CommonDetails item={productDetailsData && productDetailsData.data} />;\n}\n"
  },
  {
    "path": "src/app/product/listing/all-products/page.js",
    "content": "import CommonListing from \"@/components/CommonListing\";\nimport { getAllAdminProducts } from \"@/services/product\";\n\nexport default async function AllProducts() {\n  const getAllProducts = await getAllAdminProducts();\n\n  return <CommonListing data={getAllProducts && getAllProducts.data} />;\n}\n"
  },
  {
    "path": "src/app/product/listing/kids/page.js",
    "content": "import CommonListing from \"@/components/CommonListing\";\nimport { productByCategory } from \"@/services/product\";\n\nexport default async function KidsAllProducts() {\n  const getAllProducts = await productByCategory(\"kids\");\n\n  return <CommonListing data={getAllProducts && getAllProducts.data} />;\n}\n"
  },
  {
    "path": "src/app/product/listing/men/page.js",
    "content": "import CommonListing from \"@/components/CommonListing\";\nimport { productByCategory } from \"@/services/product\";\n\nexport default async function MenAllProducts() {\n  const getAllProducts = await productByCategory(\"men\");\n\n  return <CommonListing data={getAllProducts && getAllProducts.data} />;\n}\n"
  },
  {
    "path": "src/app/product/listing/women/page.js",
    "content": "import CommonListing from \"@/components/CommonListing\";\nimport { productByCategory } from \"@/services/product\";\n\nexport default async function WomenAllProducts() {\n  const getAllProducts = await productByCategory(\"women\");\n\n  return <CommonListing data={getAllProducts && getAllProducts.data} />;\n}\n"
  },
  {
    "path": "src/app/register/page.js",
    "content": "\"use client\";\n\nimport InputComponent from \"@/components/FormElements/InputComponent\";\nimport SelectComponent from \"@/components/FormElements/SelectComponent\";\nimport ComponentLevelLoader from \"@/components/Loader/componentlevel\";\nimport Notification from \"@/components/Notification\";\nimport { GlobalContext } from \"@/context\";\nimport { registerNewUser } from \"@/services/register\";\nimport { registrationFormControls } from \"@/utils\";\nimport { useRouter } from \"next/navigation\";\nimport { useContext, useEffect, useState } from \"react\";\nimport { toast } from \"react-toastify\";\n\nconst initialFormData = {\n  name: \"\",\n  email: \"\",\n  password: \"\",\n  role: \"customer\",\n};\n\nexport default function Register() {\n  const [formData, setFormData] = useState(initialFormData);\n  const [isRegistered, setIsRegistered] = useState(false);\n  const { pageLevelLoader, setPageLevelLoader , isAuthUser } = useContext(GlobalContext);\n\n  const router = useRouter()\n\n  console.log(formData);\n\n  function isFormValid() {\n    return formData &&\n      formData.name &&\n      formData.name.trim() !== \"\" &&\n      formData.email &&\n      formData.email.trim() !== \"\" &&\n      formData.password &&\n      formData.password.trim() !== \"\"\n      ? true\n      : false;\n  }\n\n  console.log(isFormValid());\n\n  async function handleRegisterOnSubmit() {\n    setPageLevelLoader(true);\n    const data = await registerNewUser(formData);\n\n    if (data.success) {\n      toast.success(data.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setIsRegistered(true);\n      setPageLevelLoader(false);\n      setFormData(initialFormData);\n    } else {\n      toast.error(data.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setPageLevelLoader(false);\n      setFormData(initialFormData);\n    }\n\n    console.log(data);\n  }\n\n  useEffect(() => {\n    if (isAuthUser) router.push(\"/\");\n  }, [isAuthUser]);\n\n  return (\n    <div className=\"bg-white relative\">\n      <div className=\"flex flex-col items-center justify-between pt-0 pr-10 pb-0 pl-10 mt-8 mr-auto xl:px-5 lg:flex-row\">\n        <div className=\"flex flex-col justify-center items-center w-full pr-10 pl-10 lg:flex-row\">\n          <div className=\"w-full mt-10 mr-0 mb-0 ml-0 relative max-w-2xl lg:mt-0 lg:w-5/12\">\n            <div className=\"flex flex-col items-center justify-start pt-10 pr-10 pb-10 pl-10 bg-white shadow-2xl rounded-xl relative z-10\">\n              <p className=\"w-full text-4xl font-medium text-center font-serif\">\n                {isRegistered\n                  ? \"Registration Successfull !\"\n                  : \"Sign up for an account\"}\n              </p>\n              {isRegistered ? (\n                <button\n                  className=\"inline-flex w-full items-center justify-center bg-black px-6 py-4 text-lg \n                text-white transition-all duration-200 ease-in-out focus:shadow font-medium uppercase tracking-wide\n                \"\n                onClick={()=>router.push('/login')}\n                >\n                  Login\n                </button>\n              ) : (\n                <div className=\"w-full mt-6 mr-0 mb-0 ml-0 relative space-y-8\">\n                  {registrationFormControls.map((controlItem) =>\n                    controlItem.componentType === \"input\" ? (\n                      <InputComponent\n                        type={controlItem.type}\n                        placeholder={controlItem.placeholder}\n                        label={controlItem.label}\n                        onChange={(event) => {\n                          setFormData({\n                            ...formData,\n                            [controlItem.id]: event.target.value,\n                          });\n                        }}\n                        value={formData[controlItem.id]}\n                      />\n                    ) : controlItem.componentType === \"select\" ? (\n                      <SelectComponent\n                        options={controlItem.options}\n                        label={controlItem.label}\n                        onChange={(event) => {\n                          setFormData({\n                            ...formData,\n                            [controlItem.id]: event.target.value,\n                          });\n                        }}\n                        value={formData[controlItem.id]}\n                      />\n                    ) : null\n                  )}\n                  <button\n                    className=\" disabled:opacity-50 inline-flex w-full items-center justify-center bg-black px-6 py-4 text-lg \n                   text-white transition-all duration-200 ease-in-out focus:shadow font-medium uppercase tracking-wide\n                   \"\n                    disabled={!isFormValid()}\n                    onClick={handleRegisterOnSubmit}\n                  >\n                    {pageLevelLoader ? (\n                      <ComponentLevelLoader\n                        text={\"Registering\"}\n                        color={\"#ffffff\"}\n                        loading={pageLevelLoader}\n                      />\n                    ) : (\n                      \"Register\"\n                    )}\n                  </button>\n                </div>\n              )}\n            </div>\n          </div>\n        </div>\n      </div>\n      <Notification />\n    </div>\n  );\n}\n"
  },
  {
    "path": "src/app/unauthorized-page/page.js",
    "content": "\"use client\";\n\nexport default function Unauthorized() {\n  return (\n    <section className=\"h-screen bg-gray-200\">\n      <div className=\"mx-auto px-4 sm:px-6 lg:px-8\">\n        <div className=\"mx-auto mt-8 max-w-screen-xl px-4 sm:px-6 lg:px-8 \">\n          <div className=\"bg-white shadow\">\n            <div className=\"px-4 py-6 sm:px-8 sm:py-10 flex flex-col gap-5\">\n              <h1 className=\"font-bold text-lg\">\n                You don't have access to view this page!\n              </h1>\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
  },
  {
    "path": "src/components/CartModal/index.js",
    "content": "\"use client\";\n\nimport { Fragment, useContext, useEffect } from \"react\";\nimport CommonModal from \"../CommonModal\";\nimport { GlobalContext } from \"@/context\";\nimport { deleteFromCart, getAllCartItems } from \"@/services/cart\";\nimport { toast } from \"react-toastify\";\nimport ComponentLevelLoader from \"../Loader/componentlevel\";\nimport { useRouter } from \"next/navigation\";\n\nexport default function CartModal() {\n  const {\n    showCartModal,\n    setShowCartModal,\n    cartItems,\n    setCartItems,\n    user,\n    setComponentLevelLoader,\n    componentLevelLoader,\n  } = useContext(GlobalContext);\n\n  const router = useRouter();\n\n  async function extractAllCartItems() {\n    const res = await getAllCartItems(user?._id);\n\n    if (res.success) {\n      const updatedData =\n        res.data && res.data.length\n          ? res.data.map((item) => ({\n              ...item,\n              productID: {\n                ...item.productID,\n                price:\n                  item.productID.onSale === \"yes\"\n                    ? parseInt(\n                        (\n                          item.productID.price -\n                          item.productID.price * (item.productID.priceDrop / 100)\n                        ).toFixed(2)\n                      )\n                    : item.productID.price,\n              },\n            }))\n          : [];\n      setCartItems(updatedData);\n      localStorage.setItem(\"cartItems\", JSON.stringify(updatedData));\n    }\n\n    console.log(res);\n  }\n\n  useEffect(() => {\n    if (user !== null) extractAllCartItems();\n  }, [user]);\n\n  async function handleDeleteCartItem(getCartItemID) {\n    setComponentLevelLoader({ loading: true, id: getCartItemID });\n    const res = await deleteFromCart(getCartItemID);\n\n    if (res.success) {\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n\n      extractAllCartItems();\n    } else {\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setComponentLevelLoader({ loading: false, id: getCartItemID });\n    }\n  }\n\n  return (\n    <CommonModal\n      showButtons={true}\n      show={showCartModal}\n      setShow={setShowCartModal}\n      mainContent={\n        cartItems && cartItems.length ? (\n          <ul role=\"list\" className=\"-my-6 divide-y divide-gray-300\">\n            {cartItems.map((cartItem) => (\n              <li key={cartItem.id} className=\"flex py-6\">\n                <div className=\"h-24 w-24 flex-shrink-0 overflow-hidden rounded-md border border-gray-200\">\n                  <img\n                    src={\n                      cartItem &&\n                      cartItem.productID &&\n                      cartItem.productID.imageUrl\n                    }\n                    alt=\"Cart Item\"\n                    className=\"h-full w-full object-cover object-center\"\n                  />\n                </div>\n                <div className=\"ml-4 flex flex-1 flex-col\">\n                  <div>\n                    <div className=\"flex justify-between text-base font-medium text-gray-900\">\n                      <h3>\n                        <a>\n                          {cartItem &&\n                            cartItem.productID &&\n                            cartItem.productID.name}\n                        </a>\n                      </h3>\n                    </div>\n                    <p className=\"mt-1 text-sm text-gray-600\">\n                      $\n                      {cartItem &&\n                        cartItem.productID &&\n                        cartItem.productID.price}\n                    </p>\n                  </div>\n                  <div className=\"flex flex-1 items-end justify-between text-sm\">\n                    <button\n                      type=\"button\"\n                      className=\"font-medium text-yellow-600 sm:order-2\"\n                      onClick={() => handleDeleteCartItem(cartItem._id)}\n                    >\n                      {componentLevelLoader &&\n                      componentLevelLoader.loading &&\n                      componentLevelLoader.id === cartItem._id ? (\n                        <ComponentLevelLoader\n                          text={\"Removing\"}\n                          color={\"#000000\"}\n                          loading={\n                            componentLevelLoader && componentLevelLoader.loading\n                          }\n                        />\n                      ) : (\n                        \"Remove\"\n                      )}\n                    </button>\n                  </div>\n                </div>\n              </li>\n            ))}\n          </ul>\n        ) : null\n      }\n      buttonComponent={\n        <Fragment>\n          <button\n            type=\"button\"\n            onClick={() => {\n              router.push(\"/cart\");\n              setShowCartModal(false);\n            }}\n            className=\"mt-1.5 w-full inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide\"\n          >\n            Go To Cart\n          </button>\n          <button\n            disabled={cartItems && cartItems.length === 0}\n            type=\"button\"\n            onClick={() => {\n              router.push(\"/checkout\");\n              setShowCartModal(false);\n            }}\n            className=\"mt-1.5 w-full inline-block bg-black text-white px-5 py-3 text-xs font-medium uppercase tracking-wide disabled:opacity-50\"\n          >\n            Checkout\n          </button>\n          <div className=\"mt-6 flex justify-center text-center text-sm text-gray-600\">\n            <button type=\"button\" className=\"font-medium text-grey\">\n              Continue Shopping\n              <span aria-hidden=\"true\"> &rarr;</span>\n            </button>\n          </div>\n        </Fragment>\n      }\n    />\n  );\n}\n"
  },
  {
    "path": "src/components/CommonCart/index.js",
    "content": "\"use client\";\n\nimport { useRouter } from \"next/navigation\";\nimport ComponentLevelLoader from \"../Loader/componentlevel\";\n\nexport default function CommonCart({\n  cartItems = [],\n  handleDeleteCartItem,\n  componentLevelLoader,\n}) {\n\n  const router = useRouter()\n\n  return (\n    <section className=\"h-screen bg-gray-100\">\n      <div className=\"mx-auto px-4 sm:px-6 lg:px-8\">\n        <div className=\"mx-auto mt-8 max-w-screen-xl px-4 sm:px-6 lg:px-8\">\n          <div className=\"bg-white shadow\">\n            <div className=\"px-4 py-6 sm:px-8 sm:py-10\">\n              <div className=\"flow-root\">\n                {cartItems && cartItems.length ? (\n                  <ul className=\"-my-8\">\n                    {cartItems.map((cartItem) => (\n                      <li\n                        className=\"flex-col flex space-y-3 py-6 text-left sm:flex-row sm:space-x-5 sm:space-y-0\"\n                        key={cartItem.id}\n                      >\n                        <div className=\"shrink-0\">\n                          <img\n                            src={\n                              cartItem &&\n                              cartItem.productID &&\n                              cartItem.productID.imageUrl\n                            }\n                            alt=\"Product image\"\n                            className=\"h-24 w-25 max-w-full rounded-lg object-cover\"\n                          />\n                        </div>\n                        <div className=\"flex flex-1 flex-col justify-between\">\n                          <div className=\"sm:col-gap-5 sm:grid sm:grid-cols-2\">\n                            <div className=\"pr-8 sm:pr-4\">\n                              <p className=\"text-base font-semibold text-gray-900\">\n                                {cartItem &&\n                                  cartItem.productID &&\n                                  cartItem.productID.name}\n                              </p>\n                            </div>\n                            <div className=\"mt-4 flex gap-3 items-end justify-between sm:mt-0 sm:items-start sm:justify-end\">\n                              <p className=\"shrink-0 w-20 text-base font-semibold text-gray-950 sm:order-1 sm:ml-8 sm:text-right\">\n                                $\n                                {cartItem &&\n                                  cartItem.productID &&\n                                  cartItem.productID.price}\n                              </p>\n                              <button\n                                type=\"button\"\n                                className=\"font-medium text-yellow-700 sm:order-2\"\n                                onClick={() =>\n                                  handleDeleteCartItem(cartItem._id)\n                                }\n                              >\n                                {componentLevelLoader &&\n                                componentLevelLoader.loading &&\n                                componentLevelLoader.id === cartItem._id ? (\n                                  <ComponentLevelLoader\n                                    text={\"Removing\"}\n                                    color={\"#0000000\"}\n                                    loading={\n                                      componentLevelLoader &&\n                                      componentLevelLoader.loading\n                                    }\n                                  />\n                                ) : (\n                                  \"Remove\"\n                                )}\n                              </button>\n                            </div>\n                          </div>\n                        </div>\n                      </li>\n                    ))}\n                  </ul>\n                ) : (\n                  <h1 className=\"font-bold text-lg\">Your cart is Empty !</h1>\n                )}\n              </div>\n              <div className=\"mt-6 border-t border-b py-2\">\n                <div className=\"flex items-center justify-between\">\n                  <p className=\"text-sm text-gray-400\">Subtotal</p>\n                  <p className=\"text-lg text-black font-semibold\">\n                    $\n                    {cartItems && cartItems.length\n                      ? cartItems.reduce(\n                          (total, item) => item.productID.price + total,\n                          0\n                        )\n                      : \"0\"}\n                  </p>\n                </div>\n                <div className=\"flex items-center justify-between\">\n                  <p className=\"text-sm text-gray-400\">Shipping</p>\n                  <p className=\"text-lg text-black font-semibold\">$0</p>\n                </div>\n                <div className=\"flex items-center justify-between\">\n                  <p className=\"text-sm text-gray-400\">Total</p>\n                  <p className=\"text-lg text-black font-semibold\">\n                    $\n                    {cartItems && cartItems.length\n                      ? cartItems.reduce(\n                          (total, item) => item.productID.price + total,\n                          0\n                        )\n                      : \"0\"}\n                  </p>\n                </div>\n                <div className=\"mt-5 text-center\">\n                  <button\n                  onClick={()=>router.push('/checkout')}\n                    disabled={cartItems && cartItems.length === 0}\n                    className=\"disabled:opacity-50 group inline-flex w-full items-center justify-center bg-black px-6 py-4 text-lg text-white font-medium uppercase tracking-wide\"\n                  >\n                    Checkout\n                  </button>\n                </div>\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
  },
  {
    "path": "src/components/CommonDetails/index.js",
    "content": "\"use client\";\n\nimport { GlobalContext } from \"@/context\";\nimport { useContext } from \"react\";\nimport { toast } from \"react-toastify\";\nimport ComponentLevelLoader from \"../Loader/componentlevel\";\nimport { addToCart } from \"@/services/cart\";\nimport Notification from \"../Notification\";\n\nexport default function CommonDetails({ item }) {\n  const {\n    setComponentLevelLoader,\n    componentLevelLoader,\n    user,\n    setShowCartModal,\n  } = useContext(GlobalContext);\n\n  async function handleAddToCart(getItem) {\n    setComponentLevelLoader({ loading: true, id: \"\" });\n\n    const res = await addToCart({ productID: getItem._id, userID: user._id });\n\n    if (res.success) {\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      setShowCartModal(true);\n    } else {\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      setShowCartModal(true);\n    }\n  }\n\n  return (\n    <section className=\"mx-auto max-w-screen-xl px-4 sm:px-6 lg:px-8\">\n      <div className=\"container mx-auto px-4\">\n        <div className=\"lg:col-gap-12 xl:col-gap-16 mt-8 grid grid-cols-1 gap-12 lg:mt-12 lg:grid-cols-5 lg:gap-16\">\n          <div className=\"lg:col-span-3 lg:row-end-1\">\n            <div className=\"lg:flex lg:items-start\">\n              <div className=\"lg:order-2 lg:ml-5\">\n                <div className=\"max-w-xl overflow-hidden rounded-lg\">\n                  <img\n                    src={item.imageUrl}\n                    className=\"h-full w-full max-w-full object-cover\"\n                    alt=\"Product Details\"\n                  />\n                </div>\n              </div>\n              <div className=\"mt-2 w-full lg:order-1 lg:w-32 lg:flex-shrink-0\">\n                <div className=\"flex flex-row items-start lg:flex-col\">\n                  <button\n                    type=\"button\"\n                    className=\"flex-0 aspect-square mb-3 h-20 overflow-hidden rounded-lg border-2 border-gray-100 text-center\"\n                  >\n                    <img\n                      src={item.imageUrl}\n                      className=\"h-full w-full object-cover\"\n                      alt=\"Product Details\"\n                    />\n                  </button>\n                  <button\n                    type=\"button\"\n                    className=\"flex-0 aspect-square mb-3 h-20 overflow-hidden rounded-lg border-2 border-gray-100 text-center\"\n                  >\n                    <img\n                      src={item.imageUrl}\n                      className=\"h-full w-full object-cover\"\n                      alt=\"Product Details\"\n                    />\n                  </button>\n                </div>\n              </div>\n            </div>\n          </div>\n          <div className=\"lg:col-span-2 lg:row-span-2 lg:row-end-2\">\n            <h1 className=\"text-2xl font-bold text-gray-900\">\n              {item && item.name}\n            </h1>\n            <div className=\"mt-10 flex flex-col items-center justify-between space-y-4 botder-t border-b py-4 sm:flex-row sm:space-y-0\">\n              <div className=\"flex items-end\">\n                <h1\n                  className={`text-3xl font-bold mr-2 ${\n                    item.onSale === \"yes\" ? \"line-through\" : \"\"\n                  }`}\n                >\n                  ${item && item.price}\n                </h1>\n                {item.onSale === \"yes\" ? (\n                  <h1 className=\"text-3xl font-bold text-red-700\">{`$${(\n                    item.price -\n                    item.price * (item.priceDrop / 100)\n                  ).toFixed(2)}`}</h1>\n                ) : null}\n              </div>\n              <button\n                type=\"button\"\n                onClick={() => handleAddToCart(item)}\n                className=\"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium tracking-wide uppercase text-white\"\n              >\n                {componentLevelLoader && componentLevelLoader.loading ? (\n                  <ComponentLevelLoader\n                    text={\"Adding to Cart\"}\n                    color={\"#ffffff\"}\n                    loading={\n                      componentLevelLoader && componentLevelLoader.loading\n                    }\n                  />\n                ) : (\n                  \"Add to Cart\"\n                )}\n              </button>\n            </div>\n            <ul className=\"mt-8 space-y-2\">\n              <li className=\"flex items-center text-left text-sm font-medium text-gray-600\">\n                {item && item.deliveryInfo}\n              </li>\n              <li className=\"flex items-center text-left text-sm font-medium text-gray-600\">\n                {\"Cancel anytime\"}\n              </li>\n            </ul>\n            <div className=\"lg:col-span-3\">\n              <div className=\"border-b border-gray-400\">\n                <nav className=\"flex gap-4\">\n                  <a\n                    href=\"#\"\n                    className=\"border-b-2 border-gray-900 py-4 text-sm font-medium text-gray-900\"\n                  >\n                    Description\n                  </a>\n                </nav>\n              </div>\n              <div className=\"mt-8 flow-root sm:mt-12\">\n                {item && item.description}\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n      <Notification/>\n    </section>\n  );\n}\n"
  },
  {
    "path": "src/components/CommonListing/ProductButtons/index.js",
    "content": "\"use client\";\n\nimport ComponentLevelLoader from \"@/components/Loader/componentlevel\";\nimport { GlobalContext } from \"@/context\";\nimport { addToCart } from \"@/services/cart\";\nimport { deleteAProduct } from \"@/services/product\";\nimport { usePathname, useRouter } from \"next/navigation\";\nimport { useContext } from \"react\";\nimport { toast } from \"react-toastify\";\n\nexport default function ProductButton({ item }) {\n  const pathName = usePathname();\n  const {\n    setCurrentUpdatedProduct,\n    setComponentLevelLoader,\n    componentLevelLoader,\n    user,\n    showCartModal, setShowCartModal\n  } = useContext(GlobalContext);\n  const router = useRouter();\n\n  const isAdminView = pathName.includes(\"admin-view\");\n\n  async function handleDeleteProduct(item) {\n    setComponentLevelLoader({ loading: true, id: item._id });\n\n    const res = await deleteAProduct(item._id);\n\n    if (res.success) {\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      router.refresh();\n    } else {\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setComponentLevelLoader({ loading: false, id: \"\" });\n    }\n  }\n\n  async function handleAddToCart(getItem) {\n    setComponentLevelLoader({ loading: true, id: getItem._id });\n\n    const res = await addToCart({ productID: getItem._id, userID: user._id });\n\n    if (res.success) {\n      toast.success(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      setShowCartModal(true);\n    } else {\n      toast.error(res.message, {\n        position: toast.POSITION.TOP_RIGHT,\n      });\n      setComponentLevelLoader({ loading: false, id: \"\" });\n      setShowCartModal(true)\n    }\n\n    console.log(res);\n  }\n\n  return isAdminView ? (\n    <>\n      <button\n        onClick={() => {\n          setCurrentUpdatedProduct(item);\n          router.push(\"/admin-view/add-product\");\n        }}\n        className=\"mt-1.5 flex w-full justify-center bg-black px-5 py-3 text-xs font-medium uppercase tracking-wide text-white\"\n      >\n        Update\n      </button>\n      <button\n        onClick={() => handleDeleteProduct(item)}\n        className=\"mt-1.5 flex w-full justify-center bg-black px-5 py-3 text-xs font-medium uppercase tracking-wide text-white\"\n      >\n        {componentLevelLoader &&\n        componentLevelLoader.loading &&\n        item._id === componentLevelLoader.id ? (\n          <ComponentLevelLoader\n            text={\"Deleting Product\"}\n            color={\"#ffffff\"}\n            loading={componentLevelLoader && componentLevelLoader.loading}\n          />\n        ) : (\n          \"DELETE\"\n        )}\n      </button>\n    </>\n  ) : (\n    <>\n      <button\n        onClick={() => handleAddToCart(item)}\n        className=\"mt-1.5 flex w-full justify-center bg-black px-5 py-3 text-xs font-medium uppercase tracking-wide text-white\"\n      >\n        {componentLevelLoader &&\n        componentLevelLoader.loading &&\n        componentLevelLoader.id === item._id ? (\n          <ComponentLevelLoader\n            text={\"Adding to cart\"}\n            color={\"#ffffff\"}\n            loading={componentLevelLoader && componentLevelLoader.loading}\n          />\n        ) : (\n          \"Add To Cart\"\n        )}\n      </button>\n    </>\n  );\n}\n"
  },
  {
    "path": "src/components/CommonListing/ProductTile/index.js",
    "content": "\"use client\";\n\nimport { useRouter } from \"next/navigation\";\n\nexport default function ProductTile({ item }) {\n  const router = useRouter();\n  \n  return (\n    <div  onClick={()=> router.push(`/product/${item._id}`)}>\n      <div className=\"overflow-hideen aspect-w-1 aspect-h-1 h-52\">\n        <img\n          src={item.imageUrl}\n          alt=\"Product image\"\n          className=\"h-full w-full object-cover transition-all duration-300 group-hover:scale-125\"\n        />\n      </div>\n      {item.onSale === \"yes\" ? (\n        <div className=\"absolute top-0 m-2 rounded-full bg-black\">\n          <p className=\"rounded-full  p-1 text-[8px] font-bold uppercase tracking-wide text-white sm:py-1 sm:px-3\">\n            Sale\n          </p>\n        </div>\n      ) : null}\n      <div className=\"my-4 mx-auto flex w-10/12 flex-col items-start justify-between\">\n        <div className=\"mb-2 flex\">\n          <p\n            className={`mr-3 text-sm font-semibold ${\n              item.onSale === \"yes\" ? \"line-through\" : \"\"\n            }`}\n          >{`$ ${item.price}`}</p>\n          {item.onSale === \"yes\" ? (\n            <p className=\"mr-3 text-sm font-semibold text-red-700\">{`$ ${(\n              item.price -\n              item.price * (item.priceDrop / 100)\n            ).toFixed(2)}`}</p>\n          ) : null}\n          {item.onSale === \"yes\" ? (\n            <p className=\"mr-3 text-sm font-semibold\">{`-(${item.priceDrop}%)off`}</p>\n          ) : null}\n        </div>\n        <h3 className=\"md-2 text-gray-400 text-sm\">{item.name}</h3>\n      </div>\n    </div>\n  );\n}\n"
  },
  {
    "path": "src/components/CommonListing/index.js",
    "content": "\"use client\";\n\nimport { useRouter } from \"next/navigation\";\nimport ProductButton from \"./ProductButtons\";\nimport ProductTile from \"./ProductTile\";\nimport { useEffect } from \"react\";\nimport Notification from \"../Notification\";\n\nexport default function CommonListing({ data }) {\n  const router = useRouter();\n\n  useEffect(() => {\n    router.refresh();\n  }, []);\n\n  return (\n    <section className=\"bg-white py-12 sm:py-16\">\n      <div className=\"mx-auto max-w-screen-xl px-4 sm:px-6 lg:px-8\">\n        <div className=\"mt-10 grid grid-cols-2 gap-6 sm:grid-cols-4 sm:gap-4 lg:mt-16\">\n          {data && data.length\n            ? data.map((item) => (\n                <article\n                  className=\"relative flex flex-col overflow-hidden border cursor-pointer\"\n                  key={item._id}\n                >\n                  <ProductTile item={item} />\n                  <ProductButton item={item} />\n                </article>\n              ))\n            : null}\n        </div>\n      </div>\n      <Notification/>\n    </section>\n  );\n}\n"
  },
  {
    "path": "src/components/CommonModal/index.js",
    "content": "\"use client\";\n\nimport { Dialog, Transition } from \"@headlessui/react\";\nimport { Fragment } from \"react\";\n\nexport default function CommonModal({\n  modalTitle,\n  mainContent,\n  showButtons,\n  buttonComponent,\n  show,\n  setShow,\n  showModalTitle\n}) {\n  return (\n    <Transition.Root show={show} as={Fragment}>\n      <Dialog as=\"div\" className={\"relative z-10\"} onClose={setShow}>\n        <Transition.Child\n          as={Fragment}\n          enter=\"ease-in-out duration-900\"\n          enterFrom=\"opacity-0\"\n          enterTo=\"opacity-100\"\n          leave=\"ease-in-out duration-500\"\n          leaveFrom=\"opacity-100\"\n          leaveTo=\"opacity-0\"\n        >\n          <div className=\"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity\" />\n        </Transition.Child>\n        <div className=\"fixed inset-0 overflow-hidden\">\n          <div className=\"absolute inset-0 overflow-hidden\">\n            <div className=\"fixed inset-y-0 right-0 flex max-w-full pl-10\">\n              <Transition.Child\n                as={Fragment}\n                enter=\"ease-in-out duration-900\"\n                enterFrom=\"opacity-0\"\n                enterTo=\"opacity-100\"\n                leave=\"ease-in-out duration-500\"\n                leaveFrom=\"opacity-100\"\n                leaveTo=\"opacity-0\"\n              >\n                <Dialog.Panel className={\"w-screen max-w-md\"}>\n                  <div className=\"flex h-full flex-col overflow-y-scroll bg-white shadow-xl\">\n                    <div className=\"flex-1 overflow-y-auto px-4 py-6 sm:px-6\">\n                      {\n                        showModalTitle ?  <div className=\"flex items-start justify-between\">\n                        <Dialog.Title>{modalTitle}</Dialog.Title>\n                      </div> : null\n                      }\n                      <div className=\"mt-20\">{mainContent}</div>\n                    </div>\n                    {showButtons ? (\n                      <div className=\"border-none px-4 py-6 sm:px-6\">\n                        {buttonComponent}\n                      </div>\n                    ) : null}\n                  </div>\n                </Dialog.Panel>\n              </Transition.Child>\n            </div>\n          </div>\n        </div>\n      </Dialog>\n    </Transition.Root>\n  );\n}\n"
  },
  {
    "path": "src/components/FormElements/InputComponent/index.js",
    "content": "export default function InputComponent({\n  label,\n  placeholder,\n  onChange,\n  value,\n  type,\n}) {\n  return (\n    <div className=\"relative\">\n      <p className=\" pt-0 pr-2 pb-0 pl-2 absolute -mt-3 mr-0 mb-0 ml-2 font-medium text-gray-600 bg-white\">\n        {label}\n      </p>\n      <input\n        placeholder={placeholder}\n        type={type || \"text\"}\n        value={value}\n        onChange={onChange}\n        className=\"border placeholder-gray-400 focus:outline-none focus:border-black w-full pt-4 pr-4 pb-4 pl-4 mr-0 mt-0 ml-0 text-base block bg-white border-gray-300 rounded-md\"\n      />\n    </div>\n  );\n}\n"
  },
  {
    "path": "src/components/FormElements/SelectComponent/index.js",
    "content": "export default function SelectComponent({\n  label,\n  value,\n  onChange,\n  options = [],\n}) {\n  return (\n    <div className=\"relative\">\n      <p className=\" pt-0 pr-2 absolute pb-0 pl-2 -mt-3 mr-0 mb-0 ml-2 font-medium text-gray-600 bg-white\">\n        {label}\n      </p>\n      <select\n        value={value}\n        onChange={onChange}\n        className=\"border placeholder-gray-400 focus:outline-none focus:border-black w-full pt-4 pr-4 pb-4 pl-4 mr-0 mt-0 ml-0 text-base block bg-white border-gray-300 rounded-md\"\n      >\n        {options && options.length ? (\n          options.map((optionItem) => (\n            <option\n              id={optionItem.id}\n              value={optionItem.id}\n              key={optionItem.id}\n            >\n              {optionItem.label}\n            </option>\n          ))\n        ) : (\n          <option id=\"\" value={\"\"}>\n            Select\n          </option>\n        )}\n      </select>\n    </div>\n  );\n}\n"
  },
  {
    "path": "src/components/FormElements/TileComponent/index.js",
    "content": "export default function TileComponent({ data, selected = [], onClick }) {\n  return data && data.length ? (\n    <div className=\"mt-3 flex flex-wrap items-center gap-1\">\n      {data.map((dataItem) => (\n        <label\n          onClick={() => onClick(dataItem)}\n          className={`cursor-pointer ${\n            selected &&\n            selected.length &&\n            selected.map((item) => item.id).indexOf(dataItem.id) !== -1\n              ? \"bg-black\"\n              : \"\"\n          }`}\n          key={dataItem.id}\n        >\n          <span\n            className={`rounded-lg border border-black px-6 py-2 font-bold ${\n              selected &&\n              selected.length &&\n              selected.map((item) => item.id).indexOf(dataItem.id) !== -1\n                ? \"text-white\"\n                : \"\"\n            }`}\n          >\n            {dataItem.label}\n          </span>\n        </label>\n      ))}\n    </div>\n  ) : null;\n}\n"
  },
  {
    "path": "src/components/Loader/componentlevel/index.js",
    "content": "\"use client\";\n\nimport { PulseLoader } from \"react-spinners\";\n\nexport default function ComponentLevelLoader({ text, color, loading, size }) {\n  return (\n    <span className=\"flex gap-1 items-center\">\n      {text}\n      <PulseLoader\n        color={color}\n        loading={loading}\n        size={size || 10}\n        data-testid=\"loader\"\n      />\n    </span>\n  );\n}\n"
  },
  {
    "path": "src/components/Navbar/index.js",
    "content": "\"use client\";\n\nimport { GlobalContext } from \"@/context\";\nimport { adminNavOptions, navOptions } from \"@/utils\";\nimport { Fragment, useContext, useEffect } from \"react\";\nimport CommonModal from \"../CommonModal\";\nimport Cookies from \"js-cookie\";\nimport { usePathname, useRouter } from \"next/navigation\";\nimport CartModal from \"../CartModal\";\n\nfunction NavItems({ isModalView = false, isAdminView, router }) {\n  return (\n    <div\n      className={`items-center justify-between w-full md:flex md:w-auto ${\n        isModalView ? \"\" : \"hidden\"\n      }`}\n      id=\"nav-items\"\n    >\n      <ul\n        className={`flex flex-col p-4 md:p-0 mt-4 font-medium  rounded-lg md:flex-row md:space-x-8 md:mt-0 md:border-0 bg-white ${\n          isModalView ? \"border-none\" : \"border border-gray-100\"\n        }`}\n      >\n        {isAdminView\n          ? adminNavOptions.map((item) => (\n              <li\n                className=\"cursor-pointer block py-2 pl-3 pr-4 text-gray-900 rounded md:p-0\"\n                key={item.id}\n                onClick={() => router.push(item.path)}\n              >\n                {item.label}\n              </li>\n            ))\n          : navOptions.map((item) => (\n              <li\n                className=\"cursor-pointer block py-2 pl-3 pr-4 text-gray-900 rounded md:p-0\"\n                key={item.id}\n                onClick={() => router.push(item.path)}\n              >\n                {item.label}\n              </li>\n            ))}\n      </ul>\n    </div>\n  );\n}\n\nexport default function Navbar() {\n  const { showNavModal, setShowNavModal } = useContext(GlobalContext);\n  const {\n    user,\n    isAuthUser,\n    setIsAuthUser,\n    setUser,\n    currentUpdatedProduct,\n    setCurrentUpdatedProduct,\n    showCartModal,\n    setShowCartModal\n  } = useContext(GlobalContext);\n\n  const pathName = usePathname();\n  const router = useRouter();\n\n  console.log(currentUpdatedProduct, \"navbar\");\n\n  useEffect(() => {\n    if (\n      pathName !== \"/admin-view/add-product\" &&\n      currentUpdatedProduct !== null\n    )\n      setCurrentUpdatedProduct(null);\n  }, [pathName]);\n\n  function handleLogout() {\n    setIsAuthUser(false);\n    setUser(null);\n    Cookies.remove(\"token\");\n    localStorage.clear();\n    router.push(\"/\");\n  }\n\n  const isAdminView = pathName.includes(\"admin-view\");\n\n  return (\n    <>\n      <nav className=\"bg-white fixed w-full z-20 top-0 left-0 border-b border-gray-200\">\n        <div className=\"max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4\">\n          <div\n            onClick={() => router.push(\"/\")}\n            className=\"flex items-center cursor-pointer\"\n          >\n            <span className=\"slef-center text-2xl font-semibold whitespace-nowrap\">\n              Ecommercery\n            </span>\n          </div>\n          <div className=\"flex md:order-2 gap-2\">\n            {!isAdminView && isAuthUser ? (\n              <Fragment>\n                <button\n                  className={\n                    \"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium upprcase tracking-wide text-white\"\n                  }\n                  onClick={()=>router.push('/account')}\n                >\n                  Account\n                </button>\n                <button\n                  className={\n                    \"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium upprcase tracking-wide text-white\"\n                  }\n                  onClick={()=> setShowCartModal(true)}\n                >\n                  Cart\n                </button>\n              </Fragment>\n            ) : null}\n            {user?.role === \"admin\" ? (\n              isAdminView ? (\n                <button\n                  className={\n                    \"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium upprcase tracking-wide text-white\"\n                  }\n                  onClick={() => router.push(\"/\")}\n                >\n                  Client View\n                </button>\n              ) : (\n                <button\n                  onClick={() => router.push(\"/admin-view\")}\n                  className={\n                    \"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium upprcase tracking-wide text-white\"\n                  }\n                >\n                  Admin View\n                </button>\n              )\n            ) : null}\n            {isAuthUser ? (\n              <button\n                onClick={handleLogout}\n                className={\n                  \"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium upprcase tracking-wide text-white\"\n                }\n              >\n                Logout\n              </button>\n            ) : (\n              <button\n                onClick={() => router.push(\"/login\")}\n                className={\n                  \"mt-1.5 inline-block bg-black px-5 py-3 text-xs font-medium upprcase tracking-wide text-white\"\n                }\n              >\n                Login\n              </button>\n            )}\n            <button\n              data-collapse-toggle=\"navbar-sticky\"\n              type=\"button\"\n              className=\"inline-flex items-center p-2 text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600\"\n              aria-controls=\"navbar-sticky\"\n              aria-expanded=\"false\"\n              onClick={() => setShowNavModal(true)}\n            >\n              <span className=\"sr-only\">Open main menu</span>\n              <svg\n                className=\"w-6 h-6\"\n                aria-hidden=\"true\"\n                fill=\"currentColor\"\n                viewBox=\"0 0 20 20\"\n                xmlns=\"http://www.w3.org/2000/svg\"\n              >\n                <path\n                  fill-rule=\"evenodd\"\n                  d=\"M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z\"\n                  clip-rule=\"evenodd\"\n                ></path>\n              </svg>\n            </button>\n          </div>\n          <NavItems router={router} isAdminView={isAdminView} />\n        </div>\n      </nav>\n      <CommonModal\n        showModalTitle={false}\n        mainContent={\n          <NavItems\n            router={router}\n            isModalView={true}\n            isAdminView={isAdminView}\n          />\n        }\n        show={showNavModal}\n        setShow={setShowNavModal}\n      />\n      {showCartModal && <CartModal />}\n    </>\n  );\n}\n"
  },
  {
    "path": "src/components/Notification/index.js",
    "content": "import { ToastContainer } from \"react-toastify\";\nimport \"react-toastify/dist/ReactToastify.css\";\n\nexport default function Notification() {\n  return (\n    <ToastContainer\n      position=\"top-right\"\n      autoClose={4000}\n      hideProgressBar={false}\n      newestOnTop={false}\n      closeOnClick\n      pauseOnFocusLoss\n      draggable\n      pauseOnHover\n      theme=\"light\"\n      rtl={false}\n    />\n  );\n}\n"
  },
  {
    "path": "src/context/index.js",
    "content": "\"use client\";\n\nimport Cookies from \"js-cookie\";\nimport { usePathname, useRouter } from \"next/navigation\";\nimport { createContext, useEffect, useState } from \"react\";\n\nexport const GlobalContext = createContext(null);\n\nexport const initialCheckoutFormData = {\n  shippingAddress: {},\n  paymentMethod: \"\",\n  totalPrice: 0,\n  isPaid: false,\n  paidAt: new Date(),\n  isProcessing: true,\n};\n\nconst protectedRoutes = [\"cart\", \"checkout\", \"account\", \"orders\", \"admin-view\"];\n\nconst protectedAdminRoutes = [\n  \"/admin-view\",\n  \"/admin-view/add-product\",\n  \"/admin-view/all-products\",\n];\n\nexport default function GlobalState({ children }) {\n  const [showNavModal, setShowNavModal] = useState(false);\n  const [pageLevelLoader, setPageLevelLoader] = useState(true);\n  const [componentLevelLoader, setComponentLevelLoader] = useState({\n    loading: false,\n    id: \"\",\n  });\n  const [isAuthUser, setIsAuthUser] = useState(null);\n  const [user, setUser] = useState(null);\n  const [currentUpdatedProduct, setCurrentUpdatedProduct] = useState(null);\n  const [showCartModal, setShowCartModal] = useState(false);\n  const [cartItems, setCartItems] = useState([]);\n  const [addresses, setAddresses] = useState([]);\n  const [addressFormData, setAddressFormData] = useState({\n    fullName: \"\",\n    city: \"\",\n    country: \"\",\n    postalCode: \"\",\n    address: \"\",\n  });\n\n  const [checkoutFormData, setCheckoutFormData] = useState(\n    initialCheckoutFormData\n  );\n\n  const [allOrdersForUser, setAllOrdersForUser] = useState([]);\n  const [orderDetails, setOrderDetails] = useState(null);\n  const [allOrdersForAllUsers, setAllOrdersForAllUsers] = useState([]);\n\n  const router = useRouter();\n  const pathName = usePathname();\n\n  useEffect(() => {\n    if (Cookies.get(\"token\") !== undefined) {\n      setIsAuthUser(true);\n      const userData = JSON.parse(localStorage.getItem(\"user\")) || {};\n      const getCartItems = JSON.parse(localStorage.getItem(\"cartItems\")) || [];\n      setUser(userData);\n      setCartItems(getCartItems);\n    } else {\n      setIsAuthUser(false);\n      setUser({}); //unauthenticated user\n    }\n  }, [Cookies]);\n\n  useEffect(() => {\n    if (\n      pathName !== \"/register\" &&\n      !pathName.includes(\"product\") &&\n      pathName !== \"/\" &&\n      user &&\n      Object.keys(user).length === 0 &&\n      protectedRoutes.includes(pathName) > -1\n    )\n      router.push(\"/login\");\n  }, [user, pathName]);\n\n  useEffect(() => {\n    if (\n      user !== null &&\n      user &&\n      Object.keys(user).length > 0 &&\n      user?.role !== \"admin\" &&\n      protectedAdminRoutes.indexOf(pathName) > -1\n    )\n      router.push(\"/unauthorized-page\");\n  }, [user, pathName]);\n\n  return (\n    <GlobalContext.Provider\n      value={{\n        showNavModal,\n        setShowNavModal,\n        pageLevelLoader,\n        setPageLevelLoader,\n        isAuthUser,\n        setIsAuthUser,\n        user,\n        setUser,\n        componentLevelLoader,\n        setComponentLevelLoader,\n        currentUpdatedProduct,\n        setCurrentUpdatedProduct,\n        showCartModal,\n        setShowCartModal,\n        cartItems,\n        setCartItems,\n        addresses,\n        setAddresses,\n        addressFormData,\n        setAddressFormData,\n        checkoutFormData,\n        setCheckoutFormData,\n        allOrdersForUser,\n        setAllOrdersForUser,\n        orderDetails,\n        setOrderDetails,\n        allOrdersForAllUsers,\n        setAllOrdersForAllUsers,\n      }}\n    >\n      {children}\n    </GlobalContext.Provider>\n  );\n}\n"
  },
  {
    "path": "src/database/index.js",
    "content": "import mongoose from \"mongoose\";\n\nconst configOptions = {\n  useNewUrlParser: true,\n  useUnifiedTopology: true,\n};\n\nconst connectToDB = async () => {\n  const connectionUrl =\n    \"your-mongodb-url\";\n\n  mongoose\n    .connect(connectionUrl, configOptions)\n    .then(() => console.log(\"Ecommerce database connected successfully!\"))\n    .catch((err) =>\n      console.log(`Getting Error from DB connection ${err.message}`)\n    );\n};\n\nexport default connectToDB;\n"
  },
  {
    "path": "src/middleware/AuthUser.js",
    "content": "import jwt from \"jsonwebtoken\";\n\nexport const dynamic = \"force-dynamic\";\n\nconst AuthUser = async (req) => {\n  const token = req.headers.get(\"Authorization\")?.split(\" \")[1];\n\n  if (!token) return false;\n\n  try {\n    const extractAuthUserInfo = jwt.verify(token, \"default_secret_key\");\n    if (extractAuthUserInfo) return extractAuthUserInfo;\n  } catch (e) {\n    console.log(e);\n    return false;\n  }\n};\n\nexport default AuthUser;\n"
  },
  {
    "path": "src/models/address.js",
    "content": "import mongoose from \"mongoose\";\n\nconst NewAddressSchema = new mongoose.Schema(\n  {\n    userID: {\n      type: mongoose.Schema.Types.ObjectId,\n      ref: \"User\",\n    },\n    fullName: String,\n    address: String,\n    city: String,\n    country: String,\n    postalCode: String,\n  },\n  { timestamps: true }\n);\n\nconst Address =\n  mongoose.models.Address || mongoose.model(\"Address\", NewAddressSchema);\n\nexport default Address;\n"
  },
  {
    "path": "src/models/cart.js",
    "content": "import mongoose from \"mongoose\";\n\nconst CartSchema = new mongoose.Schema(\n  {\n    userID: {\n        type: mongoose.Schema.Types.ObjectId,\n        ref: 'User',\n    },\n    productID: {\n        type: mongoose.Schema.Types.ObjectId,\n        ref: 'Products',\n    },\n    quantity: {\n        type: Number,\n        required: true,\n        default: 1,\n    },\n  },\n  { timestamps: true }\n);\n\nconst Cart = mongoose.models.Cart || mongoose.model(\"Cart\", CartSchema);\nexport default Cart;\n"
  },
  {
    "path": "src/models/order.js",
    "content": "import mongoose from \"mongoose\";\nimport Product from \"./product\";\nimport User from \"./user\";\n\nconst OrderSchema = new mongoose.Schema(\n  {\n    user: {\n      type: mongoose.Schema.Types.ObjectId,\n      ref: \"User\",\n      required: true,\n    },\n    orderItems: [\n      {\n        qty: { type: Number, required: true },\n        product: {\n          type: mongoose.Schema.Types.ObjectId,\n          ref: \"Products\",\n        },\n      },\n    ],\n    shippingAddress: {\n      fullName: { type: String, required: true },\n      address: { type: String, required: true },\n      city: { type: String, required: true },\n      country: { type: String, required: true },\n      postalCode: { type: String, required: true },\n    },\n    paymentMethod: { type: String, required: true, default: \"Stripe\" },\n    totalPrice: { type: Number, required: true },\n    isPaid: { type: Boolean, required: true },\n    paidAt: { type: Date, required: true },\n    isProcessing: { type: Boolean, required: true },\n  },\n  { timestamps: true }\n);\n\nconst Order = mongoose.models.Order || mongoose.model(\"Order\", OrderSchema);\n\nexport default Order;\n"
  },
  {
    "path": "src/models/product.js",
    "content": "import mongoose from \"mongoose\";\n\nconst ProductSchema = new mongoose.Schema(\n  {\n    name: String,\n    description: String,\n    price: Number,\n    category: String,\n    sizes: Array,\n    deliveryInfo: String,\n    onSale: String,\n    priceDrop: Number,\n    imageUrl: String,\n  },\n  { timestamps: true }\n);\n\nconst Product =\n  mongoose.models.Products || mongoose.model(\"Products\", ProductSchema);\n\nexport default Product;\n"
  },
  {
    "path": "src/models/user.js",
    "content": "import mongoose from \"mongoose\";\n\nconst UserSchema = new mongoose.Schema({\n  name: String,\n  email: String,\n  password: String,\n  role: String,\n});\n\nconst User = mongoose.models.User || mongoose.model(\"User\", UserSchema);\n\nexport default User;\n"
  },
  {
    "path": "src/services/address/index.js",
    "content": "import Cookies from \"js-cookie\";\n\nexport const addNewAddress = async (formData) => {\n  try {\n    const res = await fetch(\"/api/address/add-new-address\", {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application/json\",\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n      body: JSON.stringify(formData),\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const fetchAllAddresses = async (id) => {\n  try {\n    const res = await fetch(`/api/address/get-all-address?id=${id}`, {\n      method: \"GET\",\n      headers: {\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const updateAddress = async (formData) => {\n  try {\n    const res = await fetch(\"/api/address/update-address\", {\n      method: \"PUT\",\n      headers: {\n        \"Content-Type\": \"application/json\",\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n      body: JSON.stringify(formData),\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const deleteAddress = async (id) => {\n  try {\n    const res = await fetch(`/api/address/delete-address?id=${id}`, {\n      method: \"DELETE\",\n      headers: {\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n"
  },
  {
    "path": "src/services/cart/index.js",
    "content": "import Cookies from \"js-cookie\";\n\nexport const addToCart = async (formData) => {\n  try {\n    const res = await fetch(\"/api/cart/add-to-cart\", {\n      method: \"POST\",\n      headers: {\n        \"content-type\": \"application/json\",\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n      body: JSON.stringify(formData),\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const getAllCartItems = async (id) => {\n  try {\n    const res = await fetch(`http://localhost:3000/api/cart/all-cart-items?id=${id}`, {\n      method: \"GET\",\n      headers: {\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const deleteFromCart = async (id) => {\n  try {\n    const res = await fetch(`/api/cart/delete-from-cart?id=${id}`, {\n      method: \"DELETE\",\n      headers: {\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n"
  },
  {
    "path": "src/services/login/index.js",
    "content": "export const login = async (formData) => {\n  try {\n    const response = await fetch(\"/api/login\", {\n      method: \"POST\",\n      headers: {\n        \"content-type\": \"application/json\",\n      },\n      body: JSON.stringify(formData),\n    });\n\n    const data = await response.json();\n\n    return data;\n  } catch (error) {\n    console.log(error);\n  }\n};\n"
  },
  {
    "path": "src/services/order/index.js",
    "content": "import Cookies from \"js-cookie\";\n\nexport const createNewOrder = async (formData) => {\n  try {\n    const res = await fetch(\"/api/order/create-order\", {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application/json\",\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n      body: JSON.stringify(formData),\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const getAllOrdersForUser = async (id) => {\n  try {\n    const res = await fetch(`/api/order/get-all-orders?id=${id}`, {\n      method: \"GET\",\n      headers: {\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const getOrderDetails = async (id) => {\n  try {\n    const res = await fetch(`/api/order/order-details?id=${id}`, {\n      method: \"GET\",\n      headers: {\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const getAllOrdersForAllUsers = async () => {\n  try {\n    const res = await fetch(`/api/admin/orders/get-all-orders`, {\n      method: \"GET\",\n      headers: {\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const updateStatusOfOrder = async (formData) => {\n  try {\n    const res = await fetch(`/api/admin/orders/update-order`, {\n      method: \"PUT\",\n      headers: {\n        \"Content-Type\": \"application/json\",\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n      body: JSON.stringify(formData),\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n"
  },
  {
    "path": "src/services/product/index.js",
    "content": "//add a new product service\n\nimport Cookies from \"js-cookie\";\n\nexport const addNewProduct = async (formData) => {\n  try {\n    const response = await fetch(\"/api/admin/add-product\", {\n      method: \"POST\",\n      headers: {\n        \"content-type\": \"application/json\",\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n      body: JSON.stringify(formData),\n    });\n\n    const data = await response.json();\n\n    return data;\n  } catch (error) {\n    console.log(error);\n  }\n};\n\nexport const getAllAdminProducts = async () => {\n  try {\n    const res = await fetch(\"http://localhost:3000/api/admin/all-products\", {\n      method: \"GET\",\n      cache: \"no-store\",\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (error) {\n    console.log(error);\n  }\n};\n\nexport const updateAProduct = async (formData) => {\n  try {\n    const res = await fetch(\"/api/admin/update-product\", {\n      method: \"PUT\",\n      headers: {\n        \"content-type\": \"application/json\",\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n      cache: \"no-store\",\n      body: JSON.stringify(formData),\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const deleteAProduct = async (id) => {\n  try {\n    const res = await fetch(`/api/admin/delete-product?id=${id}`, {\n      method: \"DELETE\",\n      headers: {\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const productByCategory = async (id) => {\n  try {\n    const res = await fetch(\n      `http://localhost:3000/api/admin/product-by-category?id=${id}`,\n      {\n        method: \"GET\",\n        cache: \"no-store\",\n      }\n    );\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n\nexport const productById = async (id) => {\n  try {\n    const res = await fetch(\n      `http://localhost:3000/api/admin/product-by-id?id=${id}`,\n      {\n        method: \"GET\",\n        cache: \"no-store\",\n      }\n    );\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n"
  },
  {
    "path": "src/services/register/index.js",
    "content": "export const registerNewUser = async (formData) => {\n  try {\n    const response = await fetch(\"/api/register\", {\n      method: \"POST\",\n      headers: {\n        \"content-type\": \"application/json\",\n      },\n      body: JSON.stringify(formData),\n    });\n\n    const finalData = await response.json();\n\n    return finalData;\n  } catch (e) {\n    console.log(\"error\", e);\n  }\n};\n"
  },
  {
    "path": "src/services/stripe/index.js",
    "content": "import Cookies from \"js-cookie\";\n\nexport const callStripeSession = async (formData) => {\n  try {\n    const res = await fetch(\"/api/stripe\", {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application/json\",\n        Authorization: `Bearer ${Cookies.get(\"token\")}`,\n      },\n      body: JSON.stringify(formData),\n    });\n\n    const data = await res.json();\n\n    return data;\n  } catch (e) {\n    console.log(e);\n  }\n};\n"
  },
  {
    "path": "src/utils/index.js",
    "content": "export const navOptions = [\n  {\n    id: \"home\",\n    label: \"Home\",\n    path: \"/\",\n  },\n  {\n    id: \"listing\",\n    label: \"All Products\",\n    path: \"/product/listing/all-products\",\n  },\n  {\n    id: \"listingMen\",\n    label: \"Men\",\n    path: \"/product/listing/men\",\n  },\n  {\n    id: \"listingWomen\",\n    label: \"Women\",\n    path: \"/product/listing/women\",\n  },\n  {\n    id: \"listingKids\",\n    label: \"kids\",\n    path: \"/product/listing/kids\",\n  },\n];\n\nexport const adminNavOptions = [\n  {\n    id: \"adminListing\",\n    label: \"Manage All Products\",\n    path: \"/admin-view/all-products\",\n  },\n  {\n    id: \"adminNewProduct\",\n    label: \"Add New Product\",\n    path: \"/admin-view/add-product\",\n  },\n];\n\nexport const registrationFormControls = [\n  {\n    id: \"name\",\n    type: \"text\",\n    placeholder: \"Enter your name\",\n    label: \"Name\",\n    componentType: \"input\",\n  },\n  {\n    id: \"email\",\n    type: \"email\",\n    placeholder: \"Enter your email\",\n    label: \"Email\",\n    componentType: \"input\",\n  },\n  {\n    id: \"password\",\n    type: \"password\",\n    placeholder: \"Enter your password\",\n    label: \"Password\",\n    componentType: \"input\",\n  },\n  {\n    id: \"role\",\n    type: \"\",\n    placeholder: \"\",\n    label: \"Role\",\n    componentType: \"select\",\n    options: [\n      {\n        id: \"admin\",\n        label: \"Admin\",\n      },\n      {\n        id: \"customer\",\n        label: \"customer\",\n      },\n    ],\n  },\n];\n\nexport const loginFormControls = [\n  {\n    id: \"email\",\n    type: \"email\",\n    placeholder: \"Enter your email\",\n    label: \"Email\",\n    componentType: \"input\",\n  },\n  {\n    id: \"password\",\n    type: \"password\",\n    placeholder: \"Enter your password\",\n    label: \"Password\",\n    componentType: \"input\",\n  },\n];\n\nexport const adminAddProductformControls = [\n  {\n    id: \"name\",\n    type: \"text\",\n    placeholder: \"Enter name\",\n    label: \"Name\",\n    componentType: \"input\",\n  },\n  {\n    id: \"price\",\n    type: \"number\",\n    placeholder: \"Enter price\",\n    label: \"Price\",\n    componentType: \"input\",\n  },\n  {\n    id: \"description\",\n    type: \"text\",\n    placeholder: \"Enter description\",\n    label: \"Description\",\n    componentType: \"input\",\n  },\n  {\n    id: \"category\",\n    type: \"\",\n    placeholder: \"\",\n    label: \"Category\",\n    componentType: \"select\",\n    options: [\n      {\n        id: \"men\",\n        label: \"Men\",\n      },\n      {\n        id: \"women\",\n        label: \"Women\",\n      },\n      {\n        id: \"kids\",\n        label: \"Kids\",\n      },\n    ],\n  },\n  {\n    id: \"deliveryInfo\",\n    type: \"text\",\n    placeholder: \"Enter deliveryInfo\",\n    label: \"Delivery Info\",\n    componentType: \"input\",\n  },\n  {\n    id: \"onSale\",\n    type: \"\",\n    placeholder: \"\",\n    label: \"On Sale\",\n    componentType: \"select\",\n    options: [\n      {\n        id: \"yes\",\n        label: \"Yes\",\n      },\n      {\n        id: \"no\",\n        label: \"No\",\n      },\n    ],\n  },\n  {\n    id: \"priceDrop\",\n    type: \"number\",\n    placeholder: \"Enter Price Drop\",\n    label: \"Price Drop\",\n    componentType: \"input\",\n  },\n];\n\nexport const AvailableSizes = [\n  {\n    id: \"s\",\n    label: \"S\",\n  },\n  {\n    id: \"m\",\n    label: \"M\",\n  },\n  {\n    id: \"l\",\n    label: \"L\",\n  },\n];\n\nexport const firebaseConfig = {\n  apiKey: \"API_KEY\",\n  authDomain: \"AUTH_DOMAIN\",\n  projectId: \"PROJECT_ID\",\n  storageBucket: \"STROAGE_BUCKET\",\n  messagingSenderId: \"MESSAGING_SENDER_ID\",\n  appId: \"APP_ID\",\n  measurementId: \"MEASUREMENT_ID\",\n};\n\nexport const firebaseStroageURL =\n  \"YOUR_FIREBASE_STROAGE_URL\";\n\nexport const addNewAddressFormControls = [\n  {\n    id: \"fullName\",\n    type: \"input\",\n    placeholder: \"Enter your full name\",\n    label: \"Full Name\",\n    componentType: \"input\",\n  },\n  {\n    id: \"address\",\n    type: \"input\",\n    placeholder: \"Enter your full address\",\n    label: \"Address\",\n    componentType: \"input\",\n  },\n  {\n    id: \"city\",\n    type: \"input\",\n    placeholder: \"Enter your city\",\n    label: \"City\",\n    componentType: \"input\",\n  },\n  {\n    id: \"country\",\n    type: \"input\",\n    placeholder: \"Enter your country\",\n    label: \"Country\",\n    componentType: \"input\",\n  },\n  {\n    id: \"postalCode\",\n    type: \"input\",\n    placeholder: \"Enter your postal code\",\n    label: \"Postal Code\",\n    componentType: \"input\",\n  },\n];\n"
  },
  {
    "path": "tailwind.config.js",
    "content": "/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n  content: [\n    './src/pages/**/*.{js,ts,jsx,tsx,mdx}',\n    './src/components/**/*.{js,ts,jsx,tsx,mdx}',\n    './src/app/**/*.{js,ts,jsx,tsx,mdx}',\n  ],\n  theme: {\n    extend: {\n      backgroundImage: {\n        'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',\n        'gradient-conic':\n          'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))',\n      },\n    },\n  },\n  plugins: [],\n}\n"
  }
]