Skip to content

appointment option in time filter, infer country when state is us/canada #443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '22'
cache: 'npm'
- run: npm install
- run: npm run test-coverage
Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface TSMLReactConfig {
strings: {
[lang in Lang]: Translation;
};
times: Array<'morning' | 'midday' | 'evening' | 'night'>;
times: Array<'morning' | 'midday' | 'evening' | 'night' | 'appointment'>;
weekdays: string[];
}

Expand Down
9 changes: 9 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
import { TextEncoder, TextDecoder } from 'node:util';

if (!global.TextEncoder) {
global.TextEncoder = TextEncoder;
}

if (!global.TextDecoder) {
global.TextDecoder = TextDecoder;
}

global.React = React;

Expand Down
74 changes: 48 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"react-dom": "^18.2.0",
"react-infinite-scroller": "^1.2.6",
"react-map-gl": "^7.1.7",
"react-router-dom": "^6.18.0",
"react-router-dom": "^7.5.2",
"viewport-mercator-project": "^7.0.4"
},
"babel": {
Expand Down
4 changes: 2 additions & 2 deletions public/app.js

Large diffs are not rendered by default.

24 changes: 1 addition & 23 deletions public/app.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,7 @@
*/

/**
* @remix-run/router v1.14.2
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* React Router DOM v6.21.3
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/

/**
* React Router v6.21.3
* react-router v7.5.3
*
* Copyright (c) Remix Software Inc.
*
Expand Down
31 changes: 31 additions & 0 deletions public/tests/river-cities.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="description" content="React JS recovery meeting finder demo" />
<link rel="icon" type="image/png" href="/logo.png" />
<title>Meetings</title>
<style type="text/css">
body {
margin: 0;
}
#tsml-ui {
min-height: 100vh;
min-height: -webkit-fill-available;
}
</style>
</head>
<body>
<div
id="tsml-ui"
data-src="https://docs.google.com/spreadsheets/d/1lqDzi6bS8zJoWe2WuHNh4V-8nkn205ufgtRgvX9niiA/edit?gid=1811591486#gid=1811591486"
data-mapbox="pk.eyJ1Ijoiam9zaHJlaXNuZXIiLCJhIjoiY2tvYXA0YnZxMGRldDJxbzdta25uNGphdiJ9.eay-UKgIT99ALmdw08xBPw"
data-google="AIzaSyCS9M8Dqk5cMFqA7xvUrQEzT1u5IvcbT7c"
></div>
<script src="/app.js" async></script>
</body>
</html>
23 changes: 23 additions & 0 deletions src/helpers/load-meeting-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { formatAddress } from './format-address';
import { formatConferenceProvider } from './format-conference-provider';
import { formatFeedbackEmail } from './format-feedback-email';
import { formatSlug } from './format-slug';
import { states } from './states';

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

Expand Down Expand Up @@ -100,6 +101,15 @@ export function loadMeetingData(

// creates formatted_address if necessary
if (!formatted_address) {
// infer country if state is in Canada or USA
if (!meeting.country && meeting.state) {
if (states.canada.includes(meeting.state)) {
meeting.country = 'Canada';
} else if (states.usa.includes(meeting.state)) {
meeting.country = 'USA';
}
}

formatted_address = [
meeting.address,
meeting.city,
Expand Down Expand Up @@ -321,6 +331,19 @@ export function loadMeetingData(
}
});
}
} else {
const timeIndex = indexes.time.findIndex(
({ key }) => key === 'appointment'
);
if (timeIndex === -1) {
indexes.time.push({
key: 'appointment',
name: strings.appointment,
slugs: [slug],
});
} else {
indexes.time[timeIndex].slugs.push(slug);
}
}

// parse regions
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const defaults: TSMLReactConfig = {
sk,
sv,
},
times: ['morning', 'midday', 'evening', 'night'],
times: ['morning', 'midday', 'evening', 'night', 'appointment'],
weekdays: [
'sunday',
'monday',
Expand Down
78 changes: 78 additions & 0 deletions src/helpers/states.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
export const states = {
canada: [
'AB',
'BC',
'MB',
'NB',
'NL',
'NT',
'NS',
'NU',
'ON',
'PE',
'QC',
'SK',
'YT',
],
usa: [
'AL',
'AK',
'AS',
'AZ',
'AR',
'CA',
'CO',
'CT',
'DE',
'DC',
'FM',
'FL',
'GA',
'GU',
'HI',
'ID',
'IL',
'IN',
'IA',
'KS',
'KY',
'LA',
'ME',
'MH',
'MD',
'MA',
'MI',
'MN',
'MS',
'MO',
'MT',
'NE',
'NV',
'NH',
'NJ',
'NM',
'NY',
'NC',
'ND',
'MP',
'OH',
'OK',
'OR',
'PW',
'PA',
'PR',
'RI',
'SC',
'SD',
'TN',
'TX',
'UT',
'VT',
'VI',
'VA',
'WA',
'WV',
'WI',
'WY',
],
};
8 changes: 7 additions & 1 deletion test/__tests__/load-meeting-data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@ describe('loadMeetingData', () => {
slugs: ['test-meeting'],
},
],
time: [],
time: [
{
key: 'appointment',
name: 'Appointment',
slugs: ['test-meeting', 'inactive-meeting'],
},
],
type: [
{
key: 'active',
Expand Down