Client web app for atila.ca, demo.atila.ca and staging.atila.ca
npm install; npm start
- We use the atila-web-components-library for some of our web components
- You can add your desired component using:
npm install @orgName/componentScopeName.componentID
npm config set '@atila:registry' https://node.bit.dev
npm i @atila/web-components-library.ui.crypto-payment-form
oryarn add @atila/web-components-library.ui.crypto-payment-form
Taken from PR #8
-
Go to
src/redux/reducers/data
and add a data item to a reducer in the respective.js
file -
If you are creating a new reducer you will also need to add the reducer to
index.js
insrc/redux/reducers/data
-
For adding actions:
-
Go to
src/redux/actions/<yourActionFile>.js
and add an action that will trigger that data item -
Then you can reference the redux state from
mapStateToProps()
andstate.data.user.loggedInUserProfile
-
If you are adding an action, you can do:
mapDispatchToProps()
npm test
To test a specific file: npm test FileName
for example: npm test Register
This client-web app is connected to multiple external APIs
Environment.apiUrl
: atila-django: main serverEnvironment.apiUrlNotion
: notion-api-worker: get Wiki content from Notion- etc.
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).
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.
- How to Mock API Data in atila-client-web-app
- How to Mock API Data in atila-client-web-app based on the request
- How to Mock API data for use in a Pull Request
Steps:
-
Set
ATILA_MOCK_API_CALLS
to true in local storage.- Right click in your browser > Inspect > Application.
-
Get the JSON response of the data you want to mock.
- This can usually be retrieved from staging.atila.ca and checking the network tap of the request using devtools.
- Right click > Inspect > Network and filter by the api URL.
- Use jsonformatter.curiousconcept.com to add tab spacing to make your JSON files easier to read and so it's not one one line
- Make sure to use a 4 space tab
- Note: Make sure you don't use production data containing private information for your mock data:
- 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
-
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 intosrc/services/mocks/Scholarship/ScholarshipsPreview1.json
you might have to make a new directory if the object name you want to use doesn't exist. -
Go to
MockAPI.initializeMocks()
insrc/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.
-
We use Storybook to develop components independently from business logic, see Adding Storybook to our Web App Development Process
-
To run Storybook:
- You only have to do this the first time you run Storybook: delete
node_modules
andpackage-lock.json
NOTpackage.json
then runnpm install
npm run storybook
- If that command fails with:
Error: EEXIST: file already exists, mkdir '/Users/admin/Desktop/tomiwa/codeproj/atila-code/atila-client-web-app/node_modules/.cache/ts-docgen'
- Try running
npm run storybook:clear-cache
- You can run your react server alongside storybook: Open a seperate terminal window and run
npm start
- You only have to do this the first time you run Storybook: delete
-
To add a new component to Storybook: create it in
src/stories/{ComponentName}.stories.js
-
Follow the example in
src/stories/ContentCard.stories.js
and create a seperate story for each scenario of that component -
NOTE: if there is an error in one of your components, instead of storybook crashing, the error is displayed in the console so make sure to inpect console to see the error
-
Learn more here:
This project deploys to 3 environments using Netlify
-
master
deploys to atila.ca -
demo
deploys to demo.atila.ca -
All other branches that are not
master
ordemo
deploy to staging.atila.ca -
To push to
demo
branch and trigger a deploy todemo.atla.ca
from CI run:git push origin <local_branch_name>:demo
-
The environment variables for these domains are in circleci: https://app.circleci.com/settings/project/github/ademidun/atila-client-web-app/environment-variables
- If you get compiler errors in your IDE, try setting your Typescript version: