Skip to content

Commit a2f00a9

Browse files
authored
Merge pull request #1814 from IFRCGo/feature/backend-submodule
Add submodules for go-api and risk-api
2 parents 4c3af83 + 9f70e2e commit a2f00a9

File tree

19 files changed

+77
-57
lines changed

19 files changed

+77
-57
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -230,24 +230,37 @@ jobs:
230230
- name: Lint CSS
231231
run: pnpm lint:css
232232

233-
# FIXME: Identify a way to generate schema before we run typecheck
234-
# typecheck:
235-
# name: Typecheck
236-
# runs-on: ubuntu-latest
237-
# steps:
238-
# - uses: actions/checkout@v4
239-
# - name: Install pnpm
240-
# uses: pnpm/action-setup@v4
241-
# - name: Install Node.js
242-
# uses: actions/setup-node@v4
243-
# with:
244-
# node-version: 20
245-
# cache: 'pnpm'
246-
# - name: Install dependencies
247-
# run: pnpm install
248-
#
249-
# - name: Typecheck
250-
# run: pnpm typecheck
233+
typecheck:
234+
name: Typecheck
235+
runs-on: ubuntu-latest
236+
defaults:
237+
run:
238+
working-directory: app
239+
needs: [ui]
240+
steps:
241+
- uses: actions/checkout@v4
242+
with:
243+
submodules: true
244+
- name: Install pnpm
245+
uses: pnpm/action-setup@v4
246+
- name: Install Node.js
247+
uses: actions/setup-node@v4
248+
with:
249+
node-version: 20
250+
cache: 'pnpm'
251+
- name: Install dependencies
252+
run: pnpm install
253+
254+
- uses: actions/download-artifact@v4
255+
with:
256+
name: ui-build
257+
path: packages/ui/dist
258+
259+
- name: Generate types
260+
run: pnpm generate:type
261+
262+
- name: Typecheck
263+
run: pnpm typecheck
251264

252265
typos:
253266
name: Spell Check with Typos

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "go-api"]
2+
path = go-api
3+
url = [email protected]:IFRCGo/go-api.git
4+
[submodule "go-risk-module-api"]
5+
path = go-risk-module-api
6+
url = [email protected]:IFRCGo/go-risk-module-api.git

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@ To begin, ensure you have network access. Then, you'll need the following:
4141
gh repo clone IFRCGo/go-web-app # GitHub CLI
4242
```
4343

44-
2. Install the dependencies:
44+
2. Initialize submodules
45+
46+
```bash
47+
git submodule update --init --recursive --remote
48+
```
49+
50+
3. Install the dependencies:
4551

4652
```bash
4753
pnpm install
4854
```
4955

50-
3. Create a `.env` file in the `app` directory and add variables from [env.ts](https://github.com/IFRCGo/go-web-app/blob/develop/app/env.ts). Any variables marked with `.optional()` are not mandatory for setup and can be skipped.
56+
4. Create a `.env` file in the `app` directory and add variables from [env.ts](https://github.com/IFRCGo/go-web-app/blob/develop/app/env.ts). Any variables marked with `.optional()` are not mandatory for setup and can be skipped.
5157
5258
```bash
5359
cd app
@@ -61,10 +67,10 @@ To begin, ensure you have network access. Then, you'll need the following:
6167
...
6268
```
6369

64-
4. Start the development server:
70+
5. Start the development server:
6571

6672
```bash
67-
pnpm start:app
73+
pnpm start
6874
```
6975

7076
## Contributing

app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"initialize:type:go-api": "test -f ./generated/types.ts && true || cp types.stub.ts ./generated/types.ts",
1818
"initialize:type:risk-api": "test -f ./generated/riskTypes.ts && true || cp types.stub.ts ./generated/riskTypes.ts",
1919
"generate:type": "pnpm generate:type:go-api && pnpm generate:type:risk-api",
20-
"generate:type:go-api": "dotenv -- cross-var openapi-typescript \"%APP_API_ENDPOINT%api-docs/\" -o ./generated/types.ts --alphabetize",
21-
"generate:type:risk-api": "dotenv -- cross-var openapi-typescript \"%APP_RISK_API_ENDPOINT%api-docs/\" -o ./generated/riskTypes.ts --alphabetize",
20+
"generate:type:go-api": "GO_API_HASH=$(git rev-parse HEAD:go-api); dotenv -- cross-var openapi-typescript https://raw.githubusercontent.com/IFRCGo/go-api-artifacts/refs/heads/main/generated/$GO_API_HASH/openapi-schema.yaml -o ./generated/types.ts --alphabetize",
21+
"generate:type:risk-api": "dotenv -- cross-var openapi-typescript ../go-risk-module-api/openapi-schema.yaml -o ./generated/riskTypes.ts --alphabetize",
2222
"prestart": "pnpm initialize:type",
2323
"start": "pnpm -F @ifrc-go/ui build && vite",
2424
"prebuild": "pnpm initialize:type",

app/src/components/domain/RiskImminentEventMap/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ const mapImageOption = {
6666
sdf: true,
6767
};
6868

69-
type HazardType = components<'read'>['schemas']['HazardTypeEnum'];
69+
type CommonHazardType = components<'read'>['schemas']['CommonHazardTypeEnumKey'];
7070

71-
const hazardKeys = Object.keys(hazardKeyToIconMap) as HazardType[];
71+
const hazardKeys = Object.keys(hazardKeyToIconMap) as CommonHazardType[];
7272

7373
const mapIcons = mapToList(
7474
hazardKeyToIconMap,
@@ -77,7 +77,7 @@ const mapIcons = mapToList(
7777

7878
type EventPointProperties = {
7979
id: string | number,
80-
hazard_type: HazardType,
80+
hazard_type: CommonHazardType,
8181
}
8282

8383
export type EventPointFeature = GeoJSON.Feature<GeoJSON.Point, EventPointProperties>;
@@ -108,7 +108,7 @@ interface Props<EVENT, EXPOSURE, KEY extends string | number> {
108108
source: ImminentEventSource;
109109
events: EVENT[] | undefined;
110110
keySelector: (event: EVENT) => KEY;
111-
hazardTypeSelector: (event: EVENT) => HazardType | '' | undefined;
111+
hazardTypeSelector: (event: EVENT) => CommonHazardType | '' | undefined;
112112
pointFeatureSelector: (event: EVENT) => EventPointFeature | undefined;
113113
footprintSelector: (activeEventExposure: EXPOSURE | undefined) => Footprint | undefined;
114114
activeEventExposure: EXPOSURE | undefined;
@@ -306,7 +306,7 @@ function RiskImminentEventMap<
306306
const [loadedIcons, setLoadedIcons] = useState<Record<string, boolean>>({});
307307

308308
const handleIconLoad = useCallback(
309-
(loaded: boolean, key: HazardType) => {
309+
(loaded: boolean, key: CommonHazardType) => {
310310
setLoadedIcons((prevValue) => ({
311311
...prevValue,
312312
[key]: loaded,

app/src/components/domain/RiskImminentEventMap/mapStyles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ import {
3333
type RiskLayerTypes,
3434
} from './utils';
3535

36-
type HazardType = components<'read'>['schemas']['HazardTypeEnum'];
36+
type CommonHazardType = components<'read'>['schemas']['CommonHazardTypeEnumKey'];
3737

38-
export const hazardKeyToIconMap: Record<HazardType, string | null> = {
38+
export const hazardKeyToIconMap: Record<CommonHazardType, string | null> = {
3939
EQ: earthquakeIcon,
4040
FL: floodIcon,
4141
TC: cycloneIcon,

app/src/components/domain/RiskImminentEvents/Gdacs/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,6 @@ function Gdacs(props: Props) {
192192
isNotDefined(latitude)
193193
|| isNotDefined(longitude)
194194
|| isNotDefined(hazard_type)
195-
// FIXME: hazard_type should not be ''
196-
|| hazard_type === ''
197195
) {
198196
return undefined;
199197
}

app/src/components/domain/RiskImminentEvents/MeteoSwiss/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ function MeteoSwiss(props: Props) {
128128
isNotDefined(latitude)
129129
|| isNotDefined(longitude)
130130
|| isNotDefined(hazard_type)
131-
// FIXME: hazard_type should not be ''
132-
|| hazard_type === ''
133131
) {
134132
return undefined;
135133
}

app/src/components/domain/RiskImminentEvents/Pdc/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ function Pdc(props: Props) {
9999
isNotDefined(latitude)
100100
|| isNotDefined(longitude)
101101
|| isNotDefined(hazard_type)
102-
// FIXME: hazard_type should not be ''
103-
|| hazard_type === ''
104102
) {
105103
return undefined;
106104
}
@@ -138,8 +136,8 @@ function Pdc(props: Props) {
138136
} = exposure;
139137

140138
// FIXME: showing five days cou when three days cou is not available
141-
const cyclone_cou = (cyclone_three_days_cou as unknown[] | null)?.[0]
142-
?? (cyclone_five_days_cou as unknown[])?.[0];
139+
const cyclone_cou = (cyclone_three_days_cou as unknown as object[] | null)?.[0]
140+
?? (cyclone_five_days_cou as unknown as object[] | null)?.[0];
143141

144142
if (isNotDefined(footprint_geojson) && isNotDefined(storm_position_geojson)) {
145143
return undefined;

app/src/components/domain/RiskImminentEvents/WfpAdam/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ function WfpAdam(props: Props) {
146146
isNotDefined(latitude)
147147
|| isNotDefined(longitude)
148148
|| isNotDefined(hazard_type)
149-
// FIXME: hazard_type should not be ''
150-
|| hazard_type === ''
151149
) {
152150
return undefined;
153151
}

0 commit comments

Comments
 (0)