diff --git a/.github/workflows/prodtest.yml b/.github/workflows/prodtest.yml index 80d315e3..5b7fcf70 100644 --- a/.github/workflows/prodtest.yml +++ b/.github/workflows/prodtest.yml @@ -10,36 +10,36 @@ on: - main jobs: - cypress-run: - runs-on: ubuntu-latest - - container: cypress/browsers:node18.12.0-chrome107 - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: set environment variables - uses: allenevans/set-env@v2.0.0 - with: - HUSKY: 0 - - - name: "Cypress Tests - Chrome" - uses: cypress-io/github-action@v4.2.0 - with: - install: true - build: npm run build - start: npm run dev - wait-on: "http://localhost:3000" - wait-on-timeout: 120 - browser: chrome - spec: cypress/e2e/* - env: - CI: "false" + # cypress-run: + # runs-on: ubuntu-latest + + # container: cypress/browsers:node18.12.0-chrome107 + + # steps: + # - name: Checkout + # uses: actions/checkout@v3 + + # - name: set environment variables + # uses: allenevans/set-env@v2.0.0 + # with: + # HUSKY: 0 + + # - name: "Cypress Tests - Chrome" + # uses: cypress-io/github-action@v4.2.0 + # with: + # install: true + # build: npm run build + # start: npm run dev + # wait-on: "http://localhost:3000" + # wait-on-timeout: 120 + # browser: chrome + # spec: cypress/e2e/* + # env: + # CI: "false" Deploy-Production: - needs: cypress-run - if: success() + # needs: cypress-run + # if: success() runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/prodtestbeta.yml b/.github/workflows/prodtestbeta.yml deleted file mode 100644 index 25897f63..00000000 --- a/.github/workflows/prodtestbeta.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: 🚀 BETA -> E2E Tests + Production Deploy (Frontend) - -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_BETA }} - -on: - push: - branches: - - beta - -jobs: - cypress-run: - runs-on: ubuntu-latest - - container: cypress/browsers:node18.12.0-chrome107 - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: set environment variables - uses: allenevans/set-env@v2.0.0 - with: - HUSKY: 0 - - - name: "Cypress Tests - Chrome" - uses: cypress-io/github-action@v4.2.0 - with: - install: true - build: npm run build - start: npm run dev - wait-on: "http://localhost:3000" - wait-on-timeout: 120 - browser: chrome - spec: cypress/e2e/* - env: - CI: "false" - - Deploy-Production: - needs: cypress-run - if: success() - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Install Vercel CLI - run: npm install --global vercel@canary - - name: Pull Vercel Environment Information - run: - vercel pull --yes --environment=production --token=${{ - secrets.VERCEL_TOKEN }} - - name: Build Project Artifacts - run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} - - name: Deploy Project Artifacts to Vercel - run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/prtestbeta.yml b/.github/workflows/prtestbeta.yml deleted file mode 100644 index 0085213c..00000000 --- a/.github/workflows/prtestbeta.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: 👩🏻‍🚀 BETA -> E2E Tests + Preview Deploy (Frontend) - -env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_BETA }} - DEPLOY_PR_FROM_FORK: true - -on: - pull_request_target: - types: [opened, synchronize, reopened] - branches: - - beta - -jobs: - cypress-run: - runs-on: ubuntu-latest - # use docker container to run tests - container: cypress/browsers:node18.12.0-chrome107 - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install npm - run: npm install -g husky - - - name: set environment variables - uses: allenevans/set-env@v2.0.0 - with: - HUSKY: 0 - - - name: "Cypress Tests - Chrome" - uses: cypress-io/github-action@v4.2.0 - with: - install: true - build: npm run build - start: npm run dev - wait-on: "http://localhost:3000" - wait-on-timeout: 120 - browser: chrome - spec: cypress/e2e/* - env: - CI: "false" - - Deploy-Preview: - needs: cypress-run - if: success() - runs-on: ubuntu-latest - - steps: - - id: script - uses: actions/github-script@v3 - with: - script: | - const isPr = [ 'pull_request', 'pull_request_target' ].includes(context.eventName) - core.setOutput('ref', isPr ? context.payload.pull_request.head.ref : context.ref) - core.setOutput('repo', isPr ? context.payload.pull_request.head.repo.full_name : context.repo.full_name) - - - name: Checkout - uses: actions/checkout@v2 - with: - ref: ${{ github.event.pull_request.head.ref }} - repository: ${{ steps.script.outputs.repo }} - - - name: Create Branch - uses: peterjgrainger/action-create-branch@v2.2.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - branch: "${{ github.event.pull_request.head.ref }}" - sha: "${{ github.event.pull_request.head.sha }}" - - - name: Deploy to Vercel Action - uses: BetaHuhn/deploy-to-vercel-action@latest - with: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_BETA }} - DEPLOY_PR_FROM_FORK: true - DELETE_EXISTING_COMMENT: true diff --git a/.github/workflows/prtests.yml b/.github/workflows/prtests.yml index 720d17d8..a4e48624 100644 --- a/.github/workflows/prtests.yml +++ b/.github/workflows/prtests.yml @@ -14,38 +14,38 @@ on: - main jobs: - cypress-run: - runs-on: ubuntu-latest - # use docker container to run tests - container: cypress/browsers:node18.12.0-chrome107 - steps: - - name: Checkout - uses: actions/checkout@v3 + # cypress-run: + # runs-on: ubuntu-latest + # # use docker container to run tests + # container: cypress/browsers:node18.12.0-chrome107 + # steps: + # - name: Checkout + # uses: actions/checkout@v3 - - name: Install npm - run: npm install -g husky + # - name: Install npm + # run: npm install -g husky - - name: set environment variables - uses: allenevans/set-env@v2.0.0 - with: - HUSKY: 0 + # - name: set environment variables + # uses: allenevans/set-env@v2.0.0 + # with: + # HUSKY: 0 - - name: "Cypress Tests - Chrome" - uses: cypress-io/github-action@v4.2.0 - with: - install: true - build: npm run build - start: npm run dev - wait-on: "http://localhost:3000" - wait-on-timeout: 120 - browser: chrome - spec: cypress/e2e/* - env: - CI: "false" + # - name: "Cypress Tests - Chrome" + # uses: cypress-io/github-action@v4.2.0 + # with: + # install: true + # build: npm run build + # start: npm run dev + # wait-on: "http://localhost:3000" + # wait-on-timeout: 120 + # browser: chrome + # spec: cypress/e2e/* + # env: + # CI: "false" Deploy-Preview: - needs: cypress-run - if: success() + # needs: cypress-run + # if: success() runs-on: ubuntu-latest steps: diff --git a/src/App.jsx b/src/App.jsx index bd89bbf5..0ef6b682 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,7 +1,7 @@ import { LocalizationProvider } from "@mui/x-date-pickers"; import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; -import React from "react"; +import { Suspense } from "react"; import { Route, BrowserRouter as Router, Routes } from "react-router-dom"; import { ToastContainer } from "react-toastify"; import { BacktoTop } from "./components/shared"; @@ -17,18 +17,20 @@ const App = () => {
- - - {routesConfig.map((route, index) => ( - - ))} - - + + + + {routesConfig.map((route, index) => ( + + ))} + + +
diff --git a/src/components/private/events/create/CreateEvents.jsx b/src/components/private/events/create/CreateEvents.jsx index 06387b05..4525153f 100644 --- a/src/components/private/events/create/CreateEvents.jsx +++ b/src/components/private/events/create/CreateEvents.jsx @@ -9,7 +9,7 @@ import Select from "@mui/material/Select"; import { DatePicker } from "@mui/x-date-pickers/DatePicker"; import { TimePicker } from "@mui/x-date-pickers/TimePicker"; import dayjs from "dayjs"; -import React, { useCallback, useState } from "react"; +import { useCallback, useState } from "react"; import "react-calendar/dist/Calendar.css"; import "react-clock/dist/Clock.css"; import { IoMdCloseCircleOutline } from "react-icons/io"; @@ -51,7 +51,6 @@ const CreateEvents = ({ setshowCreateModal }) => { const handleCreateBase64 = useCallback(async (e) => { const base64 = await convertToBase64(e); - console.log("🚀 ~ handleCreateBase64 ~ base64:", base64); setevent((prevEvent) => ({ ...prevEvent, coverImage: base64 })); e.target.value = ""; }, []); @@ -76,13 +75,7 @@ const CreateEvents = ({ setshowCreateModal }) => { />
-

{ - console.log(Object.keys(errors).length); - }} - > - Create -

+

Create

diff --git a/src/components/private/landing/Landing.jsx b/src/components/private/landing/Landing.jsx index 959d59e9..54c14e80 100644 --- a/src/components/private/landing/Landing.jsx +++ b/src/components/private/landing/Landing.jsx @@ -1,5 +1,5 @@ import Cookies from "js-cookie"; -import React, { useEffect, useState } from "react"; +import { useEffect, useState } from "react"; import Vector from "../../../assets/pictures/Banner/Vector.png"; import { Button } from "../../shared"; import "./Landing.scss"; @@ -55,7 +55,7 @@ const Landing = () => { ) : ( )} diff --git a/src/components/shared/navbar/Navbar.jsx b/src/components/shared/navbar/Navbar.jsx index ad1d626e..76016289 100644 --- a/src/components/shared/navbar/Navbar.jsx +++ b/src/components/shared/navbar/Navbar.jsx @@ -1,5 +1,5 @@ import Cookies from "js-cookie"; -import React, { useEffect, useState } from "react"; +import { useEffect, useState } from "react"; import { FaChevronRight } from "react-icons/fa6"; import { GiHamburgerMenu } from "react-icons/gi"; import { RxCross2 } from "react-icons/rx"; @@ -67,12 +67,14 @@ const Navbar = () => { if (data?.status === 200) { showSuccessToast(data?.data?.message); - setTimeout(() => { - navigate("/"); - dispatch(resetUserData()); - Cookies.remove("skipProfileCompletion"); - localStorage.clear(); - }, 1500); + + navigate("/"); + dispatch(resetUserData()); + Cookies.remove("skipProfileCompletion"); + localStorage.clear(); + document + .querySelector(".nav_dropdown") + .classList.toggle("nav_dropdown_visible"); } else { showErrorToast(data?.message); } @@ -104,7 +106,7 @@ const Navbar = () => { ); })}
- {Cookies.get("isLoggedIn") || isLoggedIn ? ( + {Cookies.get("Token") && isLoggedIn ? ( { )} {!isNavbarOpen && - (Cookies.get("isLoggedIn") ? ( + (Cookies.get("Token") ? ( { - console.log("🚀 ~ ProfileCompletion ~ editProfile:", editProfile); const [part, setPart] = useState(editProfile ? 2 : 1); const [currentStep, setcurrentStep] = useState(2); const [currentIndex, setcurrentIndex] = useState(0); const [formData, setFormData] = useState({}); const [errors, setErrors] = useState({}); const user = useSelector((state) => state.user); - console.log("🚀 ~ user:", user); useEffect(() => { if (editProfile) { @@ -50,7 +48,7 @@ const ProfileCompletion = ({ editProfile }) => { // formData is an object // lenght of an object - console.log(Object.keys(formData).length); + // const response = await UpdateUser(formData); // if (response?.status !== 200) { // showErrorToast(response?.data?.message); diff --git a/src/hooks/useAuth.js b/src/hooks/useAuth.js index 52b9230f..ba6d1ea4 100644 --- a/src/hooks/useAuth.js +++ b/src/hooks/useAuth.js @@ -47,7 +47,7 @@ export function useAuth(authType) { if (response?.status === 201 || response?.status === 200) { showSuccessToast(response?.data?.message); - dispatch(updateUserData(response.data.user)); + dispatch(updateUserData({ ...response.data.user, isLoggedIn: true })); setTimeout(() => { navigate("/"); diff --git a/src/hooks/useEvent.js b/src/hooks/useEvent.js index 1e936a1c..7b4eb082 100644 --- a/src/hooks/useEvent.js +++ b/src/hooks/useEvent.js @@ -1,7 +1,6 @@ import { useDispatch } from "react-redux"; import { useSWRConfig } from "swr"; import { eventEndpoints } from "../integrations/ApiEndpoints"; -import { updateCreatedEvents } from "../redux/slice/eventSlice"; import { CreateEvent } from "../service/MilanApi"; import { showErrorToast, showSuccessToast } from "../utils/Toasts"; @@ -68,7 +67,7 @@ export function useEvent(event) { if (response.status === 201) { showSuccessToast(response.data.message); setshowCreateModal(false); - dispatch(updateCreatedEvents(response.data.savedEvent)); + mutate(eventEndpoints.all); } else { showErrorToast(response.response.data.message); diff --git a/src/pages/auth/SignIn.jsx b/src/pages/auth/SignIn.jsx index 72972ef2..3e1935f4 100644 --- a/src/pages/auth/SignIn.jsx +++ b/src/pages/auth/SignIn.jsx @@ -18,11 +18,9 @@ const SignIn = () => { }); const [errors, setErrors] = useState({}); - // Auth functions const { authenticateUser, loading } = useAuth("signin"); const [showPassword, setshowPassword] = useState(false); - // Handlers const handleGoogle = async () => { const response = await GoogleAuth(); window.location.href = response; diff --git a/src/redux/slice/authSlice.js b/src/redux/slice/authSlice.js deleted file mode 100644 index cdbb5382..00000000 --- a/src/redux/slice/authSlice.js +++ /dev/null @@ -1,22 +0,0 @@ -import { createSlice } from "@reduxjs/toolkit"; - -const initialState = { - authTypeOptions: [ - { value: "individual", label: "Individual (Person)" }, - { value: "club", label: "Organization (Charity/Club/NGO)" }, - ], - authType: "individual", -}; - -const authSlice = createSlice({ - name: "auth", - initialState, - reducers: { - setAuthType: (state, action) => { - state.authType = action.payload; - }, - }, -}); - -export const { setAuthType } = authSlice.actions; -export default authSlice.reducer; diff --git a/src/redux/slice/eventSlice.js b/src/redux/slice/eventSlice.js deleted file mode 100644 index f9879ef3..00000000 --- a/src/redux/slice/eventSlice.js +++ /dev/null @@ -1,19 +0,0 @@ -import { createSlice } from "@reduxjs/toolkit"; - -const initialState = { - created: [], - attending: [], -}; - -const eventSlice = createSlice({ - name: "event", - initialState, - reducers: { - updateCreatedEvents: (state, action) => { - state.created = [...state.created, action.payload]; - }, - }, -}); - -export const { updateCreatedEvents } = eventSlice.actions; -export default eventSlice.reducer; diff --git a/src/redux/slice/userSlice.js b/src/redux/slice/userSlice.js index e0663e96..03fd846b 100644 --- a/src/redux/slice/userSlice.js +++ b/src/redux/slice/userSlice.js @@ -1,6 +1,6 @@ import { createSlice } from "@reduxjs/toolkit"; -const initialState = {}; +const initialState = { isLoggedIn: false, user: {} }; const userSlice = createSlice({ name: "user", @@ -26,6 +26,8 @@ const userSlice = createSlice({ }, }); +export const selectIsLoggedIn = (state) => state.user.isLoggedIn; + export const { updateUserData, resetUserData, toggleUserLogin } = userSlice.actions; export default userSlice.reducer; diff --git a/src/redux/store.js b/src/redux/store.js index 904c0eb0..d444510e 100644 --- a/src/redux/store.js +++ b/src/redux/store.js @@ -1,14 +1,10 @@ import { combineReducers, configureStore } from "@reduxjs/toolkit"; import { persistReducer, persistStore } from "redux-persist"; import storage from "redux-persist/lib/storage"; -import authReducer from "./slice/authSlice"; -import eventReducer from "./slice/eventSlice"; import userReducer from "./slice/userSlice"; const rootReducer = combineReducers({ user: userReducer, - auth: authReducer, - event: eventReducer, }); const persistConfig = { diff --git a/src/utils/Auth/DonotRenderWhenLoggedIn.jsx b/src/utils/Auth/DonotRenderWhenLoggedIn.jsx new file mode 100644 index 00000000..9cb61293 --- /dev/null +++ b/src/utils/Auth/DonotRenderWhenLoggedIn.jsx @@ -0,0 +1,25 @@ +import { selectIsLoggedIn } from "@redux/slice/userSlice"; +import Cookies from "js-cookie"; +import { useSelector } from "react-redux"; +import { Navigate } from "react-router-dom"; + +const DonotRenderWhenLoggedIn = (Component) => { + const WrappedComponent = (props) => { + const token = Cookies.get("Token"); + const isLoggedIn = useSelector(selectIsLoggedIn); + + if (token && isLoggedIn) { + return ; + } + + return ; + }; + + WrappedComponent.displayName = `WithUserLoggedInRoute(${ + Component.displayName || Component.name || "Component" + })`; + + return WrappedComponent; +}; + +export default DonotRenderWhenLoggedIn; diff --git a/src/utils/Auth/RenderErrorMessage.jsx b/src/utils/Auth/RenderErrorMessage.jsx index 8dcc898f..f969676a 100644 --- a/src/utils/Auth/RenderErrorMessage.jsx +++ b/src/utils/Auth/RenderErrorMessage.jsx @@ -1,5 +1,4 @@ export const renderErrorMessage = (fieldName, formState) => { - console.log(formState); return ( formState?.errors?.length > 0 && (
diff --git a/src/utils/checkMissingFields.js b/src/utils/checkMissingFields.js index 1342a385..714faf2d 100644 --- a/src/utils/checkMissingFields.js +++ b/src/utils/checkMissingFields.js @@ -15,7 +15,6 @@ */ export function checkMissingFields(info) { - console.log("🚀 ~ checkMissingFields ~ info:", info); if ( info?.city === undefined || info?.state === undefined || @@ -23,7 +22,6 @@ export function checkMissingFields(info) { info?.country === undefined || info?.pincode === undefined ) { - console.log("🚀 ~ checkMissingFields ~ info", info); return true; } else if ( (info?.userType === "club" && info?.tagLine === undefined) || diff --git a/src/utils/getProfileFields.js b/src/utils/getProfileFields.js index 15a78f36..12f1e304 100644 --- a/src/utils/getProfileFields.js +++ b/src/utils/getProfileFields.js @@ -1,5 +1,4 @@ function getMissingElements(info) { - console.log("🚀 ~ getMissingElements ~ info:", info); const missing = []; if (info?.userType === "club") { diff --git a/src/utils/routesConfig.jsx b/src/utils/routesConfig.jsx index 41d152ec..1b4a1797 100644 --- a/src/utils/routesConfig.jsx +++ b/src/utils/routesConfig.jsx @@ -1,21 +1,32 @@ -import SignIn from "@pages/auth/SignIn"; -import Test from "../pages/Test"; -import Trending from "../pages/Trending"; +import Home from "@pages/Home"; import { Clubs, Dashboard, Error404, Events, - Home, Profile, Shop, - SignUp, -} from "../pages/route"; +} from "@pages/route"; +import Trending from "@pages/Trending"; +import { lazy } from "react"; +import { default as DonotRenderWhenLoggedIn } from "./Auth/DonotRenderWhenLoggedIn"; + +const SignIn = lazy(() => import("@pages/auth/SignIn")); +const SignUp = lazy(() => import("@pages/auth/SignUp")); + +const ProtectedSignIn = DonotRenderWhenLoggedIn(SignIn); +const ProtectedSignUp = DonotRenderWhenLoggedIn(SignUp); const routesConfig = [ { path: "/", element: }, - { path: "/auth/signup", element: }, - { path: "/auth/signin", element: }, + { + path: "/auth/signup", + element: , + }, + { + path: "/auth/signin", + element: , + }, { path: "/user/:userName", element: }, { path: "/clubs", element: }, { path: "/club/:userName", element: }, @@ -23,7 +34,6 @@ const routesConfig = [ { path: "/events", element: }, { path: "/shop", element: }, { path: "/trending", element: }, - { path: "/test", element: }, { path: "*", element: }, ];