massenergize / massenergize-campaigns

MassEnergize Campaigns
MIT License
1 stars 1 forks source link

This is the MassEnergize Campaigns Web Frontend

A React application project bootstrapped with create-next-app.

To get started (Development setup)

  1. Clone the repository here

  2. Install the dependencies by running the following command

npm install
  1. Run the development server by running the following command
npm run start

or

yarn start
  1. Open http://localhost:3000 with your browser to see the result.

Project Structure

The project structure is as follows:

./
└── public
├── src
│   ├── api
│   ├── assets
│   ├── components
│   └── config
│   │   ├── i18n
│   │   └── routes
│   ├── guards
│   ├── helpers
│   ├── high-order-components
│   ├── hooks
│   ├── layout-components
│   ├── layouts
│   ├── lib
│   │   ├── bubbbly-balloon
│   │   ├── reduxoid
│   │   └── dicey-dialog
│   ├── mocks
|   ├── redux
│   ├── pages
│   ├── sections
│   ├── seo
│   ├── store
|   ├── user-portal
│   └──views
└── test

You can start editing the pages or add pages to the /src/pages/. Pages are automatically compiled and updated as you edit them.

Read more about the contents of the directories in contributing guide here to learn more about how to contribute to this project and the rules to follow.

Core Dependencies

The following are the core dependencies used in this project

GitHub Actions

We use GitHub Actions for pull request checks. Any pull request triggers checks such as linting, unit tests and E2E tests.

Testing 🧪

Jest ⚡️

For lower level tests of utilities and individual components, we use jest. We have DOM-specific assertion helpers via @testing-library/jest-dom.

There are 5 questions every unit test must answer and Eric Elliott created a testing framework called RITEway that forces you to write Readable, Isolated, and Explicit tests. The framework only exposes a single assert test function, which performs a deep equality check.

Linting

This project uses ESLint for linting. That is configured in .eslintrc with ignored files in .eslintignore. You can run the linter with yarn lint or npm run lint.

Formatting

We use Prettier for auto-formatting in this project. The Prettier config is in .prettierrc.

Deployment

This project is deployed on AWS Amplify. The build settings are configured in amplify.yml. The production tip deployment is done on every push to the main branch. The staging tip deployment is done on every push to the staging branch. Special feature deployments can be done by pushing to the feature/<feature-name> branch and setting the feature/<feature-name> branch as the deployment branch on AWS Amplify.

Sentry

We use Sentry for error tracking. The Sentry DSN is configured in the next.config.js file.

Google Analytics

We use Google Analytics for analytics. The Google Analytics ID is configured in the /src/config/firebase.js file.

Firebase

We use Firebase for authentication and push notifications. The firebase config is configured in the /src/config/firebase/ file. with initialization in the /src/helpers/firebase.js file.

Sirv

Let's be honest, using next/image is a pain. The opinions about forcing image widths and heights make it very annoying.

We therefore use Sirv for image optimization. Using Sirv, we can serve images with the correct content type and optimized for web. Images are automatically compressed and resized to fit the device screen size. The srcset attribute is automatically added to serve different images to different devices. To use sirv images, in as image tags in components, use the SirvImage component in the /src/components/SirvImage folder. The SirvImage component takes the following props:

<SirvImage src={imageSrc} alt={imageAlt}/>

The sirv base url is configured in the APP_PATHS object in /src/config/routes/index.js file. It can thus be used in other places in the app, programmatically to fetch images from sirv.

Next Image

Next Image is not completely abandoned. It is still used for some images that are not hosted on sirv, and also more importantly, if we can supply all the required props to the image component. To use next image, in as image tags in components, use the NextImage component in the /src/components/NextImage folder. It wraps the next image component and takes the following props:

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!