1.0.0 • Published 2 years ago

smweb-frontend v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

Introduction

Repository for the School Connect frontend codebase.

School Connect is an offline-first data-entry application for Schools taking part in WFP's School Connect pilot programme. For more detailed information, see this project's Azure DevOps wiki.

Getting Started

Requirements

Using a Node Version Manager to install Node.js and npm is strongly suggested.

Yarn is recommended over plain npm.

Setting up the development environment

Within the project root folder, execute these commands

  1. Install all dependencies and development dependencies according to package.json

    $ yarn install
  2. Configure .env.local file

    $ cp .env.local.example .env.local

If you are a fullstack developer and have the BE running on your machine, leave it as it is. If you are a FE developer, make REACT_APP_API_URL point to the dev or qa environment. In both cases, be sure to point it to the correct API version.

For more information on how .env.local works see CRA documentation.

  1. You will need to export the fontawesome token locally - please ask for the token or check the env variables on azure. Date set: 31:03:2022

    $ export FONTAWESOME_NPM_AUTH_TOKEN=***

  2. Start the FE server

    $ yarn start

This starts the FE server (defaults to port 3000) and opens your default browser to http://localhost:3000/

Account Creation

When starting the frontend for the first time it is required to create an account through CIAM. If you require a admin account add your email to the backend settings. This will automatically make your account a admin upon creation.

Building

Run yarn build

Testing (Jest)

Run yarn test

Testing (Cypress)

When using end to end testing make sure to uncomment the REACT_APP_E2E enviroment variable from the .env.local file

  1. In a terminal, run the backend

  2. In another terminal, run the frontend:

    $ yarn start
  3. In another terminal, run:

    $ yarn cypress open
  4. Within the Cypress GUI, click on "Run all specs".

Translating

We use React-Intl from formatjs.io/.

Its API is fine but the tooling is lackluster. For this reason, the translationcli.py script was written.

Translation workflow

  1. Run setup to install Translation dependency and pip

    $ yarn trans:setup
  2. extract .csv file and make translations using google_trans_new then merge file back into .json files usable by React Intl

    $ yarn trans:translate

Formatting

To comply with formatting checks performed in CI, run yarn pretty

Contribute

See this project's Azure DevOps wiki for detailed information about development workflows.