From 5e8cf8851f5e64bd8392826b772a90d33db329c5 Mon Sep 17 00:00:00 2001 From: Sinthusan Date: Sat, 4 May 2024 12:46:09 +0800 Subject: [PATCH 1/6] Refactor code --- src/App.tsx | 47 ++-- src/assets/icons/link.svg | 4 +- .../Breadcrumbs/Breadcrumbs.tsx} | 13 +- src/components/Breadcrumbs/index.ts | 1 + src/components/Container/Container.tsx | 10 + src/components/Container/index.ts | 1 + src/components/Footer/Footer.tsx | 196 ++++++++++++++++ src/components/Footer/index.ts | 1 + src/components/Header/Header.tsx | 142 ++++++++++++ src/components/Header/index.ts | 1 + .../NavigationButton}/NavigationButton.tsx | 0 src/components/NavigationButton/index.ts | 1 + .../ScrollAnimation}/ScrollAnimation.tsx | 0 src/components/ScrollAnimation/index.ts | 1 + src/data/auth/authContext.tsx | 2 +- src/data/model/organisation.ts | 18 +- src/data/model/organisationAdmin.ts | 8 +- .../organisationProfileFAQ.ts | 4 +- .../organisationProfileImpact.ts | 6 +- .../organisationProfileOurStory.ts | 6 +- .../organisationProfilePeopleSpotlight.ts | 6 +- src/data/model/organisationSummary.ts | 6 +- src/data/model/user.ts | 6 +- src/features/common/NavigationBar.tsx | 135 ----------- src/features/common/footer.tsx | 194 ---------------- .../firestore-mock/test-data/users.json | 13 -- src/features/home/components/FrontPage.tsx | 70 ------ src/features/home/components/FrontSupport.tsx | 119 ---------- src/features/home/index.tsx | 214 ------------------ .../login/components/email-credential.tsx | 59 ----- .../login/components/forgot-password.tsx | 14 -- .../components/google-sign-in-button.tsx | 50 ---- .../login/components/login-menu-message.tsx | 28 --- .../login/components/login-section.tsx | 32 --- .../login/components/sign-in-button.tsx | 55 ----- src/features/login/login-page.tsx | 19 -- .../components/ViewToggle.tsx | 53 ----- .../components/summary.tsx | 147 ------------ src/features/page-style.scss | 18 -- .../FirestoreMock.tsx} | 44 ++-- .../InitialOrganisationsMock.ts} | 28 +-- .../QuillEditor.tsx} | 0 .../TestOrganisationsMock.ts} | 26 +-- src/mocks/UsersMock.ts | 13 ++ src/pages/Home/HeroSection.tsx | 74 ++++++ src/pages/Home/Home.tsx | 149 ++++++++++++ src/pages/Home/SupportSection.tsx | 126 +++++++++++ src/pages/Home/TogetherSection.tsx | 53 +++++ src/pages/Home/index.ts | 1 + src/{features/home => pages/Home}/styles.ts | 0 src/pages/Login/EmailCredential.tsx | 60 +++++ src/pages/Login/ForgotPassword.tsx | 17 ++ src/pages/Login/GoogleSignInButton.tsx | 52 +++++ src/pages/Login/Login.tsx | 19 ++ .../Login/LoginDesign.tsx} | 0 .../Login/LoginForm.tsx} | 8 +- src/pages/Login/LoginMenuMessage.tsx | 18 ++ .../Login/LoginSection.tsx} | 20 +- src/pages/Login/SignInButton.tsx | 57 +++++ .../sign-up.tsx => pages/Login/SignUp.tsx} | 2 +- src/pages/Login/index.ts | 1 + .../login.scss => pages/Login/style.scss} | 2 - .../OrganisationList}/CardView.tsx | 6 +- .../OrganisationList/Const.ts} | 8 +- .../OrganisationList}/ListView.tsx | 16 +- .../OrganisationList/NavigationBar.tsx} | 0 .../OrganisationList/OrganisationCard.tsx} | 6 +- .../OrganisationList/OrganisationList.tsx} | 98 ++++---- src/pages/OrganisationList/ViewToggle.tsx | 88 +++++++ src/pages/OrganisationList/index.ts | 1 + .../OrganisationProfile.tsx} | 28 +-- .../OrganisationProfile/Profile.tsx} | 96 ++++---- .../OrganisationProfile/ProfileContent.tsx} | 2 +- .../OrganisationProfile/ProfileSidebar.tsx} | 0 .../OrganisationProfile/Services.tsx} | 12 +- .../SimilarOrganisations.tsx} | 14 +- src/pages/OrganisationProfile/Summary.tsx | 150 ++++++++++++ src/pages/OrganisationProfile/index.ts | 1 + .../OrganisationProfile}/profile.scss | 3 - .../OrganisationProfile}/services.scss | 5 - .../OrganisationProfile}/similar-orgs.scss | 0 .../OrganisationProfile}/summary.scss | 0 .../Registration/GoalsForm.tsx} | 10 +- .../Registration/OrganisationInfoForm.tsx} | 16 +- .../Registration/ProfileSetup.tsx} | 24 +- .../Registration/Registration.tsx} | 10 +- .../Registration/RegistrationDesign.tsx} | 4 +- .../Registration/RegistrationForm.tsx} | 20 +- .../Registration/RegistrationMenuMessage.tsx} | 4 +- .../Registration/RegistrationSection.tsx | 37 +++ .../Registration/SignIn.tsx} | 8 +- .../Registration/SignUpButton.tsx} | 14 +- .../Registration/SignUpWaiting.tsx} | 22 +- src/pages/Registration/index.ts | 1 + .../Registration}/registration.scss | 2 - .../scss => pages/Registration}/setup.scss | 2 - .../UserDashboard/UserDashboard.tsx} | 9 +- src/pages/UserDashboard/index.ts | 1 + src/pages/style.scss | 15 ++ src/{paths.ts => routing/Paths.ts} | 0 src/routing/Routing.tsx | 29 +++ src/routing/index.ts | 1 + src/services/Authentication.ts | 4 +- .../{http-common.ts => HttpCommon.ts} | 0 src/services/firebase/authProvider.tsx | 10 +- src/services/firebase/storage.ts | 2 +- src/utilities/icon-mappings.tsx | 61 ----- src/utilities/iconMappings/iconMapping.tsx | 61 +++++ src/utilities/iconMappings/index.ts | 1 + src/utilities/validators/index.ts | 1 + src/utilities/{ => validators}/validators.ts | 0 111 files changed, 1721 insertions(+), 1652 deletions(-) rename src/{features/common/orgBreadCrumb.tsx => components/Breadcrumbs/Breadcrumbs.tsx} (80%) create mode 100644 src/components/Breadcrumbs/index.ts create mode 100644 src/components/Container/Container.tsx create mode 100644 src/components/Container/index.ts create mode 100644 src/components/Footer/Footer.tsx create mode 100644 src/components/Footer/index.ts create mode 100644 src/components/Header/Header.tsx create mode 100644 src/components/Header/index.ts rename src/{features/home/components => components/NavigationButton}/NavigationButton.tsx (100%) create mode 100644 src/components/NavigationButton/index.ts rename src/{features/home/components => components/ScrollAnimation}/ScrollAnimation.tsx (100%) create mode 100644 src/components/ScrollAnimation/index.ts delete mode 100644 src/features/common/NavigationBar.tsx delete mode 100644 src/features/common/footer.tsx delete mode 100644 src/features/firestore-mock/test-data/users.json delete mode 100644 src/features/home/components/FrontPage.tsx delete mode 100644 src/features/home/components/FrontSupport.tsx delete mode 100644 src/features/home/index.tsx delete mode 100644 src/features/login/components/email-credential.tsx delete mode 100644 src/features/login/components/forgot-password.tsx delete mode 100644 src/features/login/components/google-sign-in-button.tsx delete mode 100644 src/features/login/components/login-menu-message.tsx delete mode 100644 src/features/login/components/login-section.tsx delete mode 100644 src/features/login/components/sign-in-button.tsx delete mode 100644 src/features/login/login-page.tsx delete mode 100644 src/features/organisation-list/components/ViewToggle.tsx delete mode 100644 src/features/organisation-profile/components/summary.tsx delete mode 100644 src/features/page-style.scss rename src/{features/firestore-mock/firestore-mock.tsx => mocks/FirestoreMock.tsx} (74%) rename src/{features/firestore-mock/test-data/initial-organisations.ts => mocks/InitialOrganisationsMock.ts} (92%) rename src/{features/firestore-mock/quill-editor.tsx => mocks/QuillEditor.tsx} (100%) rename src/{features/firestore-mock/test-data/test-organisations.ts => mocks/TestOrganisationsMock.ts} (93%) create mode 100644 src/mocks/UsersMock.ts create mode 100644 src/pages/Home/HeroSection.tsx create mode 100644 src/pages/Home/Home.tsx create mode 100644 src/pages/Home/SupportSection.tsx create mode 100644 src/pages/Home/TogetherSection.tsx create mode 100644 src/pages/Home/index.ts rename src/{features/home => pages/Home}/styles.ts (100%) create mode 100644 src/pages/Login/EmailCredential.tsx create mode 100644 src/pages/Login/ForgotPassword.tsx create mode 100644 src/pages/Login/GoogleSignInButton.tsx create mode 100644 src/pages/Login/Login.tsx rename src/{features/login/components/login-design.tsx => pages/Login/LoginDesign.tsx} (100%) rename src/{features/login/components/login-form.tsx => pages/Login/LoginForm.tsx} (90%) create mode 100644 src/pages/Login/LoginMenuMessage.tsx rename src/{features/registration/components/registration-section.tsx => pages/Login/LoginSection.tsx} (50%) create mode 100644 src/pages/Login/SignInButton.tsx rename src/{features/login/components/sign-up.tsx => pages/Login/SignUp.tsx} (94%) create mode 100644 src/pages/Login/index.ts rename src/{features/login/scss/login.scss => pages/Login/style.scss} (98%) rename src/{features/organisation-list/components => pages/OrganisationList}/CardView.tsx (83%) rename src/{features/organisation-list/const.ts => pages/OrganisationList/Const.ts} (87%) rename src/{features/organisation-list/components => pages/OrganisationList}/ListView.tsx (74%) rename src/{features/organisation-list/components/navigation-bar.tsx => pages/OrganisationList/NavigationBar.tsx} (100%) rename src/{features/organisation-list/components/OrgCard.tsx => pages/OrganisationList/OrganisationCard.tsx} (93%) rename src/{features/organisation-list/index.tsx => pages/OrganisationList/OrganisationList.tsx} (76%) create mode 100644 src/pages/OrganisationList/ViewToggle.tsx create mode 100644 src/pages/OrganisationList/index.ts rename src/{features/organisation-profile/index.tsx => pages/OrganisationProfile/OrganisationProfile.tsx} (51%) rename src/{features/organisation-profile/components/profile.tsx => pages/OrganisationProfile/Profile.tsx} (87%) rename src/{features/organisation-profile/components/profile-content.tsx => pages/OrganisationProfile/ProfileContent.tsx} (98%) rename src/{features/organisation-profile/components/profile-sidebar.tsx => pages/OrganisationProfile/ProfileSidebar.tsx} (100%) rename src/{features/organisation-profile/components/services.tsx => pages/OrganisationProfile/Services.tsx} (84%) rename src/{features/organisation-profile/components/similar-orgs.tsx => pages/OrganisationProfile/SimilarOrganisations.tsx} (77%) create mode 100644 src/pages/OrganisationProfile/Summary.tsx create mode 100644 src/pages/OrganisationProfile/index.ts rename src/{features/organisation-profile/scss => pages/OrganisationProfile}/profile.scss (98%) rename src/{features/organisation-profile/scss => pages/OrganisationProfile}/services.scss (91%) rename src/{features/organisation-profile/scss => pages/OrganisationProfile}/similar-orgs.scss (100%) rename src/{features/organisation-profile/scss => pages/OrganisationProfile}/summary.scss (100%) rename src/{features/registration/components/goals-form.tsx => pages/Registration/GoalsForm.tsx} (93%) rename src/{features/registration/components/org-info-form.tsx => pages/Registration/OrganisationInfoForm.tsx} (95%) rename src/{features/registration/profile-setup-page.tsx => pages/Registration/ProfileSetup.tsx} (91%) rename src/{features/registration/registration-page.tsx => pages/Registration/Registration.tsx} (55%) rename src/{features/registration/components/registration-design.tsx => pages/Registration/RegistrationDesign.tsx} (80%) rename src/{features/registration/components/registration-form.tsx => pages/Registration/RegistrationForm.tsx} (92%) rename src/{features/registration/components/registration-menu-message.tsx => pages/Registration/RegistrationMenuMessage.tsx} (83%) create mode 100644 src/pages/Registration/RegistrationSection.tsx rename src/{features/registration/components/sign-in.tsx => pages/Registration/SignIn.tsx} (84%) rename src/{features/registration/components/sign-up-button.tsx => pages/Registration/SignUpButton.tsx} (60%) rename src/{features/registration/components/sign-up-waiting.tsx => pages/Registration/SignUpWaiting.tsx} (85%) create mode 100644 src/pages/Registration/index.ts rename src/{features/registration/scss => pages/Registration}/registration.scss (99%) rename src/{features/registration/scss => pages/Registration}/setup.scss (99%) rename src/{features/user-dashboard/user-dashboard-page.tsx => pages/UserDashboard/UserDashboard.tsx} (82%) create mode 100644 src/pages/UserDashboard/index.ts create mode 100644 src/pages/style.scss rename src/{paths.ts => routing/Paths.ts} (100%) create mode 100644 src/routing/Routing.tsx create mode 100644 src/routing/index.ts rename src/services/{http-common.ts => HttpCommon.ts} (100%) delete mode 100644 src/utilities/icon-mappings.tsx create mode 100644 src/utilities/iconMappings/iconMapping.tsx create mode 100644 src/utilities/iconMappings/index.ts create mode 100644 src/utilities/validators/index.ts rename src/utilities/{ => validators}/validators.ts (100%) diff --git a/src/App.tsx b/src/App.tsx index 9e50dad..f1ca607 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,39 +1,26 @@ -import { ChakraProvider } from "@chakra-ui/react"; -import { Route, Routes } from "react-router-dom"; -import Home from "./features/home"; -import LoginPage from "./features/login/login-page"; -import ProfileSetupPage from "./features/registration/profile-setup-page"; -import RegistrationPage from "./features/registration/registration-page"; -import OrgProfilePage from "./features/organisation-profile"; -import OrganisationList from "./features/organisation-list"; -import UserDashboardPage from "./features/user-dashboard/user-dashboard-page"; -import { AuthProvider } from "./services/firebase/authProvider"; -import FirestoreMock from "./features/firestore-mock/firestore-mock"; -import { Paths } from "./paths"; +import { ChakraProvider, Container } from "@chakra-ui/react"; +import { AuthProvider } from "./services/Firebase/AuthProvider"; import { appTheme } from "./theme"; +import Routing from "./routing"; +import { Paths } from "./routing/Paths"; +import Header from "./components/Header"; +import Footer from "./components/Footer"; function App() { + // Get current page + const currentPage = window.location.pathname; + + // Check the current page is not login and registration page + const isShowHeaderAndFooter = ![Paths.login, Paths.signup, Paths.profileSetup].includes( + currentPage + ); + return ( - - } /> - } /> - } /> - } /> - } /> - } - /> - } - /> - {process.env.NODE_ENV === "development" && ( - } /> - )} - + {isShowHeaderAndFooter &&
} + + {isShowHeaderAndFooter &&