Skip to content

Commit 1f6baa3

Browse files
authored
Merge pull request #332 from labzero/develop
Merge to master
2 parents 9ab7b4d + 37ab829 commit 1f6baa3

91 files changed

Lines changed: 977 additions & 2115 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.

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ module.exports = {
100100
"import/no-relative-packages": "off",
101101
"import/no-import-module-exports": "off",
102102
"no-use-before-define": "off",
103+
"no-param-reassign": [
104+
"error",
105+
{ props: true, ignorePropertyModificationsFor: ["draftState"] },
106+
],
103107
"@typescript-eslint/no-use-before-define": ["error"],
104108
},
105109

package.json

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,16 @@
2828
"cors": "^2.8.3",
2929
"dayjs": "^1.11.7",
3030
"dotenv": "^2.0.0",
31-
"eventemitter3": "^1.2.0",
3231
"express": "^4.17.3",
3332
"express-body-parser-error-handler": "^1.0.4",
3433
"express-jwt": "^8.4.1",
3534
"express-session": "^1.17.3",
3635
"express-sslify": "^1.2.0",
3736
"express-ws": "^5.0.2",
38-
"fastclick": "^1.0.6",
39-
"fbjs": "^3.0.4",
4037
"fetch-mock": "^9.11.0",
4138
"flip-toolkit": "^7.1.0",
4239
"google-map-react": "^2.2.0",
4340
"history": "^5.3.0",
44-
"immutability-helper": "^3.1.1",
4541
"isomorphic-style-loader": "^5.3.2",
4642
"jsonwebtoken": "^9.0.0",
4743
"lodash.get": "^4.4.2",
@@ -55,15 +51,13 @@
5551
"pg": "^8.9.0",
5652
"pretty-error": "^3.0.4",
5753
"prop-types": "^15.8.1",
58-
"qs": "^6.11.2",
5954
"react": "^18.2.0",
6055
"react-autosuggest": "^10.0.2",
6156
"react-bootstrap": "^2.7.0",
6257
"react-dom": "^18.2.0",
6358
"react-flip-toolkit": "^7.0.17",
6459
"react-geosuggest": "^2.14.1",
6560
"react-icons": "^4.7.1",
66-
"react-intl": "^6.4.2",
6761
"react-redux": "^8.0.5",
6862
"react-scroll": "^1.8.9",
6963
"react-transition-group": "^4.4.5",
@@ -78,9 +72,7 @@
7872
"sequelize-typescript": "^2.1.5",
7973
"serialize-javascript": "^6.0.1",
8074
"source-map-support": "^0.5.21",
81-
"sqlite3": "^5.1.5",
82-
"universal-router": "^8.1.0",
83-
"uuid": "^9.0.0"
75+
"universal-router": "^8.1.0"
8476
},
8577
"devDependencies": {
8678
"@istanbuljs/nyc-config-typescript": "^1.0.2",
@@ -99,7 +91,6 @@
9991
"@types/express-session": "^1.17.6",
10092
"@types/express-sslify": "^1.2.2",
10193
"@types/express-ws": "^3.0.1",
102-
"@types/fbjs": "^3.0.4",
10394
"@types/google-map-react": "^2.1.7",
10495
"@types/google.analytics": "^0.0.42",
10596
"@types/google.maps": "^3.52.1",
@@ -119,23 +110,18 @@
119110
"@types/serialize-javascript": "^5.0.2",
120111
"@types/sinon": "^10.0.15",
121112
"@types/supertest": "^2.0.12",
122-
"@types/uuid": "^9.0.0",
123113
"@types/validator": "^13.7.17",
124114
"@types/webpack-env": "^1.18.0",
125115
"@typescript-eslint/eslint-plugin": "^5.59.1",
126116
"@typescript-eslint/parser": "^5.59.1",
127-
"assets-webpack-plugin": "^7.1.1",
128117
"autoprefixer": "^9.1.5",
129118
"browser-sync": "2.29.1",
130119
"chai": "4.3.7",
131120
"chai-jsdom": "^0.2.3",
132121
"chokidar": "^3.5.3",
133122
"cross-env": "^5.0.1",
134123
"css-loader": "^6.7.3",
135-
"custom-event-polyfill": "^0.3.0",
136124
"cypress": "^12.5.1",
137-
"del": "^2.2.2",
138-
"es6-promise": "^4.1.0",
139125
"eslint": "^8.34.0",
140126
"eslint-config-airbnb": "^19.0.4",
141127
"eslint-config-prettier": "^8.8.0",
@@ -148,13 +134,10 @@
148134
"eslint-plugin-react-hooks": "^4.6.0",
149135
"file-loader": "^6.2.0",
150136
"fork-ts-checker-webpack-plugin": "^7.3.0",
151-
"git-repository": "^0.1.4",
152137
"glob": "^7.1.3",
153138
"global-jsdom": "^9.0.1",
154139
"husky": "^8.0.3",
155-
"identity-obj-proxy": "^3.0.0",
156140
"jsdom": "^22.0.0",
157-
"json-loader": "^0.5.7",
158141
"lint-staged": "^13.2.2",
159142
"mkdirp": "^2.1.3",
160143
"mocha": "^10.2.0",
@@ -170,13 +153,11 @@
170153
"react-dev-utils": "^12.0.1",
171154
"react-error-overlay": "^4.0.1",
172155
"react-refresh": "^0.14.0",
173-
"react-test-renderer": "^18.2.0",
174156
"rimraf": "^2.6.2",
175157
"sass": "^1.58.0",
176158
"sass-loader": "^13.2.0",
177159
"sequelize-mock": "^0.7.0",
178160
"sinon": "^15.1.0",
179-
"style-loader": "^0.13.2",
180161
"stylelint": "^15.6.2",
181162
"stylelint-config-standard-scss": "^9.0.0",
182163
"stylelint-order": "^6.0.3",

src/actions/flash.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
import { v1 } from "uuid";
1+
import nodeCrypto from "crypto";
22
import { Action } from "../interfaces";
3+
import canUseDOM from "../helpers/canUseDOM";
4+
5+
const crypto = canUseDOM ? window.crypto : nodeCrypto;
36

47
export function flashError(message: string): Action {
58
return {
69
type: "FLASH_ERROR",
710
message,
8-
id: v1(),
11+
id: crypto.randomUUID(),
912
};
1013
}
1114

1215
export function flashSuccess(message: string): Action {
1316
return {
1417
type: "FLASH_SUCCESS",
1518
message,
16-
id: v1(),
19+
id: crypto.randomUUID(),
1720
};
1821
}
1922

src/actions/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ThunkAction } from "@reduxjs/toolkit";
2+
import { Action, State } from "../interfaces";
3+
import { removeRestaurant } from "./restaurants";
4+
import { removeTag } from "./tags";
5+
import { changeUserRole, removeUser } from "./users";
6+
7+
const generateConfirmableActions = <
8+
T extends {
9+
[K in keyof T]: (
10+
...args: Parameters<T[K]>
11+
) => ThunkAction<Promise<Action>, State, unknown, Action>;
12+
}
13+
>(
14+
actions: T
15+
) => actions;
16+
17+
export const confirmableActions = generateConfirmableActions({
18+
changeUserRole,
19+
removeRestaurant,
20+
removeTag,
21+
removeUser,
22+
});

src/actions/modals.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import { confirmableActions } from ".";
12
import { Action, ConfirmOpts, PastDecisionsOpts } from "../interfaces";
23

34
export function showModal(name: string): Action;
45
export function showModal(
56
name: "pastDecisions",
67
opts?: PastDecisionsOpts
78
): Action;
8-
export function showModal(name: "confirm", opts?: ConfirmOpts): Action;
9+
export function showModal(
10+
name: "confirm",
11+
opts?: ConfirmOpts<keyof typeof confirmableActions>
12+
): Action;
913

1014
export function showModal(name: unknown, opts?: unknown): unknown {
1115
return {

src/actions/restaurants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export function addRestaurant(
274274

275275
export function removeRestaurant(
276276
id: number
277-
): ThunkAction<Promise<void>, State, unknown, Action> {
277+
): ThunkAction<Promise<Action>, State, unknown, Action> {
278278
return (dispatch) => {
279279
dispatch(deleteRestaurant(id));
280280
return fetch(`/api/restaurants/${id}`, {

src/actions/users.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ThunkAction } from "@reduxjs/toolkit";
2-
import { canUseDOM } from "fbjs/lib/ExecutionEnvironment";
32
import { credentials, jsonHeaders, processResponse } from "../core/ApiClient";
3+
import canUseDOM from "../helpers/canUseDOM";
44
import { Action, RoleType, State, Team, User } from "../interfaces";
55
import { getCurrentUser } from "../selectors/user";
66

@@ -93,7 +93,7 @@ export function userDeleted(id: number, team: Team, isSelf: boolean): Action {
9393
export function removeUser(
9494
id: number,
9595
team: Team
96-
): ThunkAction<void, State, unknown, Action> {
96+
): ThunkAction<Promise<Action>, State, unknown, Action> {
9797
return (dispatch, getState) => {
9898
const state = getState();
9999
let isSelf = false;
@@ -182,7 +182,7 @@ export function userPatched(
182182
export function changeUserRole(
183183
id: number,
184184
type: RoleType
185-
): ThunkAction<void, State, unknown, Action> {
185+
): ThunkAction<Promise<Action>, State, unknown, Action> {
186186
const payload = { id, type };
187187
return (dispatch, getState) => {
188188
const state = getState();

src/api/tests/decisions.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import { expect } from "chai";
55
import { SinonSpy, match, spy, stub } from "sinon";
66
import bodyParser from "body-parser";
7-
import { Response } from "superagent";
8-
import request from "supertest";
7+
import request, { Response } from "supertest";
98
import express, { Application, RequestHandler } from "express";
109
import proxyquire from "proxyquire";
1110
import SequelizeMock from "sequelize-mock";

src/api/tests/user.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import { expect } from "chai";
55
import { SinonSpy, spy, stub } from "sinon";
66
import bodyParser from "body-parser";
7-
import { Response } from "superagent";
8-
import request from "supertest";
7+
import request, { Response } from "supertest";
98
import express, { Application } from "express";
109
import proxyquire from "proxyquire";
1110
import SequelizeMock from "sequelize-mock";

src/api/tests/users.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import { expect } from "chai";
55
import { SinonSpy, SinonStub, match, spy, stub } from "sinon";
66
import bodyParser from "body-parser";
7-
import { Response } from "superagent";
8-
import request from "supertest";
7+
import request, { Response } from "supertest";
98
import express, { Application, RequestHandler } from "express";
109
import proxyquire from "proxyquire";
1110
import SequelizeMock from "sequelize-mock";

0 commit comments

Comments
 (0)