From d9953d1a3c7118478e2483963a399c64028be172 Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Thu, 2 Mar 2023 05:45:27 +0000 Subject: [PATCH] Images working (needs testing) --- .eslintrc.js | 97 +++++++++++++++++++ .eslintrc.json | 3 - package.json | 9 +- src/app/layout.tsx | 40 ++++---- src/app/loading.tsx | 2 - src/app/page.tsx | 2 - .../profile/ProfilePageComponentProfile.tsx | 10 +- src/components/providers/FirebaseProvider.tsx | 53 ++++++++++ src/components/providers/LoggingProvider.tsx | 7 -- src/components/providers/index.ts | 3 +- .../widgets/inputs/FirebaseImageUploader.tsx | 35 ++++++- src/lib/auth/firebase.ts | 2 +- src/lib/core/generic/index.ts | 1 + src/lib/db/collections.ts | 7 ++ src/lib/db/converters.ts | 35 +++++++ src/lib/db/hooks/useGetUserProfile.tsx | 18 ++++ src/lib/db/index.ts | 42 +------- .../firebaseConfig.ts => firebase/index.ts} | 2 + src/lib/util/logging/index.js | 1 + src/lib/util/logging/logRocket.tsx | 12 +++ src/lib/util/logging/useLogRocket.tsx | 89 ----------------- src/models/index.ts | 4 +- src/models/viewer.ts | 5 + yarn.lock | 50 +++++----- 24 files changed, 331 insertions(+), 198 deletions(-) create mode 100644 .eslintrc.js delete mode 100644 .eslintrc.json create mode 100644 src/components/providers/FirebaseProvider.tsx delete mode 100644 src/components/providers/LoggingProvider.tsx create mode 100644 src/lib/core/generic/index.ts create mode 100644 src/lib/db/collections.ts create mode 100644 src/lib/db/converters.ts create mode 100644 src/lib/db/hooks/useGetUserProfile.tsx rename src/lib/{db/firebaseConfig.ts => firebase/index.ts} (87%) create mode 100644 src/lib/util/logging/logRocket.tsx delete mode 100644 src/lib/util/logging/useLogRocket.tsx create mode 100644 src/models/viewer.ts diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..c9e6269 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,97 @@ +const prettierConfig = require("./.prettierrc.js"); + +module.exports = { + env: { + browser: true, + commonjs: true, + es2021: true, + node: true, + }, + extends: [ + "next", + "prettier", + "eslint:recommended", + "plugin:react/recommended", + "plugin:react-hooks/recommended", + "plugin:prettier/recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "next/core-web-vitals", + ], + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + ecmaVersion: 12, + sourceType: "module", + }, + plugins: ["react"], + rules: { + // Possible errors + "no-console": "warn", + // Best practices + "dot-notation": "error", + "no-else-return": "error", + "no-floating-decimal": "error", + "no-sequences": "error", + // Stylistic + "array-bracket-spacing": "error", + "computed-property-spacing": ["error", "never"], + curly: "error", + "no-lonely-if": "error", + "no-unneeded-ternary": "error", + "one-var-declaration-per-line": "error", + quotes: [ + "error", + "single", + { + allowTemplateLiterals: false, + avoidEscape: true, + }, + ], + // ES6 + "array-callback-return": "off", + "prefer-const": "error", + // Imports + "import/prefer-default-export": "off", + "sort-imports": [ + "error", + { + ignoreCase: true, + ignoreDeclarationSort: true, + }, + ], + "no-unused-expressions": "off", + "no-prototype-builtins": "off", + // REACT + "react/jsx-uses-react": "off", + "react/react-in-jsx-scope": "off", + "jsx-a11y/href-no-hash": [0], + "react/display-name": 0, + "react/no-deprecated": "error", + "react/no-unsafe": [ + "error", + { + checkAliases: true, + }, + ], + "react/jsx-sort-props": [ + "error", + { + ignoreCase: true, + }, + ], + "react-hooks/rules-of-hooks": "error", + "react-hooks/exhaustive-deps": 0, + // Prettier + // eslint looks for the prettier config at the top level of the package/app + // but the config lives in the `config/` directory. Passing the config here + // to get around this. + "prettier/prettier": ["error", prettierConfig], + }, + settings: { + react: { + version: "detect", + }, + }, +}; diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index bffb357..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "next/core-web-vitals" -} diff --git a/package.json b/package.json index fa5fc0f..32dcee2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "dev": "node ./server.js", "debug": "node ./server.js", "dev-nossl": "next dev", - "build": "next build", + "build": "next build && next export", "start": "next start", "lint": "next lint" }, @@ -17,17 +17,18 @@ "@next/font": "13.2.0", "@prisma/client": "^4.9.0", "@types/feather-icons": "^4.29.1", - "@types/logrocket-react": "^3.0.0", "@types/node": "18.14.2", "@types/react": "18.0.28", "@types/react-dom": "18.0.11", "@upstash/qstash": "^0.3.6", "axios": "^1.3.4", + "babel": "^6.23.0", "classnames": "^2.3.2", "daisyui": "^2.49.0", "encoding": "^0.1.13", "eslint": "8.35.0", "eslint-config-next": "13.2.3", + "eslint-plugin-react-hooks": "^4.6.0", "feather-icons": "^4.29.0", "firebase": "^9.17.1", "firebase-admin": "^11.5.0", @@ -36,7 +37,6 @@ "http-status-codes": "^2.2.0", "localforage": "^1.10.0", "logrocket": "^3.0.1", - "logrocket-react": "^5.0.1", "next": "13.2.3", "next-logger": "^3.0.1", "next-seo": "^5.15.0", @@ -61,9 +61,10 @@ "@google-cloud/local-auth": "2.1.1", "@hookform/devtools": "^4.3.0", "autoprefixer": "^10.4.13", + "eslint-config-prettier": "^8.6.0", "googleapis": "111.0.0", "postcss": "^8.4.21", - "prettier": "^2.8.3", + "prettier": "^2.8.4", "prettier-plugin-tailwindcss": "^0.2.2", "prisma": "^4.9.0", "tailwindcss": "^3.2.4" diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 118dfbf..aff5a35 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -7,14 +7,12 @@ import { NavBar, PushNotificationWrapper } from "@/components/layout"; import { AuthUserProvider } from "@/lib/auth/authUserContext"; import { themeChange } from "theme-change"; import Script from "next/script"; -import logger from "@/lib/util/logging"; import { Toaster } from "react-hot-toast"; -import { LoggingProvider, ThemeProvider } from "@/components/providers"; -const LogRocket = require("logrocket"); -const setupLogRocketReact = require("logrocket-react"); +import useLogRocket from "@/lib/util/logging/logRocket"; +import logger from "@/lib/util/logging"; +import FirestoreProvider from "@/components/providers/FirebaseProvider"; // only initialize when in the browser - const font = Raleway({ weight: ["400", "700"], subsets: ["latin"], @@ -25,30 +23,28 @@ const RootLayout = ({ children }: React.PropsWithChildren) => { React.useEffect(() => { logger.info("Bootstrapping application"); themeChange(false); - }, []); + }, [logger]); return (