Before you begin, make sure you have Node.js version 18.16.1 installed (other versions might work, but was not tested).
You can use nvm
(Node Version Manager) to easily switch to this version if you have it installed. If not, you can install it with the following command:
nvm install 18.16.1
To get started with local development, you need to set up your environment variables.
-
Copy the
.env.example
file and rename it to.env.local
using the following command:cp .env.example .env.local
-
By default, this frontend application uses the Test environment endpoints. To switch to the Acceptance environment, simply open the
.env.local
file and replace all instances oftest
withacc
. -
If you also want to run the AngularJS application locally, modify the
NEXT_PUBLIC_LEGACY_APP_URL
variable in the.env.local
file tohttp://localhost:9999
. You can then start the AngularJS application separately.
Install project dependencies using Yarn:
yarn install
You can now start the Next.js application with the following command:
yarn dev
Once the application is running, open your web browser and navigate to http://localhost:3000/app to access the login page.
After logging in, you will be redirected to the deployed frontend (e.g., https://balie-test.uitpas.be/app). Please note that browsers don't include cookies between different hosts by default, so you'll need to make a manual change to the cookies in your browser's DevTools:
- Open your browser's DevTools (Pressing ⌥⌘ + i on a Mac).
- Go to the "Application" tab.
- Under the "Cookies" section in the left sidebar, select the domain.
- Edit the "PHPSESSID" cookie: Check "Secure," and set "SameSite" to "None"
- Return to http://localhost:3000/app, and you should now be logged in.
This project is based on Next.js v14, utilizing the app router. It also employs the following libraries:
- Joy UI (MUI) for UI components.
- Orval to generate React Query + Axios hooks for data fetching.
- FontAwesome (v6) icons.
The project is designed for a gradual migration from the AngularJS application to this Next.js application. Whenever a route is available in the Next.js app, it is used; otherwise, an iframe with the AngularJS application is rendered.
Communication between the Next.js and AngularJS apps is facilitated through EventListeners on the Window object.
The logic for this is encapsulated in src/feature-legacy
.
Once the migration is complete, the feature-legacy
can be safely removed along with any associated references.
For text translation, next-i18next
is used. You can find the translations in the src/shared/lib/i18n/locales/nl/common.json
file.
All variables specified in the .env(.local)
file should also be passed to publicRuntimeConfig
in src/shared/feature-config/getConfig.ts
, but only if they need to be available client-side.
Use the useConfig
hook to get the environment variables.