Skip to content

Commit 0d3dfb9

Browse files
authored
Merge pull request #2 from toggle-corp/feat/capacity-and-resources
Feat/capacity and resources
2 parents fabf6e1 + 3091dbd commit 0d3dfb9

167 files changed

Lines changed: 18351 additions & 1155 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# dotenv environment variables file
2+
.env
3+
.env*
4+
**/.env
5+
**/.env*
6+
7+
# Sensitive Deploy Files
8+
deploy/eb/
9+
10+
# tox
11+
./.tox
12+
13+
14+
# Backend
15+
backend
16+
!backend/schema.graphql

.github/pull_request_template.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
- Addresses XXX
2+
- Depends on XXX
3+
4+
## Changes
5+
6+
- Detailed list or prose of changes
7+
- Breaking changes
8+
- Changes to configurations
9+
10+
## This PR doesn't introduce any
11+
12+
- [ ] temporary files, auto-generated files or secret keys
13+
- [ ] build works
14+
- [ ] eslint issues
15+
- [ ] typescript issues
16+
- [ ] codegen errors
17+
- [ ] `console.log` meant for debugging
18+
- [ ] typos
19+
- [ ] unwanted comments
20+
- [ ] conflict markers
21+
22+
## This PR includes
23+
24+
- [ ] Translation
25+
- [ ] Permission

.github/workflows/ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- "main"
8+
9+
env:
10+
APP_GRAPHQL_CODEGEN_ENDPOINT: "./backend/schema.graphql"
11+
APP_GRAPHQL_ENDPOINT: "http://web:8000/graphql/"
12+
APP_TITLE: "ERCS"
13+
APP_ENVIRONMENT: "development"
14+
GITHUB_WORKFLOW: true
15+
16+
jobs:
17+
lint:
18+
name: Lint
19+
runs-on: ubuntu-latest
20+
env:
21+
PIPELINE_TYPE: ci
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
submodules: recursive
26+
- name: Install pnpm
27+
run: npm install -g pnpm
28+
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: "22.x"
32+
cache: "pnpm"
33+
34+
- name: Install dependencies
35+
run: pnpm install --frozen-lockfile
36+
37+
- name: Lint
38+
run: pnpm lint
39+
build:
40+
name: Build
41+
needs: [lint]
42+
runs-on: ubuntu-latest
43+
env:
44+
PIPELINE_TYPE: ci
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
submodules: recursive
49+
50+
- uses: pnpm/action-setup@v4
51+
name: Install pnpm
52+
53+
- name: Install Node.js
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: "22.x"
57+
cache: "pnpm"
58+
59+
- name: Install dependencies
60+
run: pnpm install --frozen-lockfile
61+
62+
- name: Generate Type
63+
run: pnpm generate:type
64+
65+
- name: Build
66+
run: pnpm build
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish web app serve
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- develop
8+
9+
permissions:
10+
packages: write
11+
12+
jobs:
13+
publish_image:
14+
name: Publish Docker Image
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
submodules: true
20+
21+
- name: Publish web-app-serve
22+
uses: toggle-corp/web-app-serve-action@v0.1.1
23+
with:
24+
github_token: ${{ secrets.GITHUB_TOKEN }}

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
[submodule "backend"]
22
path = backend
33
url = https://github.com/toggle-corp/ercs-backend.git
4+
[submodule "go-risk-module-api"]
5+
path = go-risk-module-api
6+
url = git@github.com:IFRCGo/go-risk-module-api.git
7+
[submodule "go-api"]
8+
path = go-api
9+
url = https://github.com/IFRCGo/go-api.git

Dockerfile

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
FROM node:22-bookworm AS dev
22

33
RUN apt-get update -y \
4-
&& apt-get install -y --no-install-recommends \
5-
git bash g++ make \
6-
&& rm -rf /var/lib/apt/lists/*
7-
8-
RUN corepack enable
4+
&& apt-get install -y --no-install-recommends git \
5+
&& rm -rf /var/lib/apt/lists/* \
6+
# NOTE: yarn > 1.22.19 breaks yarn-install invoked by pnpm
7+
&& npm install -g pnpm@10.33.0 yarn@1.22.19 --force \
8+
&& git config --global --add safe.directory /code
99

1010
WORKDIR /code
11-
RUN git config --global --add safe.directory /code
12-
13-
COPY package.json pnpm-lock.yaml /code/
14-
RUN corepack prepare pnpm@latest --activate
1511

1612
# -------------------------- Nginx - Builder --------------------------------
17-
FROM dev AS nginx-build
13+
FROM dev AS web-app-serve-build
14+
15+
COPY ./package.json ./pnpm-lock.yaml /code/
1816

19-
RUN pnpm install --frozen-lockfile
17+
RUN pnpm install
2018

21-
COPY . .
19+
COPY . /code/
2220

23-
ENV APP_TITLE=APP_TITLE_PLACEHOLDER
24-
ENV APP_GRAPHQL_ENDPOINT=APP_GRAPHQL_ENDPOINT_PLACEHOLDER
21+
# # Build variables (Requires backend pulled)
22+
ENV APP_TITLE=ercs-eoc
23+
ENV APP_ENVIRONMENT=development
24+
ENV APP_GRAPHQL_ENDPOINT=http://localhost:8000
2525
ENV APP_GRAPHQL_CODEGEN_ENDPOINT=./backend/schema.graphql
26+
ENV APP_MAPBOX_TOKEN=APP_MAPBOX_TOKEN_PLACEHOLDER
27+
ENV APP_GO_API=WEB_APP_SERVE_PLACEHOLDER__APP_GO_API_PLACEHOLDER
28+
ENV APP_GO_URL=WEB_APP_SERVE_PLACEHOLDER__APP_GO_URL_PLACEHOLDER
29+
ENV APP_GO_RISK_API_ENDPOINT=WEB_APP_SERVE_PLACEHOLDER__APP_GO_RISK_API_ENDPOINT_PLACEHOLDER
2630

27-
RUN pnpm generate:type && pnpm build
31+
32+
RUN pnpm generate:type && WEB_APP_SERVE_ENABLED=true pnpm build
2833

2934
# ---------------------------------------------------------------------------
30-
FROM nginx:1 AS nginx-serve
35+
FROM ghcr.io/toggle-corp/web-app-serve:v0.1.2 AS web-app-serve
3136

3237
LABEL maintainer="Togglecorp Dev"
3338
LABEL org.opencontainers.image.source="https://github.com/ToogleCorp/ercs-client"
3439

35-
COPY ./nginx-serve/apply-config.sh /docker-entrypoint.d/
36-
COPY ./nginx-serve/nginx.conf.template /etc/nginx/templates/default.conf.template
37-
COPY --from=nginx-build /code/build /code/build
38-
40+
# Env for apply-config script
3941
ENV APPLY_CONFIG__SOURCE_DIRECTORY=/code/build/
40-
ENV APPLY_CONFIG__DESTINATION_DIRECTORY=/usr/share/nginx/html/
41-
ENV APPLY_CONFIG__OVERWRITE_DESTINATION=true
42+
43+
COPY --from=web-app-serve-build /code/build "$APPLY_CONFIG__SOURCE_DIRECTORY"

app/App.css

Whitespace-only changes.

app/App.tsx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,88 @@
11
import {
22
createBrowserRouter,
3-
RouterProvider
4-
} from "react-router"
3+
type RouteObject,
4+
RouterProvider,
5+
} from 'react-router';
6+
import mapboxgl from 'mapbox-gl';
57

6-
import type { RouteConfig } from "#root/config/routes.ts";
7-
import routes from "#root/config/routes.ts";
8-
import PageError from "#views/PageError/index.tsx";
8+
import { mapboxToken } from '#config';
9+
import type { RouteConfig } from '#root/config/routes.ts';
10+
import routes from '#root/config/routes.ts';
11+
import PageError from '#views/PageError/index.tsx';
912

1013
const privateRoutes = Object.values(routes).filter(
11-
({ visibility }) => visibility === "is-authenticated",
14+
({ visibility }) => visibility === 'is-authenticated',
1215
);
1316

1417
const publicRoutes = Object.values(routes).filter(
15-
({ visibility }) => visibility === "is-anything",
18+
({ visibility }) => visibility === 'is-anything',
1619
);
1720

1821
const guestRoutes = Object.values(routes).filter(
19-
({ visibility }) => visibility === "is-not-authenticated",
22+
({ visibility }) => visibility === 'is-not-authenticated',
2023
);
2124

22-
function mapRoute(routeConfig: RouteConfig) {
25+
function mapRoute(routeConfig: RouteConfig): RouteObject {
26+
// Only truly index routes: no path, index: true
27+
if (routeConfig.index && !routeConfig.path) {
28+
return {
29+
index: true,
30+
lazy: async () => {
31+
const { default: Component } = await routeConfig.load();
32+
return { Component };
33+
},
34+
};
35+
}
36+
2337
return {
24-
index: routeConfig.index,
2538
path: routeConfig.path,
2639
lazy: async () => {
2740
const { default: Component } = await routeConfig.load();
2841
return { Component };
2942
},
43+
children: routeConfig.children?.map(mapRoute),
3044
};
3145
}
3246

47+
mapboxgl.accessToken = mapboxToken ?? '';
48+
mapboxgl.setRTLTextPlugin(
49+
'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js',
50+
// eslint-disable-next-line no-console
51+
(err) => { console.error(err); },
52+
true,
53+
);
54+
3355
const router = createBrowserRouter([
3456
{
3557
errorElement: <PageError />,
3658
lazy: async () => {
37-
const { default: Component } = await import("./Root/index.tsx");
59+
const { default: Component } = await import('./Root/index.tsx');
3860
return { Component };
3961
},
4062
children: [
4163
{
4264
lazy: async () => {
43-
const { default: Component } =
44-
await import("./views/RootLayout/index.tsx");
65+
const { default: Component } = await import('./views/RootLayout/index.tsx');
4566
return { Component };
4667
},
4768
children: [
4869
{
4970
lazy: async () => {
50-
const { default: Component } =
51-
await import("./views/GuestLayout/index.tsx");
71+
const { default: Component } = await import('./views/GuestLayout/index.tsx');
5272
return { Component };
5373
},
5474
children: guestRoutes.map(mapRoute),
5575
},
5676
{
5777
lazy: async () => {
58-
const { default: Component } =
59-
await import("./views/PrivateLayout/index.tsx");
78+
const { default: Component } = await import('./views/PrivateLayout/index.tsx');
6079
return { Component };
6180
},
6281
children: privateRoutes.map(mapRoute),
6382
},
6483
{
6584
lazy: async () => {
66-
const { default: Component } =
67-
await import("./views/PublicLayout/index.tsx");
85+
const { default: Component } = await import('./views/PublicLayout/index.tsx');
6886
return { Component };
6987
},
7088
children: publicRoutes.map(mapRoute),

0 commit comments

Comments
 (0)