ademidun / atila-client-web-app

Client web app for atila.ca
https://atila.ca
0 stars 0 forks source link

Atila Client Web App

Client web app for atila.ca, demo.atila.ca and staging.atila.ca

1345d9f0-5ded-40ea-b4a1-acb12fe2893a

CircleCI

prod: Netlify Status

staging: Netlify Status

Prerequisites

Getting Started

npm install; npm start

Open in Gitpod

Open in Gitpod

Adding a Bit Component

Steps for Adding a new Item to Redux

Taken from PR #8

Testing

npm test

To test a specific file: npm test FileName for example: npm test Register

External APIs

This client-web app is connected to multiple external APIs

In order to use these APIs you can either follow the instructions in the linked repos to start the service, use staging APIs instead of localhost (make sure to uncomment before pushing to avoid failed tests in CI) or mock API data (see next section).

Mock API Data

If you can't or don't want to use the actual backend API you can mock the responses.

Here are two video tutorials we made specifically on how to Mock API Data in this project.

  1. How to Mock API Data in atila-client-web-app
  2. How to Mock API Data in atila-client-web-app based on the request
  3. How to Mock API data for use in a Pull Request

Steps:

  1. Set ATILA_MOCK_API_CALLS to true in local storage.

    1. Right click in your browser > Inspect > Application.
  2. Get the JSON response of the data you want to mock.

    1. This can usually be retrieved from staging.atila.ca and checking the network tap of the request using devtools.
    2. Right click > Inspect > Network and filter by the api URL.
    3. Use jsonformatter.curiousconcept.com to add tab spacing to make your JSON files easier to read and so it's not one one line
      1. Make sure to use a 4 space tab
    4. Note: Make sure you don't use production data containing private information for your mock data:
      1. For example, if you want to mock a list of applications or a user profile, ask someone else on the team to send your some mock data on their local dev environment and provide them with the url you are trying to mock
  3. Copy that JSON response and put it into src/services/mocks/{Object_name}/{File_name}.json for example if you wanted to make a scholarship list response you would put it into src/services/mocks/Scholarship/ScholarshipsPreview1.json you might have to make a new directory if the object name you want to use doesn't exist.

  4. Go to MockAPI.initializeMocks() in src/services/mocks/MockAPI.js to add the instructions for how to mock your new data.

We use axios-mock-adapter for our API mocking, see their documentation for how to do more advanced mocking such as returning a certain response based on the request parameters.

Note: You can only mock api calls in the dev environment.

Storybook

How to Create a Pull Request

Deployment

This project deploys to 3 environments using Netlify

Troubleshooting