Skip to content

Commit 88b96cb

Browse files
authored
appointment option in time filter, infer country when state is us/canada (code4recovery#443)
* add appointment filter to time dropdown, imfer usa when state is in usa * include canada * update comment * remove test file for district 80 * bump dependencies * fix tests * bump node version in github action * bump github action versions
1 parent 8456b3f commit 88b96cb

File tree

12 files changed

+205
-58
lines changed

12 files changed

+205
-58
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@v2
14+
uses: actions/checkout@v4
1515

1616
- name: Setup Node
17-
uses: actions/setup-node@v2
17+
uses: actions/setup-node@v4
1818
with:
19-
node-version: '16'
19+
node-version: '22'
2020
cache: 'npm'
2121
- run: npm install
2222
- run: npm run test-coverage

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface TSMLReactConfig {
4747
strings: {
4848
[lang in Lang]: Translation;
4949
};
50-
times: Array<'morning' | 'midday' | 'evening' | 'night'>;
50+
times: Array<'morning' | 'midday' | 'evening' | 'night' | 'appointment'>;
5151
weekdays: string[];
5252
}
5353

jest.setup.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import '@testing-library/jest-dom/extend-expect';
22
import React from 'react';
3+
import { TextEncoder, TextDecoder } from 'node:util';
4+
5+
if (!global.TextEncoder) {
6+
global.TextEncoder = TextEncoder;
7+
}
8+
9+
if (!global.TextDecoder) {
10+
global.TextDecoder = TextDecoder;
11+
}
312

413
global.React = React;
514

package-lock.json

Lines changed: 48 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"react-dom": "^18.2.0",
5050
"react-infinite-scroller": "^1.2.6",
5151
"react-map-gl": "^7.1.7",
52-
"react-router-dom": "^6.18.0",
52+
"react-router-dom": "^7.5.2",
5353
"viewport-mercator-project": "^7.0.4"
5454
},
5555
"babel": {

public/app.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/app.js.LICENSE.txt

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,7 @@
4141
*/
4242

4343
/**
44-
* @remix-run/router v1.14.2
45-
*
46-
* Copyright (c) Remix Software Inc.
47-
*
48-
* This source code is licensed under the MIT license found in the
49-
* LICENSE.md file in the root directory of this source tree.
50-
*
51-
* @license MIT
52-
*/
53-
54-
/**
55-
* React Router DOM v6.21.3
56-
*
57-
* Copyright (c) Remix Software Inc.
58-
*
59-
* This source code is licensed under the MIT license found in the
60-
* LICENSE.md file in the root directory of this source tree.
61-
*
62-
* @license MIT
63-
*/
64-
65-
/**
66-
* React Router v6.21.3
44+
* react-router v7.5.3
6745
*
6846
* Copyright (c) Remix Software Inc.
6947
*

public/tests/river-cities.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta
6+
name="viewport"
7+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
8+
/>
9+
<meta name="description" content="React JS recovery meeting finder demo" />
10+
<link rel="icon" type="image/png" href="/logo.png" />
11+
<title>Meetings</title>
12+
<style type="text/css">
13+
body {
14+
margin: 0;
15+
}
16+
#tsml-ui {
17+
min-height: 100vh;
18+
min-height: -webkit-fill-available;
19+
}
20+
</style>
21+
</head>
22+
<body>
23+
<div
24+
id="tsml-ui"
25+
data-src="https://docs.google.com/spreadsheets/d/1lqDzi6bS8zJoWe2WuHNh4V-8nkn205ufgtRgvX9niiA/edit?gid=1811591486#gid=1811591486"
26+
data-mapbox="pk.eyJ1Ijoiam9zaHJlaXNuZXIiLCJhIjoiY2tvYXA0YnZxMGRldDJxbzdta25uNGphdiJ9.eay-UKgIT99ALmdw08xBPw"
27+
data-google="AIzaSyCS9M8Dqk5cMFqA7xvUrQEzT1u5IvcbT7c"
28+
></div>
29+
<script src="/app.js" async></script>
30+
</body>
31+
</html>

src/helpers/load-meeting-data.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { formatAddress } from './format-address';
55
import { formatConferenceProvider } from './format-conference-provider';
66
import { formatFeedbackEmail } from './format-feedback-email';
77
import { formatSlug } from './format-slug';
8+
import { states } from './states';
89

910
import type { JSONData, JSONDataFlat, State, Meeting, Index } from '../types';
1011

@@ -100,6 +101,15 @@ export function loadMeetingData(
100101

101102
// creates formatted_address if necessary
102103
if (!formatted_address) {
104+
// infer country if state is in Canada or USA
105+
if (!meeting.country && meeting.state) {
106+
if (states.canada.includes(meeting.state)) {
107+
meeting.country = 'Canada';
108+
} else if (states.usa.includes(meeting.state)) {
109+
meeting.country = 'USA';
110+
}
111+
}
112+
103113
formatted_address = [
104114
meeting.address,
105115
meeting.city,
@@ -321,6 +331,19 @@ export function loadMeetingData(
321331
}
322332
});
323333
}
334+
} else {
335+
const timeIndex = indexes.time.findIndex(
336+
({ key }) => key === 'appointment'
337+
);
338+
if (timeIndex === -1) {
339+
indexes.time.push({
340+
key: 'appointment',
341+
name: strings.appointment,
342+
slugs: [slug],
343+
});
344+
} else {
345+
indexes.time[timeIndex].slugs.push(slug);
346+
}
324347
}
325348

326349
// parse regions

src/helpers/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const defaults: TSMLReactConfig = {
9191
sk,
9292
sv,
9393
},
94-
times: ['morning', 'midday', 'evening', 'night'],
94+
times: ['morning', 'midday', 'evening', 'night', 'appointment'],
9595
weekdays: [
9696
'sunday',
9797
'monday',

0 commit comments

Comments
 (0)