diff --git a/.gitignore b/.gitignore index 7b7dcdc..831cf37 100644 --- a/.gitignore +++ b/.gitignore @@ -3,12 +3,10 @@ *.sqlite3 -*.cpp -*.txt - *node_modules *.bin *db.sqlite3 db.sqlite3 *.vscode vscode +*media diff --git a/Backend/Dockerfile b/Backend/Dockerfile new file mode 100644 index 0000000..07d3e96 --- /dev/null +++ b/Backend/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.10 + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# Set the working directory in the container +WORKDIR /opt/app + +RUN pip install --upgrade pip +# Copy the requirements file into the container +COPY ./requirements.txt /opt/app + +# Install the required packages +RUN pip install -r requirements.txt + +# Copy the Django backend files into the container +COPY . /opt/app + +# Expose port 8000 for the Django server +EXPOSE 8000 + +# Run the Django server +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] \ No newline at end of file diff --git a/Backend/api/__pycache__/views.cpython-310.pyc b/Backend/api/__pycache__/views.cpython-310.pyc index 018c5a4..625bea2 100644 Binary files a/Backend/api/__pycache__/views.cpython-310.pyc and b/Backend/api/__pycache__/views.cpython-310.pyc differ diff --git a/Backend/api/accounts/__pycache__/serializers.cpython-310.pyc b/Backend/api/accounts/__pycache__/serializers.cpython-310.pyc index 3618d23..3dcd501 100644 Binary files a/Backend/api/accounts/__pycache__/serializers.cpython-310.pyc and b/Backend/api/accounts/__pycache__/serializers.cpython-310.pyc differ diff --git a/Backend/api/accounts/__pycache__/views.cpython-310.pyc b/Backend/api/accounts/__pycache__/views.cpython-310.pyc index 00fe14d..39a37ab 100644 Binary files a/Backend/api/accounts/__pycache__/views.cpython-310.pyc and b/Backend/api/accounts/__pycache__/views.cpython-310.pyc differ diff --git a/Backend/api/accounts/serializers.py b/Backend/api/accounts/serializers.py index 3b7603e..0cda5b6 100644 --- a/Backend/api/accounts/serializers.py +++ b/Backend/api/accounts/serializers.py @@ -50,7 +50,6 @@ def validate(self, attrs): password = attrs.get('password') password2 = attrs.get('password2') user = self.context.get('user') - # print(user) if password != password2: raise serializers.ValidationError("Password and Confirm Password don't match") @@ -70,12 +69,8 @@ def validate(self, attrs): if CustomUser.objects.filter(email=email).exists(): user = CustomUser.objects.get(email = email) uid = urlsafe_base64_encode(force_bytes(user.uid)) - # print('Encoded UID', uid) token = PasswordResetTokenGenerator().make_token(user) - # print('Password Reset Token', token) link = 'http://localhost:8000/api/accounts/reset-password/'+ uid +'/'+token - print('Password Reset Link', link) - # Send EMail body = 'Click Following Link to Reset Your Password ' + link data = { 'subject':'Reset Your Password', diff --git a/Backend/api/accounts/views.py b/Backend/api/accounts/views.py index 4ce78ba..002f9fe 100644 --- a/Backend/api/accounts/views.py +++ b/Backend/api/accounts/views.py @@ -34,9 +34,10 @@ from .mixins import PublicApiMixin, ApiErrorsMixin from .utils import google_get_access_token, google_get_user_info, generate_tokens_for_user from api.utils import upload_to_cloudinary - +from rest_framework.parsers import MultiPartParser, FormParser # Social Auth + class GoogleLoginApi(PublicApiMixin, ApiErrorsMixin, APIView): class InputSerializer(serializers.Serializer): code = serializers.CharField(required=False) @@ -112,7 +113,7 @@ def generate_verification_token(length = 32): class UserRegistrationView(APIView): permission_classes = [AllowAny] renderer_classes = [UserRenderer] - + parser_classes = [MultiPartParser, FormParser] def post(self, request, format=None): data = request.data data['profile_pic'] = upload_to_cloudinary(data['profile_pic']) @@ -174,12 +175,14 @@ def verify_account(request, uid, token): class UserLoginView(APIView): permission_classes = [AllowAny] renderer_classes = [UserRenderer] + parser_classes = [MultiPartParser, FormParser] def post(self, request, format=None): serializer = UserLoginSerializer(data=request.data) serializer.is_valid(raise_exception=True) email = serializer.data.get('email') password = serializer.data.get('password') user = authenticate(email=email, password=password) + print(user) if user is not None: if user.verified is not False: token = get_tokens_for_user(user) diff --git a/Backend/api/views.py b/Backend/api/views.py index a0173fc..b1c7317 100644 --- a/Backend/api/views.py +++ b/Backend/api/views.py @@ -3,4 +3,4 @@ # Create your views here. def home(request): - return JsonResponse({'info':'Django react Combos Home','name': 'Sagar Kumar Sameer'}) \ No newline at end of file + return JsonResponse({'info':'This is base api.'}) \ No newline at end of file diff --git a/Backend/backend/__pycache__/settings.cpython-310.pyc b/Backend/backend/__pycache__/settings.cpython-310.pyc index 81cdb15..c9de30e 100644 Binary files a/Backend/backend/__pycache__/settings.cpython-310.pyc and b/Backend/backend/__pycache__/settings.cpython-310.pyc differ diff --git a/Backend/backend/__pycache__/urls.cpython-310.pyc b/Backend/backend/__pycache__/urls.cpython-310.pyc index a785e8c..3f40024 100644 Binary files a/Backend/backend/__pycache__/urls.cpython-310.pyc and b/Backend/backend/__pycache__/urls.cpython-310.pyc differ diff --git a/Backend/backend/settings.py b/Backend/backend/settings.py index 5db3ec6..8acc5e3 100644 --- a/Backend/backend/settings.py +++ b/Backend/backend/settings.py @@ -101,23 +101,23 @@ # Database # https://docs.djangoproject.com/en/4.1/ref/settings/#databases -# DATABASES = { -# 'default': { -# 'ENGINE': 'django.db.backends.sqlite3', -# 'NAME': BASE_DIR / 'db.sqlite3', -# } -# } +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} -DATABASES = { - 'default': dj_database_url.config( - default=os.environ.get('DB_URL') - ) -} +# DATABASES = { +# 'default': dj_database_url.config( +# default=os.environ.get('DB_URL') +# ) +# } # 'default': { # 'ENGINE': 'django.db.backends.postgresql', # 'NAME': os.environ.get('DATABASE_NAME'), @@ -187,7 +187,9 @@ 'rest_framework.authentication.SessionAuthentication', 'rest_framework_simplejwt.authentication.JWTAuthentication', ], - + 'DEFAULT_PARSER_CLASSES': [ + 'rest_framework.parsers.JSONParser', + ] } @@ -243,7 +245,7 @@ # Cloudinary config CLOUDINARY_STORAGE = { - 'CLOUD_NAME' : os.environ.get('CLOUDNARY_CLOUD_NAME'), + 'CLOUD_NAME' : os.environ.get('CLOUDINARY_CLOUD_NAME'), 'API_KEY' : os.environ.get('CLOUDINARY_API_KEY'), 'API_SECRET' : os.environ.get('CLOUDINARY_API_SECRET') } diff --git a/Backend/backend/urls.py b/Backend/backend/urls.py index dda67ab..cac92f5 100644 --- a/Backend/backend/urls.py +++ b/Backend/backend/urls.py @@ -3,11 +3,12 @@ from django.urls import path,include from django.conf.urls.static import static from django.conf import settings - +from api.views import home urlpatterns = [ path('admin/', admin.site.urls), path('api/',include('api.urls')), + path('',include('api.urls')), ] urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT) diff --git a/Backend/docker-compose.yml b/Backend/docker-compose.yml new file mode 100644 index 0000000..2eb0c94 --- /dev/null +++ b/Backend/docker-compose.yml @@ -0,0 +1,36 @@ +version: '3' + +services: + web: + build: . + command: python manage.py runserver 0.0.0.0:8000 + volumes: + - .:/app + ports: + - "8000:8000" + depends_on: + - db + environment: + DJANGO_SETTINGS_MODULE: "backend.settings" + POSTGRES_DB: ${DB_NAME} + POSTGRES_USER: ${DB_USER} + POSTGRES_PASSWORD: ${DB_PASSWORD} + networks: + - backend + + db: + image: postgres:latest + volumes: + - postgres_data:/var/lib/postgresql/data + environment: + POSTGRES_DB: ${DATABASE_NAME} + POSTGRES_USER: ${DB_USER} + POSTGRES_PASSWORD: ${DB_PASSWORD} + networks: + - backend + +networks: + backend: + +volumes: + postgres_data: diff --git a/Backend/requirements.txt b/Backend/requirements.txt new file mode 100644 index 0000000..077174c --- /dev/null +++ b/Backend/requirements.txt @@ -0,0 +1,45 @@ +asgiref==3.7.2 +cachetools==5.3.2 +certifi==2023.11.17 +cffi==1.16.0 +charset-normalizer==3.3.2 +cloudinary==1.39.0 +cryptography==41.0.7 +defusedxml==0.7.1 +dj-database-url==2.1.0 +dj-rest-auth==5.0.2 +Django==5.0 +django-allauth==0.59.0 +django-ckeditor==6.7.1 +django-cloudinary-storage==0.3.0 +django-cors-headers==4.3.1 +django-environ==0.11.2 +django-js-asset==2.2.0 +djangorestframework==3.14.0 +djangorestframework-simplejwt==5.3.1 +google-auth==2.25.2 +google-auth-httplib2==0.2.0 +google-auth-oauthlib==1.2.0 +httplib2==0.22.0 +idna==3.6 +oauthlib==3.2.2 +Pillow==10.1.0 +psycopg2==2.9.9 +psycopg2-binary==2.9.9 +pyasn1==0.5.1 +pyasn1-modules==0.3.0 +pycparser==2.21 +PyJWT==2.8.0 +pyparsing==3.1.1 +python-dotenv==1.0.0 +python3-openid==3.2.0 +pytube==15.0.0 +pytz==2023.3.post1 +razorpay==1.4.1 +requests==2.31.0 +requests-oauthlib==1.3.1 +rsa==4.9 +six==1.16.0 +sqlparse==0.4.4 +typing_extensions==4.9.0 +urllib3==2.1.0 diff --git a/README.md b/README.md index 582ed35..77ae6e7 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This is an eCommerce web application built with Django and React.js. It utilizes - Frontend: - React.js: JavaScript library for building interactive user interfaces. - React Router Dom: Library for handling client-side routing in a React application. - + - React Redux Toolkit: Library for Managing states. ## Installation and Setup 1. Clone the repository: diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..ad138de --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,23 @@ +# Use the official Node image as the base image +FROM node:20-alpine + +# Set the working directory inside the container +WORKDIR /app + +# Copy package.json and package-lock.json to the working directory +COPY package*.json ./ + +# Install project dependencies +RUN npm install + +# Copy the entire project to the working directory +COPY . . + +# Build the React app +RUN npm run build + +# Expose the port on which the app will run +EXPOSE 3000 + +# Command to start the application +CMD ["npm", "start"] diff --git a/frontend/docker-compose.yml b/frontend/docker-compose.yml new file mode 100644 index 0000000..2ca8b32 --- /dev/null +++ b/frontend/docker-compose.yml @@ -0,0 +1,14 @@ +version: '3' + +services: + frontend: + build: + context: . + dockerfile: Dockerfile + ports: + - "3000:3000" + volumes: + - ./src:/app/src + - ./public:/app/public + environment: + - NODE_ENV=development diff --git a/frontend/src/category/AddCategory.js b/frontend/src/category/AddCategory.js index 75dfcf5..d1d8f4d 100644 --- a/frontend/src/category/AddCategory.js +++ b/frontend/src/category/AddCategory.js @@ -4,14 +4,10 @@ import { useDispatch } from 'react-redux'; import { createCategory } from '../features/actions/categoryActions'; import { unwrapResult } from '@reduxjs/toolkit'; import Swal from 'sweetalert2'; -import { useLocation, useNavigate } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; const AddCategory = () => { - - const location = useLocation(); - // console.log("location...", location); - const [values, setValues] = useState({ name: "", description: "", @@ -30,11 +26,9 @@ const AddCategory = () => { }; const onSubmit = async (e) => { - e.preventDefault(); // Corrected typo - + e.preventDefault(); const res1 = await dispatch(createCategory({ name, description })); const res = await unwrapResult(res1); - console.log("category res...", res); if (!res.errors) { Swal.fire({ icon: 'success', diff --git a/frontend/src/category/Categories.jsx b/frontend/src/category/Categories.jsx index e85466b..21f0845 100644 --- a/frontend/src/category/Categories.jsx +++ b/frontend/src/category/Categories.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, useRef } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { Link, useNavigate } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import { loadCategory } from '../features/actions/categoryActions'; const Categories = () => { diff --git a/frontend/src/features/actions/paymentAction.js b/frontend/src/features/actions/paymentAction.js index 0b2eea4..60beff3 100644 --- a/frontend/src/features/actions/paymentAction.js +++ b/frontend/src/features/actions/paymentAction.js @@ -1,5 +1,4 @@ -import Swal from 'sweetalert2'; import { API } from '../../backend'; import { createAsyncThunk } from "@reduxjs/toolkit"; diff --git a/frontend/src/helper/DisplayOrderList.jsx b/frontend/src/helper/DisplayOrderList.jsx index 83f78dd..b2a39e8 100644 --- a/frontend/src/helper/DisplayOrderList.jsx +++ b/frontend/src/helper/DisplayOrderList.jsx @@ -1,6 +1,5 @@ import React, { useState } from 'react'; import { Link } from 'react-router-dom'; -import { BaseUrl } from '../backend'; import { mapDeliveryTime, mapOderType, @@ -38,7 +37,7 @@ const DisplayOrderList = ({ data }) => {
- product image + product image
diff --git a/frontend/src/helper/ProductFilter.jsx b/frontend/src/helper/ProductFilter.jsx index a44d4d8..725f86d 100644 --- a/frontend/src/helper/ProductFilter.jsx +++ b/frontend/src/helper/ProductFilter.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react' +import React, { useState } from 'react' import { useDispatch } from 'react-redux'; import { filterProduct } from '../features/actions/productActions'; diff --git a/frontend/src/homepage/Layout.jsx b/frontend/src/homepage/Layout.jsx index ef7ef35..2500a04 100644 --- a/frontend/src/homepage/Layout.jsx +++ b/frontend/src/homepage/Layout.jsx @@ -1,8 +1,6 @@ import React, { useEffect } from 'react'; import Navbar from './Component/Navbar'; import Footer from './Component/Footer'; -import { useDispatch, useSelector } from 'react-redux'; -import { refreshToken } from '../features/actions/authActions'; import Categories from '../category/Categories'; diff --git a/frontend/src/product/GetProduct.jsx b/frontend/src/product/GetProduct.jsx index 36df258..afc2e3e 100644 --- a/frontend/src/product/GetProduct.jsx +++ b/frontend/src/product/GetProduct.jsx @@ -3,7 +3,6 @@ import Layout from '../homepage/Layout' import { Link, useParams } from 'react-router-dom' import { useDispatch, useSelector } from 'react-redux' import { loadProductData, searchProduct } from '../features/actions/productActions' -import { BaseUrl } from '../backend' import { timeAgo } from '../helper' import Loading from '../helper/Loading' import { unwrapResult } from '@reduxjs/toolkit'; @@ -79,7 +78,7 @@ const GetProduct = () => {
- +
diff --git a/frontend/src/product/ProductList.jsx b/frontend/src/product/ProductList.jsx index d1bf377..b0ebff0 100644 --- a/frontend/src/product/ProductList.jsx +++ b/frontend/src/product/ProductList.jsx @@ -1,7 +1,6 @@ import React from 'react' import { Link } from 'react-router-dom' import { timeAgo } from '../helper' -import { BaseUrl } from '../backend' import WishlistButton from './Component/WishlistButton' import CartButton from './Component/CartButton' import BuyNowButton from './Component/BuyNowButton' diff --git a/frontend/src/product/RelatedProduct.jsx b/frontend/src/product/RelatedProduct.jsx index 036cfa7..8649cc5 100644 --- a/frontend/src/product/RelatedProduct.jsx +++ b/frontend/src/product/RelatedProduct.jsx @@ -1,6 +1,5 @@ import React from 'react' import { Link } from 'react-router-dom' -import { BaseUrl } from '../backend' import { timeAgo } from '../helper' import WishlistButton from './Component/WishlistButton' @@ -18,7 +17,7 @@ const RelatedProduct = ({ data }) => {
- Default Product + Default Product
diff --git a/frontend/src/product/UpdateModal.jsx b/frontend/src/product/UpdateModal.jsx index fbb6a3c..207dc05 100644 --- a/frontend/src/product/UpdateModal.jsx +++ b/frontend/src/product/UpdateModal.jsx @@ -1,12 +1,10 @@ -import React, { useEffect, useState, useCallback } from 'react' +import React, { useEffect, useState} from 'react' import { useDispatch, useSelector } from 'react-redux'; import { useNavigate, useParams } from 'react-router-dom'; -import { loadAllProduct, loadProductData, updateProductData } from '../features/actions/productActions'; +import { loadAllProduct, updateProductData } from '../features/actions/productActions'; import { unwrapResult } from '@reduxjs/toolkit'; import Swal from 'sweetalert2'; import DatePicker from 'react-datepicker' -import { loadCategory } from '../features/actions/categoryActions'; -import { resetProductData } from '../features/slices/productSlice'; import Loading from '../helper/Loading'; import { CKEditor } from '@ckeditor/ckeditor5-react'; import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; diff --git a/frontend/src/product/UpdatePage.jsx b/frontend/src/product/UpdatePage.jsx index 4fd80ef..5a124f0 100644 --- a/frontend/src/product/UpdatePage.jsx +++ b/frontend/src/product/UpdatePage.jsx @@ -1,8 +1,7 @@ import React, {useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux'; +import { useSelector } from 'react-redux'; import { useParams } from 'react-router-dom'; import Layout from '../homepage/Layout'; -import { BaseUrl } from '../backend'; import UpdateModal from './UpdateModal'; import Loading from '../helper/Loading'; @@ -23,9 +22,7 @@ const UpdatePage = () => { const { uid } = useParams(); - const { data } = useSelector((state) => state.category); - - const { loading, list, error } = useSelector( + const { loading, list} = useSelector( (state) => state.seller ); const product = list.filter(product => product.uid === uid); @@ -94,18 +91,6 @@ const UpdatePage = () => { setShowDate(true); } - const renderDetailRow = (label, value) => ( -
- -

{label}:

{value} - - - - - - ); return ( @@ -148,7 +133,7 @@ const UpdatePage = () => { - No Product Image + No Product Image diff --git a/frontend/src/seller/OrderDashboard.jsx b/frontend/src/seller/OrderDashboard.jsx index 8325865..a42c95b 100644 --- a/frontend/src/seller/OrderDashboard.jsx +++ b/frontend/src/seller/OrderDashboard.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react' import { useDispatch, useSelector } from 'react-redux'; -import { UpdateOrderStatus, getOrders } from '../features/actions/sellerActions'; +import { getOrders } from '../features/actions/sellerActions'; import Layout from '../homepage/Layout'; import { Watch } from 'react-loader-spinner'; import { filterOrder } from '../features/actions/orderActions'; diff --git a/frontend/src/seller/ProcessOrder.jsx b/frontend/src/seller/ProcessOrder.jsx index 188a9b8..398b169 100644 --- a/frontend/src/seller/ProcessOrder.jsx +++ b/frontend/src/seller/ProcessOrder.jsx @@ -4,7 +4,6 @@ import { Link, useParams } from 'react-router-dom'; import { UpdateOrderStatus, getOrderDetails } from '../features/actions/sellerActions'; import Layout from '../homepage/Layout'; import { Watch } from 'react-loader-spinner'; -import { BaseUrl } from '../backend'; import { mapAddressCodeToLabel, mapGenderCodeToLabel, @@ -88,7 +87,7 @@ const ProcessOrder = () => {
- product image + product image
diff --git a/frontend/src/seller/SellerDashboard.jsx b/frontend/src/seller/SellerDashboard.jsx index d37bae2..995920e 100644 --- a/frontend/src/seller/SellerDashboard.jsx +++ b/frontend/src/seller/SellerDashboard.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react' import { useDispatch, useSelector } from 'react-redux'; -import { Link, useNavigate } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import Layout from '../homepage/Layout'; import { loadDashboard } from '../features/actions/sellerActions'; import Loading from '../helper/Loading'; diff --git a/frontend/src/seller/SellerProductLists.jsx b/frontend/src/seller/SellerProductLists.jsx index 46fac78..cac08c8 100644 --- a/frontend/src/seller/SellerProductLists.jsx +++ b/frontend/src/seller/SellerProductLists.jsx @@ -2,14 +2,11 @@ import React, { useEffect, useState } from 'react' import Layout from '../homepage/Layout' import { useDispatch, useSelector } from 'react-redux' import { loadProductList } from '../features/actions/sellerActions'; -import { BaseUrl } from '../backend'; import { Link, useNavigate } from 'react-router-dom'; -import UpdateModal from '../product/UpdateModal'; import Loading from '../helper/Loading'; const SellerProductLists = () => { - const [showModal, setShowModal] = useState(false); - + const dispatch = useDispatch(); const navigate = useNavigate(); @@ -25,20 +22,12 @@ const SellerProductLists = () => { navigate(`/user/seller/update-product/${uid}`) } - if (list.length === 0) { + if (list.length === 0 || loading) { return ( ) } - - const showModalHandler = () => { - setShowModal(true); - }; - const hideModalHandler = () => { - setShowModal(false); - }; - return ( @@ -66,7 +55,7 @@ const SellerProductLists = () => { - No Product Image + No Product pic diff --git a/frontend/src/user/Profile.js b/frontend/src/user/Profile.js index 21c161a..6b97862 100644 --- a/frontend/src/user/Profile.js +++ b/frontend/src/user/Profile.js @@ -4,7 +4,6 @@ import { Link, useNavigate } from 'react-router-dom'; import Layout from '../homepage/Layout'; import { laodProfile } from '../features/actions/authActions'; import { deleteAddress, loadAddress } from '../features/actions/addressAction'; -import { BaseUrl } from '../backend'; import { formateDate, mapAddressCodeToLabel, mapGenderCodeToLabel } from '../helper'; const Profile = () => { @@ -57,7 +56,6 @@ const Profile = () => {
{/* src={`${BaseUrl}/${user.profile_pic}`} */} {user.profile_pic ? ( - // src="https://lavinephotography.com.au/wp-content/uploads/2022/09/Fam_Kids024-1.jpg" Profile diff --git a/frontend/src/user/Signup.js b/frontend/src/user/Signup.js index f2e8087..3ac8b24 100644 --- a/frontend/src/user/Signup.js +++ b/frontend/src/user/Signup.js @@ -5,7 +5,6 @@ import { signup } from '../features/actions/authActions'; import { useDispatch, useSelector } from 'react-redux'; import Swal from 'sweetalert2'; import { unwrapResult } from '@reduxjs/toolkit'; -import { Watch } from 'react-loader-spinner'; import GoogleLoginButton from './SocialAuth/GoogleButton'; import Loading from '../helper/Loading'; diff --git a/frontend/src/user/helper/userapicalls.js b/frontend/src/user/helper/userapicalls.js index 094fae5..6ed7b3a 100644 --- a/frontend/src/user/helper/userapicalls.js +++ b/frontend/src/user/helper/userapicalls.js @@ -16,8 +16,7 @@ export const signin = async (user) => { method: "POST", body: formData, }); - const data = await response.json(); // Extract JSON data from the response - // console.log("Success from userapi...", data); + const data = await response.json(); return data; } catch (err) { diff --git a/frontend/src/useraction/address/AddAddress.jsx b/frontend/src/useraction/address/AddAddress.jsx index e6cf382..1b830cf 100644 --- a/frontend/src/useraction/address/AddAddress.jsx +++ b/frontend/src/useraction/address/AddAddress.jsx @@ -1,6 +1,5 @@ import React, { useEffect, useState } from 'react' import { createAddress } from '../../features/actions/addressAction'; -import Swal from 'sweetalert2'; import { useNavigate } from 'react-router-dom'; import { unwrapResult } from '@reduxjs/toolkit'; import { useDispatch } from 'react-redux'; diff --git a/frontend/src/useraction/cart/UserCart.jsx b/frontend/src/useraction/cart/UserCart.jsx index 2da1503..cf73fae 100644 --- a/frontend/src/useraction/cart/UserCart.jsx +++ b/frontend/src/useraction/cart/UserCart.jsx @@ -2,7 +2,6 @@ import React, { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { addToCart, loadCart, removeFromCart } from '../../features/actions/cartAction'; import Layout from '../../homepage/Layout'; -import { BaseUrl } from '../../backend'; import { Link } from 'react-router-dom'; const UserCart = () => { @@ -64,7 +63,7 @@ const UserCart = () => {
- product image + product image
diff --git a/frontend/src/useraction/order/OrderDetail.jsx b/frontend/src/useraction/order/OrderDetail.jsx index 2dc4ddb..ffc43d1 100644 --- a/frontend/src/useraction/order/OrderDetail.jsx +++ b/frontend/src/useraction/order/OrderDetail.jsx @@ -1,10 +1,8 @@ import React, { useEffect } from 'react' import Layout from '../../homepage/Layout' import { useDispatch, useSelector } from 'react-redux' -import { BaseUrl } from '../../backend' import { useParams } from 'react-router-dom' import { cancelOrReturnOrder, loadOrderData } from '../../features/actions/orderActions' -import { Watch } from 'react-loader-spinner'; import { Link } from 'react-router-dom'; import { mapAddressCodeToLabel, @@ -58,7 +56,7 @@ const OrderDetail = () => {
- product + product
diff --git a/frontend/src/useraction/order/OrderFromCart.jsx b/frontend/src/useraction/order/OrderFromCart.jsx index 3a9f5ca..db92076 100644 --- a/frontend/src/useraction/order/OrderFromCart.jsx +++ b/frontend/src/useraction/order/OrderFromCart.jsx @@ -1,32 +1,23 @@ import React, { useEffect, useState } from 'react' import { useDispatch, useSelector } from 'react-redux'; -import Layout from '../../homepage/Layout'; -import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'; -import { loadProductData } from '../../features/actions/productActions'; -import { BaseUrl } from '../../backend'; +import { Link, useNavigate} from 'react-router-dom'; import { loadAddress } from '../../features/actions/addressAction'; import { buyAll } from '../../features/actions/orderActions'; import { unwrapResult } from '@reduxjs/toolkit'; import { CompletePaymentForAll, InitiatePaymentForAll } from '../../features/actions/paymentAction'; import useRazorpay from "react-razorpay"; import Swal from 'sweetalert2'; -import { Watch } from 'react-loader-spinner' import { mapAddressCodeToLabel } from '../../helper'; +import Loading from '../../helper/Loading'; const OrderFromCart = () => { const [Razorpay] = useRazorpay(); const dispatch = useDispatch(); const navigate = useNavigate(); - const [add, setAdd] = useState(0); - const [remove, setRemove] = useState(0); const [addressdata, setAddress] = useState(""); const [paymentMode, setPaymentMode] = useState(""); - - const { pathname } = useLocation(); - const { uid } = useParams(); - const { isAuthenticated, redirect, user } = useSelector((state) => state.auth); const { address } = useSelector((state) => state.address); @@ -46,8 +37,8 @@ const OrderFromCart = () => { }, [isAuthenticated, dispatch]); - const { product, loading } = useSelector((state) => state.product); - const { payment_loading, payments, error } = useSelector((state) => state.payment); + const { loading } = useSelector((state) => state.product); + const { payment_loading, } = useSelector((state) => state.payment); const [checked, setChecked] = useState(false); @@ -73,15 +64,12 @@ const OrderFromCart = () => { if (paymentMode === "") { alert("Select Payment Mode.") } - console.log("submit clicked!") - console.log("address...", addressdata); - console.log("payment mode... ", paymentMode); + const res1 = await dispatch(buyAll({ address: addressdata, payment_mode: paymentMode })); const res = await unwrapResult(res1); - console.log("order res..", res); if (!res.errors) { if (paymentMode === 'ONL') { @@ -91,7 +79,6 @@ const OrderFromCart = () => { const payment_res = await dispatch(InitiatePaymentForAll({ orders: orders, amount: amount })); const response = await unwrapResult(payment_res); - console.log("response1...", response); if (response.success) { var order_id = response.data.razorpay_order_id @@ -109,7 +96,6 @@ const OrderFromCart = () => { signature: response.razorpay_signature, amount: amount })) - console.log("complete response...", response); Swal.fire({ icon: 'success', title: 'Orders Placed Successfully.', @@ -124,7 +110,7 @@ const OrderFromCart = () => { contact: user.phone, }, notes: { - address: "B P Mandal Colllege of engineering, Madhepura", + address: "XYZ, 2229992, Singapore", }, theme: { color: "#3399cc", @@ -166,20 +152,9 @@ const OrderFromCart = () => { } - if (loading) { + if (loading || payment_loading) { return ( -
- -
+ ) } return ( diff --git a/frontend/src/useraction/order/OrderList.jsx b/frontend/src/useraction/order/OrderList.jsx index 89b0f21..6c5d9f9 100644 --- a/frontend/src/useraction/order/OrderList.jsx +++ b/frontend/src/useraction/order/OrderList.jsx @@ -1,11 +1,10 @@ import React, { useEffect } from 'react' import { useDispatch, useSelector } from 'react-redux' -import { BaseUrl } from '../../backend'; import Layout from '../../homepage/Layout'; import { loadOrder } from '../../features/actions/orderActions'; -import { Watch } from 'react-loader-spinner'; import { Link } from 'react-router-dom'; import { mapOrderStatusToLabel, mapPaymentStatusToLabel,mapPaymentCodeToLabel } from '../../helper'; +import Loading from '../../helper/Loading'; @@ -22,20 +21,7 @@ const OrderList = () => { if (order_loading) { return ( - -
- -
- + ) } @@ -58,7 +44,7 @@ const OrderList = () => {
- product + product
diff --git a/frontend/src/useraction/order/OrderSummary.jsx b/frontend/src/useraction/order/OrderSummary.jsx index bbfe899..fe19e4e 100644 --- a/frontend/src/useraction/order/OrderSummary.jsx +++ b/frontend/src/useraction/order/OrderSummary.jsx @@ -3,14 +3,13 @@ import { useDispatch, useSelector } from 'react-redux'; import Layout from '../../homepage/Layout'; import { Link, useLocation, useNavigate, useParams } from 'react-router-dom'; import { loadProductData } from '../../features/actions/productActions'; -import { BaseUrl } from '../../backend'; import { loadAddress } from '../../features/actions/addressAction'; import { createOrder } from '../../features/actions/orderActions'; import { unwrapResult } from '@reduxjs/toolkit'; import { CompletePayment, InitiatePayment } from '../../features/actions/paymentAction'; import useRazorpay from "react-razorpay"; import Swal from 'sweetalert2'; -import { Watch } from 'react-loader-spinner' +import Loading from '../../helper/Loading'; const OrderSummary = () => { @@ -31,6 +30,7 @@ const OrderSummary = () => { useEffect(() => { document.title = 'Order summary'; }, []); + useEffect(() => { if (isAuthenticated) { dispatch(loadProductData({ uid })); @@ -54,7 +54,7 @@ const OrderSummary = () => { const { product, loading } = useSelector((state) => state.product); - const { payment_loading, payments, error } = useSelector((state) => state.payment); + const { payment_loading } = useSelector((state) => state.payment); const removeItem = () => { if (quantity > 1) { @@ -93,36 +93,14 @@ const OrderSummary = () => { if (product.length === 0 || loading) { return ( -
- -
+ ) } const onSubmit = async () => { if (payment_loading) { return ( -
- -
+ ) } if (addressdata === "") { @@ -184,7 +162,7 @@ const OrderSummary = () => { contact: user.phone, }, notes: { - address: "B P Mandal Colllege of engineering, Madhepura", + address: "XYZ, 8877667, Singapore", }, theme: { color: "#3399cc", @@ -192,7 +170,6 @@ const OrderSummary = () => { }; const rzp1 = new Razorpay(options); - // console.log("rzp1..", rzp1); rzp1.on("payment.failed", function (response) { Swal.fire({ icon: 'error', @@ -261,7 +238,7 @@ const OrderSummary = () => {
- product + product
diff --git a/frontend/src/useraction/wishlist/Wishlist.jsx b/frontend/src/useraction/wishlist/Wishlist.jsx index becd547..510dcc0 100644 --- a/frontend/src/useraction/wishlist/Wishlist.jsx +++ b/frontend/src/useraction/wishlist/Wishlist.jsx @@ -1,7 +1,6 @@ import React, { useEffect, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { loadWishlist, removeFromWishlist } from '../../features/actions/wishlistAction'; -import { BaseUrl } from '../../backend'; import { addToCart } from '../../features/actions/cartAction'; import Layout from '../../homepage/Layout'; @@ -44,7 +43,7 @@ const Wishlist = () => {
- product image + product image