From ee51ed7bfe07505e6208c707b0234020c6e82f46 Mon Sep 17 00:00:00 2001
From: Joffjoff5000 <Joffjoff5000@gmail.com>
Date: Tue, 9 Mar 2021 11:56:39 +0100
Subject: [PATCH] #31: Change file extensions from .js -> .ts

---
 client/package-lock.json                  |  6 ++
 client/package.json                       |  3 +-
 client/src/actions/communication.js       | 62 -------------------
 client/src/actions/communication.ts       | 75 +++++++++++++++++++++++
 client/src/actions/{login.js => login.ts} |  0
 client/src/actions/{types.js => types.ts} |  0
 client/src/reducers/allReducers.js        | 11 ----
 client/src/reducers/allReducers.ts        | 10 +++
 client/src/reducers/isLoggedIn.js         |  9 ---
 client/src/reducers/isLoggedIn.ts         | 10 +++
 10 files changed, 103 insertions(+), 83 deletions(-)
 delete mode 100644 client/src/actions/communication.js
 create mode 100644 client/src/actions/communication.ts
 rename client/src/actions/{login.js => login.ts} (100%)
 rename client/src/actions/{types.js => types.ts} (100%)
 delete mode 100644 client/src/reducers/allReducers.js
 create mode 100644 client/src/reducers/allReducers.ts
 delete mode 100644 client/src/reducers/isLoggedIn.js
 create mode 100644 client/src/reducers/isLoggedIn.ts

diff --git a/client/package-lock.json b/client/package-lock.json
index ca2a06eb..2d93d97e 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -15412,6 +15412,12 @@
         "is-typedarray": "^1.0.0"
       }
     },
+    "typesafe-actions": {
+      "version": "5.1.0",
+      "resolved": "https://registry.npmjs.org/typesafe-actions/-/typesafe-actions-5.1.0.tgz",
+      "integrity": "sha512-bna6Yi1pRznoo6Bz1cE6btB/Yy8Xywytyfrzu/wc+NFW3ZF0I+2iCGImhBsoYYCOWuICtRO4yHcnDlzgo1AdNg==",
+      "dev": true
+    },
     "typescript": {
       "version": "4.1.3",
       "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz",
diff --git a/client/package.json b/client/package.json
index 58910bbf..495c2acd 100644
--- a/client/package.json
+++ b/client/package.json
@@ -43,7 +43,8 @@
     "eslint-plugin-jsx-a11y": "^6.4.1",
     "eslint-plugin-prettier": "^3.3.1",
     "eslint-plugin-react": "^7.22.0",
-    "prettier": "^2.2.1"
+    "prettier": "^2.2.1",
+    "typesafe-actions": "^5.1.0"
   },
   "scripts": {
     "start": "react-scripts start",
diff --git a/client/src/actions/communication.js b/client/src/actions/communication.js
deleted file mode 100644
index 587f431e..00000000
--- a/client/src/actions/communication.js
+++ /dev/null
@@ -1,62 +0,0 @@
-import Types from "./types.js";
-
-export function axiosPost(path, data, config = undefined, 
-        startCB = undefined, successCB = undefined, errorCB = undefined){
-    return {
-        type: Types.AXIOS_POST,
-        path, 
-        data,
-        config,
-        startCB,
-        successCB,
-        errorCB
-    }
-}
-
-export function axiosPostSuccess(path, data, previousAction){
-    return {
-        type: Types.AXIOS_POST_SUCCESS,
-        path,
-        data,
-        previousAction
-    }
-}
-
-export function axiosPostError(path, data, previousAction){
-    return {
-        type: Types.AXIOS_POST_ERROR,
-        path,
-        data,
-        previousAction
-    }
-}
-
-export function axiosGet(path, data, config = undefined, startCB = undefined, successCB = undefined, errorCB = undefined) {
-    return {
-        type: Types.AXIOS_GET,
-        path, 
-        data,
-        config,
-        startCB,
-        successCB,
-        errorCB
-    }
-}
-
-export function axiosGetSuccess(path, data, previousAction){
-    return {
-        type: Types.AXIOS_GET_SUCCESS,
-        path,
-        data,
-        previousAction
-    }
-}
-
-export function axiosGetError(path, data, previousAction){
-    return {
-        type: Types.AXIOS_GET_ERROR,
-        path,
-        data,
-        previousAction
-    }
-}
diff --git a/client/src/actions/communication.ts b/client/src/actions/communication.ts
new file mode 100644
index 00000000..d0719cd3
--- /dev/null
+++ b/client/src/actions/communication.ts
@@ -0,0 +1,75 @@
+import Types from './types.js'
+
+export function axiosPost(
+  path: any,
+  data: any,
+  config = undefined,
+  startCB = undefined,
+  successCB = undefined,
+  errorCB = undefined
+) {
+  return {
+    type: Types.AXIOS_POST,
+    path,
+    data,
+    config,
+    startCB,
+    successCB,
+    errorCB,
+  }
+}
+
+export function axiosPostSuccess(path: any, data: any, previousAction: any) {
+  return {
+    type: Types.AXIOS_POST_SUCCESS,
+    path,
+    data,
+    previousAction,
+  }
+}
+
+export function axiosPostError(path: any, data: any, previousAction: any) {
+  return {
+    type: Types.AXIOS_POST_ERROR,
+    path,
+    data,
+    previousAction,
+  }
+}
+
+export function axiosGet(
+  path: any,
+  data: any,
+  config = undefined,
+  startCB = undefined,
+  successCB = undefined,
+  errorCB = undefined
+) {
+  return {
+    type: Types.AXIOS_GET,
+    path,
+    data,
+    config,
+    startCB,
+    successCB,
+    errorCB,
+  }
+}
+
+export function axiosGetSuccess(path: any, data: any, previousAction: any) {
+  return {
+    type: Types.AXIOS_GET_SUCCESS,
+    path,
+    data,
+    previousAction,
+  }
+}
+
+export function axiosGetError(path: any, data: any, previousAction: any) {
+  return {
+    type: Types.AXIOS_GET_ERROR,
+    path,
+    data,
+    previousAction,
+  }
+}
diff --git a/client/src/actions/login.js b/client/src/actions/login.ts
similarity index 100%
rename from client/src/actions/login.js
rename to client/src/actions/login.ts
diff --git a/client/src/actions/types.js b/client/src/actions/types.ts
similarity index 100%
rename from client/src/actions/types.js
rename to client/src/actions/types.ts
diff --git a/client/src/reducers/allReducers.js b/client/src/reducers/allReducers.js
deleted file mode 100644
index 2bfcd5ea..00000000
--- a/client/src/reducers/allReducers.js
+++ /dev/null
@@ -1,11 +0,0 @@
-// Combines all the reducers so that we only have to pass "one" reducer to the store in src/index.tsx
-
-
-import { combineReducers } from 'redux';
-import loggedInReducer from './isLoggedIn';
-
-const allReducers = combineReducers({
-    // name: state
-    isLoggedIn: loggedInReducer // You can write "loggedInReducer" because its the same as "loggedInReducer: loggedInReducer"
-});
-export default allReducers;
\ No newline at end of file
diff --git a/client/src/reducers/allReducers.ts b/client/src/reducers/allReducers.ts
new file mode 100644
index 00000000..4903f9d7
--- /dev/null
+++ b/client/src/reducers/allReducers.ts
@@ -0,0 +1,10 @@
+// Combines all the reducers so that we only have to pass "one" reducer to the store in src/index.tsx
+
+import { combineReducers } from 'redux'
+import loggedInReducer from './isLoggedIn'
+
+const allReducers = combineReducers({
+  // name: state
+  isLoggedIn: loggedInReducer, // You can write "loggedInReducer" because its the same as "loggedInReducer: loggedInReducer"
+})
+export default allReducers
diff --git a/client/src/reducers/isLoggedIn.js b/client/src/reducers/isLoggedIn.js
deleted file mode 100644
index b665894a..00000000
--- a/client/src/reducers/isLoggedIn.js
+++ /dev/null
@@ -1,9 +0,0 @@
-const loggedInReducer = (state = false, action) => { // isLoggedIn has an initial state of false
-  switch (action.type) {
-    case 'SIGN_IN':
-      return !state;
-    default:
-      return state;
-  }
-}
-export default loggedInReducer
diff --git a/client/src/reducers/isLoggedIn.ts b/client/src/reducers/isLoggedIn.ts
new file mode 100644
index 00000000..cf5d7b43
--- /dev/null
+++ b/client/src/reducers/isLoggedIn.ts
@@ -0,0 +1,10 @@
+const loggedInReducer = (state = false, action: { type: any }) => {
+  // isLoggedIn has an initial state of false
+  switch (action.type) {
+    case 'SIGN_IN':
+      return !state
+    default:
+      return state
+  }
+}
+export default loggedInReducer
-- 
GitLab