From aa5602b36bd78f88c75e9f2b0f367ff8da4b997d Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Tue, 29 Aug 2023 22:13:29 -0400 Subject: [PATCH 001/177] feat: new approach to multi domain --- .gitignore | 1 + jsconfig.json | 3 ++- packages/config/lib/index.js | 9 +++++++++ server/src/configs/default.json | 1 - server/src/index.js | 10 +++++++--- server/src/routes/clientRouter.js | 5 +++-- server/src/services/config.js | 20 +++++++++++++------- server/src/services/i18n.js | 4 +++- vite.config.js | 7 ++++++- 9 files changed, 44 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index b97ba2cd3..801a266cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules dist +dist-* # Config files server/src/configs/* diff --git a/jsconfig.json b/jsconfig.json index 88e79d180..413dbbde3 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -24,6 +24,7 @@ "exclude": [ "node_modules", "**/node_modules/*", - "dist" + "dist", + "dist-*" ] } \ No newline at end of file diff --git a/packages/config/lib/index.js b/packages/config/lib/index.js index 6c7ce04d0..79c58862c 100644 --- a/packages/config/lib/index.js +++ b/packages/config/lib/index.js @@ -12,6 +12,15 @@ if (!process.env.NODE_CONFIG_DIR) { process.env.ALLOW_CONFIG_MUTATIONS = 'true' } +if (process.env.NODE_CONFIG_ENV) { + if ( + process.env.NODE_CONFIG_ENV.includes('.') || + process.env.NODE_CONFIG_ENV.includes('/') + ) { + throw new Error('Invalid NODE_CONFIG_ENV, must not contain "." or "/"') + } +} + const config = require('config') config.getSafe = config.get diff --git a/server/src/configs/default.json b/server/src/configs/default.json index 3e38cbd1e..de6c9bc9a 100644 --- a/server/src/configs/default.json +++ b/server/src/configs/default.json @@ -7,7 +7,6 @@ "enabled": false, "graphiql": false, "queryDebug": false, - "clientPath": "../../dist", "logLevel": "info", "skipMinified": false }, diff --git a/server/src/index.js b/server/src/index.js index 56f1cae08..a6e6018ae 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -137,10 +137,14 @@ app.use(compression()) app.use(express.json({ limit: '50mb' })) -app.use( - express.static(path.join(__dirname, config.getSafe('devOptions.clientPath'))), +const distDir = path.join( + __dirname, + '../../', + `dist${process.env.NODE_CONFIG_ENV ? `-${process.env.NODE_CONFIG_ENV}` : ''}`, ) +app.use(express.static(distDir)) + app.use( session({ name: 'reactmap1', @@ -168,7 +172,7 @@ passport.deserializeUser(async (user, done) => { } }) -const localePath = path.resolve(__dirname, '../../dist/locales') +const localePath = path.resolve(distDir, 'locales') if (fs.existsSync(localePath)) { require('./services/i18n') } else { diff --git a/server/src/routes/clientRouter.js b/server/src/routes/clientRouter.js index 7eb3d0571..601b781b6 100644 --- a/server/src/routes/clientRouter.js +++ b/server/src/routes/clientRouter.js @@ -1,7 +1,6 @@ // @ts-check const express = require('express') const path = require('path') -const config = require('@rm/config') const router = express.Router() @@ -22,7 +21,9 @@ router.get(CLIENT_ROUTES, (req, res) => { res.sendFile( path.join( __dirname, - `../${config.getSafe('devOptions.clientPath')}/index.html`, + `../../../dist${ + process.env.NODE_CONFIG_ENV ? `-${process.env.NODE_CONFIG_ENV}` : '' + }/index.html`, ), ) }) diff --git a/server/src/services/config.js b/server/src/services/config.js index 59d176919..d53459e9d 100644 --- a/server/src/services/config.js +++ b/server/src/services/config.js @@ -213,13 +213,19 @@ const mergeMapConfig = (input) => { // Merge sub-objects for the map object config.map = mergeMapConfig(config.map) -// Create multiDomain Objects -config.multiDomainsObj = Object.fromEntries( - config.multiDomains.map((d) => [ - d.domain.replaceAll('.', '_'), - mergeMapConfig(d), - ]), -) +if (config.has('multiDomains')) { + log.warn( + HELPERS.config, + '`multiDomains` has been deprecated and will be removed in the next major release. Please switch to the new format that makes use of `NODE_CONFIG_ENV`', + ) + // Create multiDomain Objects + config.multiDomainsObj = Object.fromEntries( + config.multiDomains.map((d) => [ + d.domain.replaceAll('.', '_'), + mergeMapConfig(d), + ]), + ) +} // Check if empty ;['tileServers', 'navigation'].forEach((opt) => { diff --git a/server/src/services/i18n.js b/server/src/services/i18n.js index 094efd298..f3b8a4928 100644 --- a/server/src/services/i18n.js +++ b/server/src/services/i18n.js @@ -17,7 +17,9 @@ i18next.use(Backend).init( backend: { loadPath: path.resolve( __dirname, - `../../../dist/locales/{{lng}}/{{ns}}.json`, + `../../../dist${ + process.env.NODE_CONFIG_ENV ? `-${process.env.NODE_CONFIG_ENV}` : '' + }/locales/{{lng}}/{{ns}}.json`, ), }, }, diff --git a/vite.config.js b/vite.config.js index cfbe987db..99b501157 100644 --- a/vite.config.js +++ b/vite.config.js @@ -188,7 +188,12 @@ const viteConfig = defineConfig(async ({ mode }) => { }, build: { target: ['safari11.1', 'chrome64', 'firefox66', 'edge88'], - outDir: resolve(__dirname, './dist'), + outDir: resolve( + __dirname, + `./dist${ + process.env.NODE_CONFIG_ENV ? `-${process.env.NODE_CONFIG_ENV}` : '' + }`, + ), sourcemap: isRelease || isDevelopment ? true : 'hidden', minify: isDevelopment || config.getSafe('devOptions.skipMinified') From f470f53fe3995e72391012a54c02ff5661660f5c Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:21:14 -0500 Subject: [PATCH 002/177] fix: custom favicons for each domain --- packages/vite-plugins/lib/favicon.js | 16 ++++++++++++---- server/src/configs/default.json | 3 +-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/vite-plugins/lib/favicon.js b/packages/vite-plugins/lib/favicon.js index 108d1c4d1..b9d29834c 100644 --- a/packages/vite-plugins/lib/favicon.js +++ b/packages/vite-plugins/lib/favicon.js @@ -10,11 +10,19 @@ const { log, HELPERS } = require('@rm/logger') */ const faviconPlugin = (isDevelopment) => { try { - const favicon = fs.existsSync( - resolve(__dirname, '../../../public/favicon/favicon.ico'), + const basePath = '../../../public/favicon' + const fallback = resolve(__dirname, `${basePath}/fallback.ico`) + const singleDomainPath = resolve(`${basePath}/favicon.ico`) + const multiDomainPath = resolve( + `${basePath}/${ + process.env.NODE_CONFIG_ENV ? `-${process.env.NODE_CONFIG_ENV}` : '' + }.ico`, ) - ? resolve(__dirname, '../../../public/favicon/favicon.ico') - : resolve(__dirname, '../../../public/favicon/fallback.ico') + const favicon = fs.existsSync(multiDomainPath) + ? multiDomainPath + : fs.existsSync(singleDomainPath) + ? singleDomainPath + : fallback return { name: 'vite-plugin-favicon', generateBundle() { diff --git a/server/src/configs/default.json b/server/src/configs/default.json index 09c96af59..7edfa5ddd 100644 --- a/server/src/configs/default.json +++ b/server/src/configs/default.json @@ -116,7 +116,6 @@ "bearerToken": "KOJI_SECRET" } }, - "multiDomains": [], "map": { "general": { "title": "ReactMap", @@ -1021,4 +1020,4 @@ "tracesSampleRate": 0.1 } } -} +} \ No newline at end of file From e5b8a9ccaf2bf00af5784107768dffc68fa2673e Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:59:20 -0500 Subject: [PATCH 003/177] fix: check for multidomains in areas --- server/src/services/areas.js | 44 +++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/server/src/services/areas.js b/server/src/services/areas.js index cbed30be7..edfcb4e0f 100644 --- a/server/src/services/areas.js +++ b/server/src/services/areas.js @@ -333,16 +333,20 @@ const loadLatestAreas = async () => { /** @type {Record} */ const scanAreas = { main: await loadScanPolygons(fileName), - ...Object.fromEntries( - await Promise.all( - config - .getSafe('multiDomains') - .map(async (d) => [ - d.general?.geoJsonFileName ? d.domain.replaceAll('.', '_') : 'main', - await loadScanPolygons(d.general?.geoJsonFileName || fileName), - ]), - ), - ), + ...(config.has('multiDomains') + ? Object.fromEntries( + await Promise.all( + config + .getSafe('multiDomains') + .map(async (d) => [ + d.general?.geoJsonFileName + ? d.domain.replaceAll('.', '_') + : 'main', + await loadScanPolygons(d.general?.geoJsonFileName || fileName), + ]), + ), + ) + : {}), } return buildAreas(scanAreas) } @@ -353,14 +357,18 @@ const loadCachedAreas = () => { /** @type {Record} */ const scanAreas = { main: loadFromFile(fileName), - ...Object.fromEntries( - config - .getSafe('multiDomains') - .map((d) => [ - d.general?.geoJsonFileName ? d.domain.replaceAll('.', '_') : 'main', - loadFromFile(d.general?.geoJsonFileName || fileName), - ]), - ), + ...(config.has('multiDomains') + ? Object.fromEntries( + config + .getSafe('multiDomains') + .map((d) => [ + d.general?.geoJsonFileName + ? d.domain.replaceAll('.', '_') + : 'main', + loadFromFile(d.general?.geoJsonFileName || fileName), + ]), + ) + : {}), } return buildAreas(scanAreas) } From e98bb9280e1f9be998aa59d8003c6949a9bee408 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Thu, 22 Feb 2024 20:51:37 -0500 Subject: [PATCH 004/177] fix: still define obj though --- server/src/services/config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/services/config.js b/server/src/services/config.js index 4135bf08c..50ebfbe75 100644 --- a/server/src/services/config.js +++ b/server/src/services/config.js @@ -211,6 +211,8 @@ if (config.has('multiDomains')) { mergeMapConfig(d), ]), ) +} else { + config.multiDomainsObj = {} } // Check if empty From b48bcb31d329b8027fdbfef397fb89ef56c34a5a Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 23 Feb 2024 14:24:25 -0500 Subject: [PATCH 005/177] fix: simplify --- packages/vite-plugins/lib/favicon.js | 58 ++++++++++++---------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/packages/vite-plugins/lib/favicon.js b/packages/vite-plugins/lib/favicon.js index b9d29834c..33e1f5f06 100644 --- a/packages/vite-plugins/lib/favicon.js +++ b/packages/vite-plugins/lib/favicon.js @@ -9,44 +9,36 @@ const { log, HELPERS } = require('@rm/logger') * @returns {import('vite').Plugin} */ const faviconPlugin = (isDevelopment) => { - try { - const basePath = '../../../public/favicon' - const fallback = resolve(__dirname, `${basePath}/fallback.ico`) - const singleDomainPath = resolve(`${basePath}/favicon.ico`) - const multiDomainPath = resolve( - `${basePath}/${ - process.env.NODE_CONFIG_ENV ? `-${process.env.NODE_CONFIG_ENV}` : '' - }.ico`, - ) - const favicon = fs.existsSync(multiDomainPath) - ? multiDomainPath - : fs.existsSync(singleDomainPath) - ? singleDomainPath - : fallback - return { - name: 'vite-plugin-favicon', - generateBundle() { - if (isDevelopment) return + const basePath = resolve(__dirname, '../../../public/favicon') + const fallback = resolve(basePath, `fallback.ico`) + const custom = process.env.NODE_CONFIG_ENV + ? resolve(basePath, `${process.env.NODE_CONFIG_ENV}.ico`) + : resolve(basePath, `favicon.ico`) + const favicon = fs.existsSync(custom) ? custom : fallback + return { + name: 'vite-plugin-favicon', + generateBundle() { + if (isDevelopment) return + try { this.emitFile({ type: 'asset', fileName: 'favicon.ico', source: fs.readFileSync(favicon), }) - }, - configureServer(server) { - server.middlewares.use((req, res, next) => { - if (req.url === '/favicon.ico') { - res.writeHead(200, { 'Content-Type': 'image/x-icon' }) - res.end(fs.readFileSync(favicon)) - return - } - next() - }) - }, - } - } catch (e) { - log.error(HELPERS.build, 'Error loading favicon', e) - return { name: 'vite-plugin-favicon' } + } catch (e) { + log.error(HELPERS.build, 'Error loading favicon', e) + } + }, + configureServer(server) { + server.middlewares.use((req, res, next) => { + if (req.url === '/favicon.ico') { + res.writeHead(200, { 'Content-Type': 'image/x-icon' }) + res.end(fs.readFileSync(favicon)) + return + } + next() + }) + }, } } From 2acf34a2f014d8b362184554061b709c2bf6abba Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 23 Feb 2024 16:08:18 -0500 Subject: [PATCH 006/177] fix: file caching for multi --- server/src/services/cache.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/src/services/cache.js b/server/src/services/cache.js index 648bf0de6..4096cc29f 100644 --- a/server/src/services/cache.js +++ b/server/src/services/cache.js @@ -4,7 +4,9 @@ const path = require('path') const { log, HELPERS } = require('@rm/logger') -const CACHE_DIR = path.join(__dirname, '../../.cache') +const CACHE_DIR = process.env.NODE_CONFIG_ENV + ? path.join(__dirname, '../../.cache', process.env.NODE_CONFIG_ENV) + : path.join(__dirname, '../../.cache') /** @param {string} str */ const fsFriendlyName = (str) => @@ -42,7 +44,9 @@ const getCache = (unsafeName, fallback = null) => { const setCache = async (unsafeName, data) => { const fileName = fsFriendlyName(unsafeName) try { - if (!fs.existsSync(CACHE_DIR)) await fs.promises.mkdir(CACHE_DIR) + if (!fs.existsSync(CACHE_DIR)) { + await fs.promises.mkdir(CACHE_DIR, { recursive: true }) + } await fs.promises.writeFile( path.resolve(CACHE_DIR, fileName), typeof data === 'string' ? data : JSON.stringify(data), From 1a33c5ece9605e4a9c6fc0a10ae0fc2e554962f7 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 23 Feb 2024 17:41:21 -0500 Subject: [PATCH 007/177] feat: lots of docs & examples --- .gitignore | 2 + .../configs/multi-domain-example/README.md | 73 +++++++++ .../multi-domain-example/local-applemap.json | 33 ++++ .../multi-domain-example/local-orangemap.json | 39 +++++ .../configs/multi-domain-example/local.json | 150 ++++++++++++++++++ server/src/configs/multi-domain-example/nginx | 47 ++++++ 6 files changed, 344 insertions(+) create mode 100644 server/src/configs/multi-domain-example/README.md create mode 100644 server/src/configs/multi-domain-example/local-applemap.json create mode 100644 server/src/configs/multi-domain-example/local-orangemap.json create mode 100644 server/src/configs/multi-domain-example/local.json create mode 100644 server/src/configs/multi-domain-example/nginx diff --git a/.gitignore b/.gitignore index 0c9745bf6..25d01c12e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ server/src/configs/koji_backups/* !server/src/configs/areas.example.json !server/src/configs/local.example.json !server/src/configs/custom-environment-variables.json +!server/src/configs/multi-domain-example/local.json +!server/src/configs/multi-domain-example .env # Masterfile diff --git a/server/src/configs/multi-domain-example/README.md b/server/src/configs/multi-domain-example/README.md new file mode 100644 index 000000000..38ae998ff --- /dev/null +++ b/server/src/configs/multi-domain-example/README.md @@ -0,0 +1,73 @@ +# Multi Domain Setup + +## Overview +- This makes use of the `NODE_CONFIG_ENV` env variable to determine which `local.json` files to load +- Loads `default.json` => `local.json` => `local-{NODE_CONFIG_ENV}`.json +- You set all of your base defaults in `local.json` still, then set things that are unique to those domains, such `geoJsonFilename` or authentication strategies in each of the domain specifics jsons +- The `NODE_CONFIG_ENV` var names should not contain `/` or `.` + +## File System +```js +// please note that this all goes in the parent `config` folder, not this example folder +local.json +local-applemap.json +local-orangemap.json +``` + +## Explanation of Config Files +- `local.json` is the base config file that all other configs will inherit from, it can also be its own map instance if do not set the `NODE_CONFIG_ENV` env variable +- The other files will inherit everything you set in `local.json` and then override any values that are set in the domain specific file +- Such as in `local-applemap.json`, we have set a new title, a separate Discord strategy, and a different geoJsonFilename +- Only config setting you must set in each file is the port, since separate instances of the app will be generated +- In `local-orangemap.json`, we also set a different start Latitude and Longitude and have disabled some various features that we do not want on that map. In `local.json`, we had set `alwaysEnabledPerms = ["map"]`, however, for orangemap we have overridden that by providing an empty array. +- The databases specified in `local.json` will be used in all 3 maps, as will all of the permissions. + +## New PM2 `ecosystem.config.js` Example +```js +module.exports = { + apps: [ + { + name: 'ReactMap', + script: 'ReactMap.js', + instances: 1, + autorestart: true, + exec_mode: 'fork', + max_memory_restart: '2G', + }, + { + name: 'AppleMap', + script: 'ReactMap.js', + instances: 1, + autorestart: true, + exec_mode: 'fork', + max_memory_restart: '2G', + env: { + NODE_CONFIG_ENV: 'applemap', + }, + }, + { + name: 'OrangeMap', + script: 'ReactMap.js', + instances: 1, + autorestart: true, + exec_mode: 'fork', + max_memory_restart: '2G', + env: { + NODE_CONFIG_ENV: 'orangemap', + }, + }, + ], +} +``` + +```sh +# Start the app with the following command +pm2 start ecosystem.config.js +``` + +## Other Notes + +- Be sure to view the `nginx` file to see how to set up the reverse proxy for the different domains +- The domains do not have to be subdomains of each other, they can be whatever you want, they are just used to differentitate the different configs +- The `NODE_CONFIG_ENV` var names should not contain `/` or `.` +- The `NODE_CONFIG_ENV` value does not have to be related to the domain its representing. The URL for the map could be `https://www.my-super-map.com` and the `NODE_CONFIG_ENV` could be `applemap` or `orangemap` or `bananamap` or whatever you want, as long as you point the nginx reverse proxy to the correct instance of the app \ No newline at end of file diff --git a/server/src/configs/multi-domain-example/local-applemap.json b/server/src/configs/multi-domain-example/local-applemap.json new file mode 100644 index 000000000..57a7d442b --- /dev/null +++ b/server/src/configs/multi-domain-example/local-applemap.json @@ -0,0 +1,33 @@ +{ + "port": 8081, + "map": { + "general": { + "title": "Apple Map", + "headerTitle": "Apple Map PoGo", + "geoJsonFilName": "http://koji.map.com/api/v1/geofence/feature-collection/apple" + }, + "links": { + "discordInvite": "apple map invite", + "rolesLink": "apple map roles link" + } + }, + "authentication": { + "strategies": [ + { + "name": "this is your discord strategy for apple map", + "enabled": false, + "type": "discord", + "logChannelId": "", + "presence": "Map Status: Online", + "presenceType": 3, + "botToken": "", + "clientId": "", + "clientSecret": "", + "redirectUri": "http://localhost:8081/auth/discord/callback", + "allowedGuilds": [], + "blockedGuilds": [], + "allowedUsers": [] + } + ] + } +} \ No newline at end of file diff --git a/server/src/configs/multi-domain-example/local-orangemap.json b/server/src/configs/multi-domain-example/local-orangemap.json new file mode 100644 index 000000000..559f54420 --- /dev/null +++ b/server/src/configs/multi-domain-example/local-orangemap.json @@ -0,0 +1,39 @@ +{ + "port": 8082, + "map": { + "general": { + "title": "Orange Map", + "headerTitle": "Orange Map", + "startLat": 67.2512, + "startLon": -25.9667, + "geoJsonFilName": "http://koji.map.com/api/v1/geofence/feature-collection/orange" + }, + "misc": { + "enableMapJsFilter": false, + "enablePokemonPopupCoordsSelector": false, + "enableGymPopupCoordsSelector": false, + "enablePokestopPopupCoordsSelector": false, + "enablePortalPopupCoordsSelector": false + } + }, + "authentication": { + "strategies": [ + { + "name": "this is your discord strategy for orange map", + "enabled": false, + "type": "discord", + "logChannelId": "", + "presence": "Map Status: Online", + "presenceType": 3, + "botToken": "", + "clientId": "", + "clientSecret": "", + "redirectUri": "http://localhost:8082/auth/discord/callback", + "allowedGuilds": [], + "blockedGuilds": [], + "allowedUsers": [] + } + ], + "alwaysEnabledPerms": [] + } +} \ No newline at end of file diff --git a/server/src/configs/multi-domain-example/local.json b/server/src/configs/multi-domain-example/local.json new file mode 100644 index 000000000..fd7c7d379 --- /dev/null +++ b/server/src/configs/multi-domain-example/local.json @@ -0,0 +1,150 @@ +{ + "interface": "0.0.0.0", + "port": 8080, + "api": { + "reactMapSecret": "very-secure-secret", + "maxSessions": 5, + "pvp": { + "reactMapHandlesPvp": false + } + }, + "map": { + "general": { + "title": "ReactMap", + "headerTitle": "ReactMap", + "startLat": 2.5014, + "startLon": 5.6362 + }, + "misc": { + "enableMapJsFilter": true, + "enablePokemonPopupCoordsSelector": true, + "enableGymPopupCoordsSelector": true, + "enablePokestopPopupCoordsSelector": true, + "enablePortalPopupCoordsSelector": true + } + }, + "database": { + "schemas": [ + { + "note": "Scanner Database", + "host": "127.0.0.1", + "port": 3306, + "username": "scanner_user", + "password": "scanner_paw", + "database": "scanner_db", + "useFor": [ + "device", + "gym", + "pokemon", + "pokestop", + "scanCell", + "spawnpoint", + "weather", + "route" + ] + }, + { + "type": "golbat", + "endpoint": "http://127.0.0.1:9001", + "secret": "", + "useFor": [ + "pokemon", + "device" + ] + }, + { + "host": "127.0.0.1", + "port": 3306, + "username": "reactmap_user", + "password": "reactmap_paw", + "database": "reactmap_db", + "useFor": [ + "user" + ] + }, + { + "host": "127.0.0.1", + "port": 3306, + "username": "manual_user", + "password": "manual_pw", + "database": "manual_db", + "useFor": [ + "nest", + "portal" + ] + } + ] + }, + "authentication": { + "strategies": [ + { + "name": "this is your discord strategy for the base config (no NODE_CONFIG_ENV set)", + "enabled": false, + "type": "discord", + "logChannelId": "", + "presence": "Map Status: Online", + "presenceType": 3, + "botToken": "", + "clientId": "", + "clientSecret": "", + "redirectUri": "http://localhost:8080/auth/discord/callback", + "allowedGuilds": [], + "blockedGuilds": [], + "allowedUsers": [] + } + ], + "alwaysEnabledPerms": [ + "map" + ], + "perms": { + "map": { + "enabled": true, + "trialPeriodEligible": false, + "roles": [] + }, + "pokemon": { + "enabled": true, + "trialPeriodEligible": false, + "roles": [ + "role1", + "role2", + "role3" + ] + }, + "iv": { + "enabled": true, + "trialPeriodEligible": false, + "roles": [ + "role1", + "role2", + "role3" + ] + }, + "pvp": { + "enabled": true, + "trialPeriodEligible": false, + "roles": [ + "role1", + "role2" + ] + }, + "gyms": { + "enabled": true, + "trialPeriodEligible": false, + "roles": [ + "role1", + "role2", + "role3", + "role4" + ] + }, + "raids": { + "enabled": true, + "trialPeriodEligible": false, + "roles": [ + "role3" + ] + } + } + } +} \ No newline at end of file diff --git a/server/src/configs/multi-domain-example/nginx b/server/src/configs/multi-domain-example/nginx new file mode 100644 index 000000000..a9b0ad698 --- /dev/null +++ b/server/src/configs/multi-domain-example/nginx @@ -0,0 +1,47 @@ +server { + listen 80; + listen [::]:80; + + mymap.com; + + location / { + proxy_pass http://127.0.0.1:8080/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_request_buffering off; + proxy_buffering off; + proxy_set_header Connection keep-alive; + } +} + +server { + listen 80; + listen [::]:80; + + applemap.com; + + location / { + proxy_pass http://127.0.0.1:8081/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_request_buffering off; + proxy_buffering off; + proxy_set_header Connection keep-alive; + } +} + +server { + listen 80; + listen [::]:80; + + orangemap.com; + + location / { + proxy_pass http://127.0.0.1:8082/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_request_buffering off; + proxy_buffering off; + proxy_set_header Connection keep-alive; + } +} From ef30f33c18146b2f14584e3639162cce16cc78a0 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 23 Feb 2024 17:45:24 -0500 Subject: [PATCH 008/177] fix: reading other config files --- server/src/services/functions/checkConfigJsons.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/services/functions/checkConfigJsons.js b/server/src/services/functions/checkConfigJsons.js index 63dc9b904..06b9fbb11 100644 --- a/server/src/services/functions/checkConfigJsons.js +++ b/server/src/services/functions/checkConfigJsons.js @@ -10,7 +10,10 @@ const { log, HELPERS } = require('@rm/logger') * @param {string} [domain] * @returns */ -function checkConfigJsons(fileName, domain = '') { +function checkConfigJsons( + fileName, + domain = process.env.NODE_CONFIG_ENV || '', +) { const generalJson = fs.existsSync( resolve(`${__dirname}/../../configs/${fileName}.json`), ) From 185150552e47980f91a5a257906ccb9b478a4dce Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 23 Feb 2024 18:00:49 -0500 Subject: [PATCH 009/177] fix: favicon instructions --- server/src/configs/multi-domain-example/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/configs/multi-domain-example/README.md b/server/src/configs/multi-domain-example/README.md index 38ae998ff..45c3d25bf 100644 --- a/server/src/configs/multi-domain-example/README.md +++ b/server/src/configs/multi-domain-example/README.md @@ -70,4 +70,5 @@ pm2 start ecosystem.config.js - Be sure to view the `nginx` file to see how to set up the reverse proxy for the different domains - The domains do not have to be subdomains of each other, they can be whatever you want, they are just used to differentitate the different configs - The `NODE_CONFIG_ENV` var names should not contain `/` or `.` -- The `NODE_CONFIG_ENV` value does not have to be related to the domain its representing. The URL for the map could be `https://www.my-super-map.com` and the `NODE_CONFIG_ENV` could be `applemap` or `orangemap` or `bananamap` or whatever you want, as long as you point the nginx reverse proxy to the correct instance of the app \ No newline at end of file +- The `NODE_CONFIG_ENV` value does not have to be related to the domain its representing. The URL for the map could be `https://www.my-super-map.com` and the `NODE_CONFIG_ENV` could be `applemap` or `orangemap` or `bananamap` or whatever you want, as long as you point the nginx reverse proxy to the correct instance of the app +- Custom favicons can be set by putting the respective `{NODE_CONFIG_ENV}.ico` in the `public/favicon` folder \ No newline at end of file From 8330adfcf918d090ddf30571d831af4da0a36c77 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 14:32:09 -0500 Subject: [PATCH 010/177] refactor: rename `features` folder to `pages` --- src/components/ReactRouter.jsx | 6 +++--- src/{features => pages}/data/components/Notification.jsx | 0 src/{features => pages}/data/components/ResetFilters.jsx | 0 src/{features => pages}/data/components/ResetGeneral.jsx | 0 src/{features => pages}/data/components/Shared.jsx | 0 src/{features => pages}/data/components/TopRow.jsx | 0 src/{features => pages}/data/hooks/store.js | 0 src/{features => pages}/data/index.jsx | 0 src/{features => pages}/login/CustomPage.jsx | 0 src/{features => pages}/login/DefaultPage.jsx | 0 src/{features => pages}/login/Methods.jsx | 0 src/{features => pages}/login/index.jsx | 0 .../playground/components/ComponentMenu.jsx | 0 src/{features => pages}/playground/components/Download.jsx | 0 src/{features => pages}/playground/components/Editor.jsx | 0 .../playground/components/LocaleMenu.jsx | 0 src/{features => pages}/playground/components/MainMenu.jsx | 0 src/{features => pages}/playground/components/Save.jsx | 0 src/{features => pages}/playground/components/Status.jsx | 0 src/{features => pages}/playground/components/Theme.jsx | 0 .../playground/components/ToggleEditor.jsx | 0 src/{features => pages}/playground/components/Toolbar.jsx | 0 src/{features => pages}/playground/components/Viewer.jsx | 0 src/{features => pages}/playground/hooks/store.js | 0 src/{features => pages}/playground/hooks/useSafeParse.js | 0 src/{features => pages}/playground/index.jsx | 0 26 files changed, 3 insertions(+), 3 deletions(-) rename src/{features => pages}/data/components/Notification.jsx (100%) rename src/{features => pages}/data/components/ResetFilters.jsx (100%) rename src/{features => pages}/data/components/ResetGeneral.jsx (100%) rename src/{features => pages}/data/components/Shared.jsx (100%) rename src/{features => pages}/data/components/TopRow.jsx (100%) rename src/{features => pages}/data/hooks/store.js (100%) rename src/{features => pages}/data/index.jsx (100%) rename src/{features => pages}/login/CustomPage.jsx (100%) rename src/{features => pages}/login/DefaultPage.jsx (100%) rename src/{features => pages}/login/Methods.jsx (100%) rename src/{features => pages}/login/index.jsx (100%) rename src/{features => pages}/playground/components/ComponentMenu.jsx (100%) rename src/{features => pages}/playground/components/Download.jsx (100%) rename src/{features => pages}/playground/components/Editor.jsx (100%) rename src/{features => pages}/playground/components/LocaleMenu.jsx (100%) rename src/{features => pages}/playground/components/MainMenu.jsx (100%) rename src/{features => pages}/playground/components/Save.jsx (100%) rename src/{features => pages}/playground/components/Status.jsx (100%) rename src/{features => pages}/playground/components/Theme.jsx (100%) rename src/{features => pages}/playground/components/ToggleEditor.jsx (100%) rename src/{features => pages}/playground/components/Toolbar.jsx (100%) rename src/{features => pages}/playground/components/Viewer.jsx (100%) rename src/{features => pages}/playground/hooks/store.js (100%) rename src/{features => pages}/playground/hooks/useSafeParse.js (100%) rename src/{features => pages}/playground/index.jsx (100%) diff --git a/src/components/ReactRouter.jsx b/src/components/ReactRouter.jsx index 6981b81c6..ffee40e48 100644 --- a/src/components/ReactRouter.jsx +++ b/src/components/ReactRouter.jsx @@ -3,14 +3,14 @@ import * as React from 'react' import { Route, Routes } from 'react-router-dom' import Auth from './layout/auth/Auth' -import LoginPage from '../features/login' +import LoginPage from '../pages/login' import Blocked from './layout/auth/Blocked' import Errors from './Errors' -import DataManagement from '../features/data' +import DataManagement from '../pages/data' import Config from './Config' import ResetAll from './Reset' -const Playground = React.lazy(() => import('../features/playground')) +const Playground = React.lazy(() => import('../pages/playground')) const authRoute = ( diff --git a/src/features/data/components/Notification.jsx b/src/pages/data/components/Notification.jsx similarity index 100% rename from src/features/data/components/Notification.jsx rename to src/pages/data/components/Notification.jsx diff --git a/src/features/data/components/ResetFilters.jsx b/src/pages/data/components/ResetFilters.jsx similarity index 100% rename from src/features/data/components/ResetFilters.jsx rename to src/pages/data/components/ResetFilters.jsx diff --git a/src/features/data/components/ResetGeneral.jsx b/src/pages/data/components/ResetGeneral.jsx similarity index 100% rename from src/features/data/components/ResetGeneral.jsx rename to src/pages/data/components/ResetGeneral.jsx diff --git a/src/features/data/components/Shared.jsx b/src/pages/data/components/Shared.jsx similarity index 100% rename from src/features/data/components/Shared.jsx rename to src/pages/data/components/Shared.jsx diff --git a/src/features/data/components/TopRow.jsx b/src/pages/data/components/TopRow.jsx similarity index 100% rename from src/features/data/components/TopRow.jsx rename to src/pages/data/components/TopRow.jsx diff --git a/src/features/data/hooks/store.js b/src/pages/data/hooks/store.js similarity index 100% rename from src/features/data/hooks/store.js rename to src/pages/data/hooks/store.js diff --git a/src/features/data/index.jsx b/src/pages/data/index.jsx similarity index 100% rename from src/features/data/index.jsx rename to src/pages/data/index.jsx diff --git a/src/features/login/CustomPage.jsx b/src/pages/login/CustomPage.jsx similarity index 100% rename from src/features/login/CustomPage.jsx rename to src/pages/login/CustomPage.jsx diff --git a/src/features/login/DefaultPage.jsx b/src/pages/login/DefaultPage.jsx similarity index 100% rename from src/features/login/DefaultPage.jsx rename to src/pages/login/DefaultPage.jsx diff --git a/src/features/login/Methods.jsx b/src/pages/login/Methods.jsx similarity index 100% rename from src/features/login/Methods.jsx rename to src/pages/login/Methods.jsx diff --git a/src/features/login/index.jsx b/src/pages/login/index.jsx similarity index 100% rename from src/features/login/index.jsx rename to src/pages/login/index.jsx diff --git a/src/features/playground/components/ComponentMenu.jsx b/src/pages/playground/components/ComponentMenu.jsx similarity index 100% rename from src/features/playground/components/ComponentMenu.jsx rename to src/pages/playground/components/ComponentMenu.jsx diff --git a/src/features/playground/components/Download.jsx b/src/pages/playground/components/Download.jsx similarity index 100% rename from src/features/playground/components/Download.jsx rename to src/pages/playground/components/Download.jsx diff --git a/src/features/playground/components/Editor.jsx b/src/pages/playground/components/Editor.jsx similarity index 100% rename from src/features/playground/components/Editor.jsx rename to src/pages/playground/components/Editor.jsx diff --git a/src/features/playground/components/LocaleMenu.jsx b/src/pages/playground/components/LocaleMenu.jsx similarity index 100% rename from src/features/playground/components/LocaleMenu.jsx rename to src/pages/playground/components/LocaleMenu.jsx diff --git a/src/features/playground/components/MainMenu.jsx b/src/pages/playground/components/MainMenu.jsx similarity index 100% rename from src/features/playground/components/MainMenu.jsx rename to src/pages/playground/components/MainMenu.jsx diff --git a/src/features/playground/components/Save.jsx b/src/pages/playground/components/Save.jsx similarity index 100% rename from src/features/playground/components/Save.jsx rename to src/pages/playground/components/Save.jsx diff --git a/src/features/playground/components/Status.jsx b/src/pages/playground/components/Status.jsx similarity index 100% rename from src/features/playground/components/Status.jsx rename to src/pages/playground/components/Status.jsx diff --git a/src/features/playground/components/Theme.jsx b/src/pages/playground/components/Theme.jsx similarity index 100% rename from src/features/playground/components/Theme.jsx rename to src/pages/playground/components/Theme.jsx diff --git a/src/features/playground/components/ToggleEditor.jsx b/src/pages/playground/components/ToggleEditor.jsx similarity index 100% rename from src/features/playground/components/ToggleEditor.jsx rename to src/pages/playground/components/ToggleEditor.jsx diff --git a/src/features/playground/components/Toolbar.jsx b/src/pages/playground/components/Toolbar.jsx similarity index 100% rename from src/features/playground/components/Toolbar.jsx rename to src/pages/playground/components/Toolbar.jsx diff --git a/src/features/playground/components/Viewer.jsx b/src/pages/playground/components/Viewer.jsx similarity index 100% rename from src/features/playground/components/Viewer.jsx rename to src/pages/playground/components/Viewer.jsx diff --git a/src/features/playground/hooks/store.js b/src/pages/playground/hooks/store.js similarity index 100% rename from src/features/playground/hooks/store.js rename to src/pages/playground/hooks/store.js diff --git a/src/features/playground/hooks/useSafeParse.js b/src/pages/playground/hooks/useSafeParse.js similarity index 100% rename from src/features/playground/hooks/useSafeParse.js rename to src/pages/playground/hooks/useSafeParse.js diff --git a/src/features/playground/index.jsx b/src/pages/playground/index.jsx similarity index 100% rename from src/features/playground/index.jsx rename to src/pages/playground/index.jsx From 89a6d39fc9f8a058d1d088d0423975187376cd4e Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 14:36:52 -0500 Subject: [PATCH 011/177] refactor: move all page components to pages folder --- src/components/App.jsx | 2 +- .../layout/auth => pages}/Blocked.jsx | 8 ++--- .../Errors.jsx => pages/Error.jsx} | 2 +- src/{components => pages}/Reset.jsx | 2 +- .../ReactRouter.jsx => pages/index.jsx} | 36 +++++++++---------- .../auth/Auth.jsx => pages/map/index.jsx} | 6 ++-- src/pages/playground/index.jsx | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) rename src/{components/layout/auth => pages}/Blocked.jsx (93%) rename src/{components/Errors.jsx => pages/Error.jsx} (96%) rename src/{components => pages}/Reset.jsx (83%) rename src/{components/ReactRouter.jsx => pages/index.jsx} (52%) rename src/{components/layout/auth/Auth.jsx => pages/map/index.jsx} (86%) diff --git a/src/components/App.jsx b/src/components/App.jsx index 0e8f581c5..07a89c547 100644 --- a/src/components/App.jsx +++ b/src/components/App.jsx @@ -17,7 +17,7 @@ import { setLoadingText } from '@services/functions/setLoadingText' import '@services/events' import ErrorBoundary from './ErrorBoundary' -import ReactRouter from './ReactRouter' +import ReactRouter from '../pages' import HolidayEffects from './HolidayEffects' const LOADING_LOCALES = { diff --git a/src/components/layout/auth/Blocked.jsx b/src/pages/Blocked.jsx similarity index 93% rename from src/components/layout/auth/Blocked.jsx rename to src/pages/Blocked.jsx index 548b26f1f..c8b9afed6 100644 --- a/src/components/layout/auth/Blocked.jsx +++ b/src/pages/Blocked.jsx @@ -17,11 +17,11 @@ import ListItemText from '@mui/material/ListItemText' import { useMemory } from '@hooks/useMemory' -import DiscordButton from './Discord' -import ThemeToggle from '../general/ThemeToggle' -import { I } from '../general/I' +import DiscordButton from '@components/layout/auth/Discord' +import ThemeToggle from '@components/layout/general/ThemeToggle' +import { I } from '@components/layout/general/I' -export default function Blocked() { +export default function BlockedPage() { const { t } = useTranslation() const { info } = useParams() const navigate = useNavigate() diff --git a/src/components/Errors.jsx b/src/pages/Error.jsx similarity index 96% rename from src/components/Errors.jsx rename to src/pages/Error.jsx index 3d779ea0d..aa14779ea 100644 --- a/src/components/Errors.jsx +++ b/src/pages/Error.jsx @@ -6,7 +6,7 @@ import Button from '@mui/material/Button' import { useTranslation } from 'react-i18next' import { useHideElement } from '@hooks/useHideElement' -export default function Errors() { +export default function ErrorPage() { const { t } = useTranslation() const error = window.location.href.split('/').pop() useHideElement() diff --git a/src/components/Reset.jsx b/src/pages/Reset.jsx similarity index 83% rename from src/components/Reset.jsx rename to src/pages/Reset.jsx index a67888b32..449914b0a 100644 --- a/src/components/Reset.jsx +++ b/src/pages/Reset.jsx @@ -4,7 +4,7 @@ import { Navigate } from 'react-router-dom' import { hardReset } from '@services/functions/resetState' -export default function ResetAll() { +export default function ResetPage() { hardReset() return } diff --git a/src/components/ReactRouter.jsx b/src/pages/index.jsx similarity index 52% rename from src/components/ReactRouter.jsx rename to src/pages/index.jsx index ffee40e48..fe7ac2998 100644 --- a/src/components/ReactRouter.jsx +++ b/src/pages/index.jsx @@ -2,19 +2,19 @@ import * as React from 'react' import { Route, Routes } from 'react-router-dom' -import Auth from './layout/auth/Auth' -import LoginPage from '../pages/login' -import Blocked from './layout/auth/Blocked' -import Errors from './Errors' -import DataManagement from '../pages/data' -import Config from './Config' -import ResetAll from './Reset' +import MapPage from './map' +import LoginPage from './login' +import BlockedPage from './Blocked' +import ErrorPage from './Error' +import DataManagement from './data' +import Config from '../components/Config' +import ResetPage from './Reset' -const Playground = React.lazy(() => import('../pages/playground')) +const Playground = React.lazy(() => import('./playground')) -const authRoute = ( +const mapRoute = ( - + ) const loginRoute = ( @@ -29,7 +29,7 @@ const dataRoute = ( ) const blockedRoute = ( - + ) const playgroundRoute = ( @@ -37,22 +37,22 @@ const playgroundRoute = ( ) -const errorRoute = -const resetRoute = +const errorRoute = +const resetRoute = export default function ReactRouter() { return ( - + - - - - + + + + ) diff --git a/src/components/layout/auth/Auth.jsx b/src/pages/map/index.jsx similarity index 86% rename from src/components/layout/auth/Auth.jsx rename to src/pages/map/index.jsx index 61ea8175a..331c5ae17 100644 --- a/src/components/layout/auth/Auth.jsx +++ b/src/pages/map/index.jsx @@ -4,10 +4,10 @@ import { Navigate, useParams } from 'react-router-dom' import { useMemory } from '@hooks/useMemory' -import Container from '../../Container' -import WebhookQuery from '../../WebhookQuery' +import Container from '../../components/Container' +import WebhookQuery from '../../components/WebhookQuery' -export default function Auth() { +export default function MapPage() { const params = useParams() const mapPerm = useMemory((s) => s.auth.perms.map) diff --git a/src/pages/playground/index.jsx b/src/pages/playground/index.jsx index 90ec765b3..5effa5507 100644 --- a/src/pages/playground/index.jsx +++ b/src/pages/playground/index.jsx @@ -12,7 +12,7 @@ import { MuiToolbar } from './components/Toolbar' import { Viewer } from './components/Viewer' import { StatusNotification } from './components/Status' -export default function Playground() { +export default function PlaygroundPage() { const { data } = useQuery(VALIDATE_USER) if (data?.validateUser === undefined) return null From c5578bf2a2a4178e2cb814530073138bb25092ff Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 14:59:16 -0500 Subject: [PATCH 012/177] refactor: move main map components to map page folder --- src/{ => pages/map}/components/Clustering.jsx | 2 +- src/{ => pages/map}/components/Container.jsx | 16 ++++++++-------- .../Map.jsx => pages/map/components/Data.jsx} | 2 +- src/{ => pages/map}/components/Layers.jsx | 0 src/{ => pages/map}/components/QueryData.jsx | 6 +++--- src/{ => pages/map}/components/WebhookQuery.jsx | 0 src/pages/map/index.jsx | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) rename src/{ => pages/map}/components/Clustering.jsx (98%) rename src/{ => pages/map}/components/Container.jsx (77%) rename src/{components/Map.jsx => pages/map/components/Data.jsx} (97%) rename src/{ => pages/map}/components/Layers.jsx (100%) rename src/{ => pages/map}/components/QueryData.jsx (96%) rename src/{ => pages/map}/components/WebhookQuery.jsx (100%) diff --git a/src/components/Clustering.jsx b/src/pages/map/components/Clustering.jsx similarity index 98% rename from src/components/Clustering.jsx rename to src/pages/map/components/Clustering.jsx index 3d8d85390..888b913e0 100644 --- a/src/components/Clustering.jsx +++ b/src/pages/map/components/Clustering.jsx @@ -5,7 +5,7 @@ import Supercluster from 'supercluster' import { marker, divIcon, point } from 'leaflet' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import Notification from './layout/general/Notification' +import Notification from '../../../components/layout/general/Notification' const IGNORE_CLUSTERING = new Set([ 'devices', diff --git a/src/components/Container.jsx b/src/pages/map/components/Container.jsx similarity index 77% rename from src/components/Container.jsx rename to src/pages/map/components/Container.jsx index c5744db4f..403a1751d 100644 --- a/src/components/Container.jsx +++ b/src/pages/map/components/Container.jsx @@ -7,18 +7,18 @@ import { useStorage } from '@hooks/useStorage' import { useMapStore } from '@hooks/useMapStore' import Utility from '@services/Utility' -import Map from './Map' -import ScanOnDemand from './layout/dialogs/scanner/ScanOnDemand' -import DraggableMarker from './layout/dialogs/webhooks/human/Draggable' -import WebhookAreaSelection from './layout/dialogs/webhooks/human/area/AreaSelection' -import { Nav } from './layout/Nav' -import ActiveWeather from './layout/general/ActiveWeather' +import DataView from './Data' +import ScanOnDemand from '../../../components/layout/dialogs/scanner/ScanOnDemand' +import DraggableMarker from '../../../components/layout/dialogs/webhooks/human/Draggable' +import WebhookAreaSelection from '../../../components/layout/dialogs/webhooks/human/area/AreaSelection' +import { Nav } from '../../../components/layout/Nav' +import ActiveWeather from '../../../components/layout/general/ActiveWeather' import { ControlledLocate, ControlledTileLayer, ControlledZoomLayer, } from './Layers' -import { Effects } from './Effects' +import { Effects } from '../../../components/Effects' /** @param {{ target: import('leaflet').Map, type: string }} args */ function setLocationZoom({ target: map }) { @@ -61,7 +61,7 @@ export default function Container() { - + diff --git a/src/components/Map.jsx b/src/pages/map/components/Data.jsx similarity index 97% rename from src/components/Map.jsx rename to src/pages/map/components/Data.jsx index ef882500a..f7212930c 100644 --- a/src/components/Map.jsx +++ b/src/pages/map/components/Data.jsx @@ -8,7 +8,7 @@ import Utility from '@services/Utility' import FilterPermCheck from './QueryData' -export default function Map() { +export default function DataView() { Utility.analytics(window.location.pathname) const iconsReady = useMemory((s) => !!s.Icons) diff --git a/src/components/Layers.jsx b/src/pages/map/components/Layers.jsx similarity index 100% rename from src/components/Layers.jsx rename to src/pages/map/components/Layers.jsx diff --git a/src/components/QueryData.jsx b/src/pages/map/components/QueryData.jsx similarity index 96% rename from src/components/QueryData.jsx rename to src/pages/map/components/QueryData.jsx index cd15d1cd7..4e6b54095 100644 --- a/src/components/QueryData.jsx +++ b/src/pages/map/components/QueryData.jsx @@ -12,10 +12,10 @@ import RobustTimeout from '@services/apollo/RobustTimeout' import Utility from '@services/Utility' import { FILTER_SKIP_LIST } from '@assets/constants' -import * as index from './tiles/index' +import * as index from '../../../components/tiles/index' import Clustering from './Clustering' -import Notification from './layout/general/Notification' -import { GenerateCells } from './tiles/S2Cell' +import Notification from '../../../components/layout/general/Notification' +import { GenerateCells } from '../../../components/tiles/S2Cell' /** @param {string} category */ const userSettingsCategory = (category) => { diff --git a/src/components/WebhookQuery.jsx b/src/pages/map/components/WebhookQuery.jsx similarity index 100% rename from src/components/WebhookQuery.jsx rename to src/pages/map/components/WebhookQuery.jsx diff --git a/src/pages/map/index.jsx b/src/pages/map/index.jsx index 331c5ae17..a8356f8c2 100644 --- a/src/pages/map/index.jsx +++ b/src/pages/map/index.jsx @@ -4,8 +4,8 @@ import { Navigate, useParams } from 'react-router-dom' import { useMemory } from '@hooks/useMemory' -import Container from '../../components/Container' -import WebhookQuery from '../../components/WebhookQuery' +import Container from './components/Container' +import WebhookQuery from './components/WebhookQuery' export default function MapPage() { const params = useParams() From da93ac426dad52e8f4925d83672bfb1002217201 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:01:57 -0500 Subject: [PATCH 013/177] refactor: move app component to src --- src/{components => }/App.jsx | 6 +++--- src/index.jsx | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) rename src/{components => }/App.jsx (93%) diff --git a/src/components/App.jsx b/src/App.jsx similarity index 93% rename from src/components/App.jsx rename to src/App.jsx index 07a89c547..7408ee795 100644 --- a/src/components/App.jsx +++ b/src/App.jsx @@ -15,10 +15,10 @@ import { apolloClient } from '@services/apollo' import { isLocalStorageEnabled } from '@services/functions/isLocalStorageEnabled' import { setLoadingText } from '@services/functions/setLoadingText' import '@services/events' +import ErrorBoundary from '@components/ErrorBoundary' +import HolidayEffects from '@components/HolidayEffects' -import ErrorBoundary from './ErrorBoundary' -import ReactRouter from '../pages' -import HolidayEffects from './HolidayEffects' +import ReactRouter from './pages' const LOADING_LOCALES = { de: 'Übersetzungen werden geladen', diff --git a/src/index.jsx b/src/index.jsx index e848e6d82..12c59251c 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -6,7 +6,8 @@ import ReactGA from 'react-ga4' // Sentry must be imported before app import '@services/Sentry' import '@services/i18n' -import App from '@components/App' + +import App from './App' if (CONFIG.googleAnalyticsId) { ReactGA.initialize(CONFIG.googleAnalyticsId) From 4793b5a918df71ded3df24fcb75289ba00ee2721 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:09:02 -0500 Subject: [PATCH 014/177] refactor: move more map components into page folder --- src/components/layout/Nav.jsx | 61 ------------------- .../map/components}/ActiveWeather.jsx | 9 ++- src/pages/map/components/Container.jsx | 4 +- .../map/components}/FloatingBtn.jsx | 9 ++- src/pages/map/components/Nav.jsx | 61 +++++++++++++++++++ 5 files changed, 73 insertions(+), 71 deletions(-) delete mode 100644 src/components/layout/Nav.jsx rename src/{components/layout/general => pages/map/components}/ActiveWeather.jsx (92%) rename src/{components/layout => pages/map/components}/FloatingBtn.jsx (97%) create mode 100644 src/pages/map/components/Nav.jsx diff --git a/src/components/layout/Nav.jsx b/src/components/layout/Nav.jsx deleted file mode 100644 index 6b2b740fc..000000000 --- a/src/components/layout/Nav.jsx +++ /dev/null @@ -1,61 +0,0 @@ -import * as React from 'react' - -import { useMemory } from '@hooks/useMemory' - -import { FloatingButtonsMemo } from './FloatingBtn' -import Sidebar from './drawer/Drawer' -import FilterMenu from './dialogs/filters/FilterMenu' -import UserOptions from './dialogs/UserOptions' -import Tutorial from './dialogs/tutorial/Tutorial' -import UserProfile from './dialogs/profile' -import Search from './dialogs/search' -import MessageOfTheDay from './dialogs/Motd' -import DonorPage from './dialogs/DonorPage' -import Feedback from './dialogs/Feedback' -import ResetFilters from './dialogs/ResetFilters' -import ScanDialog from './dialogs/scanner/ScanDialog' -import Webhook from './dialogs/webhooks/Webhook' -import ClientError from './dialogs/ClientError' -import { WebhookNotification } from './dialogs/webhooks/Notification' -import AdvancedFilter from './dialogs/filters/Advanced' -import BadgeSelection from './dialogs/BadgeSelection' -import WebhookAdvanced from './dialogs/webhooks/WebhookAdv' -import SlotSelection from './dialogs/filters/SlotSelection' -import { HelpDialog } from './dialogs/Help' -import { PkmnFilterHelp } from './dialogs/filters/PkmnFilterHelp' - -export const Nav = React.memo( - () => { - const iconsIsReady = useMemory((s) => !!s.Icons) - return ( - <> - - {iconsIsReady && ( - <> - - - - - - - - - - - - - - - - - - - - - - )} - - ) - }, - () => true, -) diff --git a/src/components/layout/general/ActiveWeather.jsx b/src/pages/map/components/ActiveWeather.jsx similarity index 92% rename from src/components/layout/general/ActiveWeather.jsx rename to src/pages/map/components/ActiveWeather.jsx index 91adc5a52..5085631be 100644 --- a/src/components/layout/general/ActiveWeather.jsx +++ b/src/pages/map/components/ActiveWeather.jsx @@ -12,10 +12,9 @@ import WeatherPopup from '@components/popups/Weather' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { apolloClient } from '@services/apollo' - -import Header from './Header' -import Footer from './Footer' -import { Img } from './Img' +import Header from '@components/layout/general/Header' +import Footer from '@components/layout/general/Footer' +import { Img } from '@components/layout/general/Img' const StyledBox = styled(Box)(({ theme }) => ({ zIndex: 1000, @@ -68,7 +67,7 @@ export default function ActiveWeather() { const footerOptions = React.useMemo( () => - /** @type {import('./Footer').FooterButton[]} */ ([ + /** @type {import('../../../components/layout/general/Footer').FooterButton[]} */ ([ { name: 'close', action: () => setOpen(false), diff --git a/src/pages/map/components/Container.jsx b/src/pages/map/components/Container.jsx index 403a1751d..664ff0e2c 100644 --- a/src/pages/map/components/Container.jsx +++ b/src/pages/map/components/Container.jsx @@ -11,8 +11,8 @@ import DataView from './Data' import ScanOnDemand from '../../../components/layout/dialogs/scanner/ScanOnDemand' import DraggableMarker from '../../../components/layout/dialogs/webhooks/human/Draggable' import WebhookAreaSelection from '../../../components/layout/dialogs/webhooks/human/area/AreaSelection' -import { Nav } from '../../../components/layout/Nav' -import ActiveWeather from '../../../components/layout/general/ActiveWeather' +import { Nav } from './Nav' +import ActiveWeather from './ActiveWeather' import { ControlledLocate, ControlledTileLayer, diff --git a/src/components/layout/FloatingBtn.jsx b/src/pages/map/components/FloatingBtn.jsx similarity index 97% rename from src/components/layout/FloatingBtn.jsx rename to src/pages/map/components/FloatingBtn.jsx index 3a70d06e2..74faf6d71 100644 --- a/src/components/layout/FloatingBtn.jsx +++ b/src/pages/map/components/FloatingBtn.jsx @@ -29,10 +29,13 @@ import useLocation from '@hooks/useLocation' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' -import { useScanStore } from './dialogs/scanner/store' +import { useScanStore } from '@components/layout/dialogs/scanner/store' -import { I } from './general/I' -import { setModeBtn, useWebhookStore } from './dialogs/webhooks/store' +import { I } from '@components/layout/general/I' +import { + setModeBtn, + useWebhookStore, +} from '@components/layout/dialogs/webhooks/store' /** @typedef {keyof ReturnType | keyof ReturnType} Keys */ diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx new file mode 100644 index 000000000..a720b08dc --- /dev/null +++ b/src/pages/map/components/Nav.jsx @@ -0,0 +1,61 @@ +import * as React from 'react' + +import { useMemory } from '@hooks/useMemory' + +import { FloatingButtonsMemo } from './FloatingBtn' +import Sidebar from '../../../components/layout/drawer/Drawer' +import FilterMenu from '../../../components/layout/dialogs/filters/FilterMenu' +import UserOptions from '../../../components/layout/dialogs/UserOptions' +import Tutorial from '../../../components/layout/dialogs/tutorial/Tutorial' +import UserProfile from '../../../components/layout/dialogs/profile' +import Search from '../../../components/layout/dialogs/search' +import MessageOfTheDay from '../../../components/layout/dialogs/Motd' +import DonorPage from '../../../components/layout/dialogs/DonorPage' +import Feedback from '../../../components/layout/dialogs/Feedback' +import ResetFilters from '../../../components/layout/dialogs/ResetFilters' +import ScanDialog from '../../../components/layout/dialogs/scanner/ScanDialog' +import Webhook from '../../../components/layout/dialogs/webhooks/Webhook' +import ClientError from '../../../components/layout/dialogs/ClientError' +import { WebhookNotification } from '../../../components/layout/dialogs/webhooks/Notification' +import AdvancedFilter from '../../../components/layout/dialogs/filters/Advanced' +import BadgeSelection from '../../../components/layout/dialogs/BadgeSelection' +import WebhookAdvanced from '../../../components/layout/dialogs/webhooks/WebhookAdv' +import SlotSelection from '../../../components/layout/dialogs/filters/SlotSelection' +import { HelpDialog } from '../../../components/layout/dialogs/Help' +import { PkmnFilterHelp } from '../../../components/layout/dialogs/filters/PkmnFilterHelp' + +export const Nav = React.memo( + () => { + const iconsIsReady = useMemory((s) => !!s.Icons) + return ( + <> + + {iconsIsReady && ( + <> + + + + + + + + + + + + + + + + + + + + + + )} + + ) + }, + () => true, +) From 3df1dea02a236d62fde13c5ab8ff07aa422965f4 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:18:10 -0500 Subject: [PATCH 015/177] refactor: `features` folder --- .eslintrc | 46 ++++--------------- jsconfig.json | 1 + src/components/Config.jsx | 5 +- .../scanner/ContextProvider.jsx | 0 .../dialogs => features}/scanner/Marker.jsx | 0 .../dialogs => features}/scanner/Popup.jsx | 0 .../scanner/ScanDialog.jsx | 0 .../scanner/ScanOnDemand.jsx | 0 .../dialogs => features}/scanner/Shared.jsx | 0 .../scanner/scanNext/PopupContent.jsx | 0 .../scanner/scanNext/getCoords.js | 0 .../scanner/scanNext/index.jsx | 0 .../scanner/scanZone/PopupContent.jsx | 0 .../scanner/scanZone/getCoords.js | 0 .../scanner/scanZone/index.jsx | 0 .../dialogs => features}/scanner/store.js | 0 .../scanner/useCheckValid.js | 0 src/pages/map/components/Container.jsx | 9 ++-- src/{ => pages/map}/components/Effects.jsx | 6 +-- src/pages/map/components/FloatingBtn.jsx | 2 +- src/pages/map/components/Nav.jsx | 40 ++++++++-------- vite.config.js | 3 +- 22 files changed, 43 insertions(+), 69 deletions(-) rename src/{components/layout/dialogs => features}/scanner/ContextProvider.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/Marker.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/Popup.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/ScanDialog.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/ScanOnDemand.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/Shared.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/scanNext/PopupContent.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/scanNext/getCoords.js (100%) rename src/{components/layout/dialogs => features}/scanner/scanNext/index.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/scanZone/PopupContent.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/scanZone/getCoords.js (100%) rename src/{components/layout/dialogs => features}/scanner/scanZone/index.jsx (100%) rename src/{components/layout/dialogs => features}/scanner/store.js (100%) rename src/{components/layout/dialogs => features}/scanner/useCheckValid.js (100%) rename src/{ => pages/map}/components/Effects.jsx (100%) diff --git a/.eslintrc b/.eslintrc index 9e378cdb1..4db5dc269 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,10 +1,5 @@ { - "extends": [ - "airbnb", - "airbnb/rules/react", - "eslint:recommended", - "prettier" - ], + "extends": ["airbnb", "airbnb/rules/react", "eslint:recommended", "prettier"], "parserOptions": { "ecmaVersion": "latest" }, @@ -74,42 +69,19 @@ }, "settings": { "node": { - "extensions": [ - ".mjs", - ".js", - ".jsx", - ".ts", - ".tsx" - ] + "extensions": [".mjs", ".js", ".jsx", ".ts", ".tsx"] }, "import/resolver": { "alias": { "map": [ - [ - "@components", - "./src/components/" - ], - [ - "@services", - "./src/services/" - ], - [ - "@hooks", - "./src/hooks/" - ], - [ - "@assets", - "./src/assets/" - ] + ["@components", "./src/components/"], + ["@features", "./src/features/"], + ["@services", "./src/services/"], + ["@hooks", "./src/hooks/"], + ["@assets", "./src/assets/"] ], - "extensions": [ - ".mjs", - ".js", - ".jsx", - ".ts", - ".tsx" - ] + "extensions": [".mjs", ".js", ".jsx", ".ts", ".tsx"] } } } -} \ No newline at end of file +} diff --git a/jsconfig.json b/jsconfig.json index eee01f5e6..9e23add5a 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -12,6 +12,7 @@ "paths": { "@assets/*": ["./src/assets/*"], "@components/*": ["./src/components/*"], + "@features/*": ["./src/features/*"], "@services/*": ["./src/services/*"], "@hooks/*": ["./src/hooks/*"] } diff --git a/src/components/Config.jsx b/src/components/Config.jsx index fc58e674e..0db3a5332 100644 --- a/src/components/Config.jsx +++ b/src/components/Config.jsx @@ -1,6 +1,7 @@ import * as React from 'react' import { useTranslation } from 'react-i18next' import { setUser } from '@sentry/react' +import { Navigate } from 'react-router-dom' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' @@ -8,12 +9,10 @@ import Fetch from '@services/Fetch' import { setLoadingText } from '@services/functions/setLoadingText' import Utility from '@services/Utility' import { deepMerge } from '@services/functions/deepMerge' -import { Navigate } from 'react-router-dom' import { checkHoliday } from '@services/functions/checkHoliday' import { useHideElement } from '@hooks/useHideElement' import { getGlowRules } from '@services/functions/getGlowRules' - -import { useScannerSessionStorage } from './layout/dialogs/scanner/store' +import { useScannerSessionStorage } from '@features/scanner/store' export default function Config({ children }) { const { t } = useTranslation() diff --git a/src/components/layout/dialogs/scanner/ContextProvider.jsx b/src/features/scanner/ContextProvider.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/ContextProvider.jsx rename to src/features/scanner/ContextProvider.jsx diff --git a/src/components/layout/dialogs/scanner/Marker.jsx b/src/features/scanner/Marker.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/Marker.jsx rename to src/features/scanner/Marker.jsx diff --git a/src/components/layout/dialogs/scanner/Popup.jsx b/src/features/scanner/Popup.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/Popup.jsx rename to src/features/scanner/Popup.jsx diff --git a/src/components/layout/dialogs/scanner/ScanDialog.jsx b/src/features/scanner/ScanDialog.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/ScanDialog.jsx rename to src/features/scanner/ScanDialog.jsx diff --git a/src/components/layout/dialogs/scanner/ScanOnDemand.jsx b/src/features/scanner/ScanOnDemand.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/ScanOnDemand.jsx rename to src/features/scanner/ScanOnDemand.jsx diff --git a/src/components/layout/dialogs/scanner/Shared.jsx b/src/features/scanner/Shared.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/Shared.jsx rename to src/features/scanner/Shared.jsx diff --git a/src/components/layout/dialogs/scanner/scanNext/PopupContent.jsx b/src/features/scanner/scanNext/PopupContent.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/scanNext/PopupContent.jsx rename to src/features/scanner/scanNext/PopupContent.jsx diff --git a/src/components/layout/dialogs/scanner/scanNext/getCoords.js b/src/features/scanner/scanNext/getCoords.js similarity index 100% rename from src/components/layout/dialogs/scanner/scanNext/getCoords.js rename to src/features/scanner/scanNext/getCoords.js diff --git a/src/components/layout/dialogs/scanner/scanNext/index.jsx b/src/features/scanner/scanNext/index.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/scanNext/index.jsx rename to src/features/scanner/scanNext/index.jsx diff --git a/src/components/layout/dialogs/scanner/scanZone/PopupContent.jsx b/src/features/scanner/scanZone/PopupContent.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/scanZone/PopupContent.jsx rename to src/features/scanner/scanZone/PopupContent.jsx diff --git a/src/components/layout/dialogs/scanner/scanZone/getCoords.js b/src/features/scanner/scanZone/getCoords.js similarity index 100% rename from src/components/layout/dialogs/scanner/scanZone/getCoords.js rename to src/features/scanner/scanZone/getCoords.js diff --git a/src/components/layout/dialogs/scanner/scanZone/index.jsx b/src/features/scanner/scanZone/index.jsx similarity index 100% rename from src/components/layout/dialogs/scanner/scanZone/index.jsx rename to src/features/scanner/scanZone/index.jsx diff --git a/src/components/layout/dialogs/scanner/store.js b/src/features/scanner/store.js similarity index 100% rename from src/components/layout/dialogs/scanner/store.js rename to src/features/scanner/store.js diff --git a/src/components/layout/dialogs/scanner/useCheckValid.js b/src/features/scanner/useCheckValid.js similarity index 100% rename from src/components/layout/dialogs/scanner/useCheckValid.js rename to src/features/scanner/useCheckValid.js diff --git a/src/pages/map/components/Container.jsx b/src/pages/map/components/Container.jsx index 664ff0e2c..b6b29ccdb 100644 --- a/src/pages/map/components/Container.jsx +++ b/src/pages/map/components/Container.jsx @@ -7,10 +7,12 @@ import { useStorage } from '@hooks/useStorage' import { useMapStore } from '@hooks/useMapStore' import Utility from '@services/Utility' +import ScanOnDemand from '@features/scanner/ScanOnDemand' +import DraggableMarker from '@components/layout/dialogs/webhooks/human/Draggable' +import WebhookAreaSelection from '@components/layout/dialogs/webhooks/human/area/AreaSelection' +import { Effects } from './Effects' + import DataView from './Data' -import ScanOnDemand from '../../../components/layout/dialogs/scanner/ScanOnDemand' -import DraggableMarker from '../../../components/layout/dialogs/webhooks/human/Draggable' -import WebhookAreaSelection from '../../../components/layout/dialogs/webhooks/human/area/AreaSelection' import { Nav } from './Nav' import ActiveWeather from './ActiveWeather' import { @@ -18,7 +20,6 @@ import { ControlledTileLayer, ControlledZoomLayer, } from './Layers' -import { Effects } from '../../../components/Effects' /** @param {{ target: import('leaflet').Map, type: string }} args */ function setLocationZoom({ target: map }) { diff --git a/src/components/Effects.jsx b/src/pages/map/components/Effects.jsx similarity index 100% rename from src/components/Effects.jsx rename to src/pages/map/components/Effects.jsx index e48e8ec32..ee7a155ec 100644 --- a/src/components/Effects.jsx +++ b/src/pages/map/components/Effects.jsx @@ -1,12 +1,12 @@ import * as React from 'react' +import { useParams } from 'react-router-dom' +import { useMap } from 'react-leaflet' +import { useTranslation } from 'react-i18next' import useMediaQuery from '@mui/material/useMediaQuery' import useGenerate from '@hooks/useGenerate' import useRefresh from '@hooks/useRefresh' import { useMemory } from '@hooks/useMemory' -import { useParams } from 'react-router-dom' -import { useMap } from 'react-leaflet' -import { useTranslation } from 'react-i18next' export function Effects() { const params = useParams() diff --git a/src/pages/map/components/FloatingBtn.jsx b/src/pages/map/components/FloatingBtn.jsx index 74faf6d71..5a5361a30 100644 --- a/src/pages/map/components/FloatingBtn.jsx +++ b/src/pages/map/components/FloatingBtn.jsx @@ -29,7 +29,7 @@ import useLocation from '@hooks/useLocation' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' -import { useScanStore } from '@components/layout/dialogs/scanner/store' +import { useScanStore } from '@features/scanner/store' import { I } from '@components/layout/general/I' import { diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index a720b08dc..4e346f4fe 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -2,27 +2,27 @@ import * as React from 'react' import { useMemory } from '@hooks/useMemory' +import Sidebar from '@components/layout/drawer/Drawer' +import FilterMenu from '@components/layout/dialogs/filters/FilterMenu' +import UserOptions from '@components/layout/dialogs/UserOptions' +import Tutorial from '@components/layout/dialogs/tutorial/Tutorial' +import UserProfile from '@components/layout/dialogs/profile' +import Search from '@components/layout/dialogs/search' +import MessageOfTheDay from '@components/layout/dialogs/Motd' +import DonorPage from '@components/layout/dialogs/DonorPage' +import Feedback from '@components/layout/dialogs/Feedback' +import ResetFilters from '@components/layout/dialogs/ResetFilters' +import ScanDialog from '@features/scanner/ScanDialog' +import Webhook from '@components/layout/dialogs/webhooks/Webhook' +import ClientError from '@components/layout/dialogs/ClientError' +import { WebhookNotification } from '@components/layout/dialogs/webhooks/Notification' +import AdvancedFilter from '@components/layout/dialogs/filters/Advanced' +import BadgeSelection from '@components/layout/dialogs/BadgeSelection' +import WebhookAdvanced from '@components/layout/dialogs/webhooks/WebhookAdv' +import SlotSelection from '@components/layout/dialogs/filters/SlotSelection' +import { HelpDialog } from '@components/layout/dialogs/Help' +import { PkmnFilterHelp } from '@components/layout/dialogs/filters/PkmnFilterHelp' import { FloatingButtonsMemo } from './FloatingBtn' -import Sidebar from '../../../components/layout/drawer/Drawer' -import FilterMenu from '../../../components/layout/dialogs/filters/FilterMenu' -import UserOptions from '../../../components/layout/dialogs/UserOptions' -import Tutorial from '../../../components/layout/dialogs/tutorial/Tutorial' -import UserProfile from '../../../components/layout/dialogs/profile' -import Search from '../../../components/layout/dialogs/search' -import MessageOfTheDay from '../../../components/layout/dialogs/Motd' -import DonorPage from '../../../components/layout/dialogs/DonorPage' -import Feedback from '../../../components/layout/dialogs/Feedback' -import ResetFilters from '../../../components/layout/dialogs/ResetFilters' -import ScanDialog from '../../../components/layout/dialogs/scanner/ScanDialog' -import Webhook from '../../../components/layout/dialogs/webhooks/Webhook' -import ClientError from '../../../components/layout/dialogs/ClientError' -import { WebhookNotification } from '../../../components/layout/dialogs/webhooks/Notification' -import AdvancedFilter from '../../../components/layout/dialogs/filters/Advanced' -import BadgeSelection from '../../../components/layout/dialogs/BadgeSelection' -import WebhookAdvanced from '../../../components/layout/dialogs/webhooks/WebhookAdv' -import SlotSelection from '../../../components/layout/dialogs/filters/SlotSelection' -import { HelpDialog } from '../../../components/layout/dialogs/Help' -import { PkmnFilterHelp } from '../../../components/layout/dialogs/filters/PkmnFilterHelp' export const Nav = React.memo( () => { diff --git a/vite.config.js b/vite.config.js index ace62341c..6dc395fbe 100644 --- a/vite.config.js +++ b/vite.config.js @@ -108,8 +108,9 @@ const viteConfig = defineConfig(({ mode }) => { publicDir: 'public', resolve: { alias: { - '@components': resolve(__dirname, './src/components'), '@assets': resolve(__dirname, './src/assets'), + '@components': resolve(__dirname, './src/components'), + '@features': resolve(__dirname, './src/features'), '@hooks': resolve(__dirname, './src/hooks'), '@services': resolve(__dirname, './src/services'), }, From 56d2b406ebac13bf931ac39c733586f9061b4813 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:19:07 -0500 Subject: [PATCH 016/177] refactor: move search into `features` folder --- .../layout/dialogs => features}/search/OptionImage.jsx | 0 src/{components/layout/dialogs => features}/search/index.jsx | 2 +- .../layout/dialogs => features}/search/renderInput.jsx | 2 +- .../layout/dialogs => features}/search/renderOption.jsx | 0 .../layout/dialogs => features}/search/useSendSearch.js | 0 src/pages/map/components/Nav.jsx | 2 +- 6 files changed, 3 insertions(+), 3 deletions(-) rename src/{components/layout/dialogs => features}/search/OptionImage.jsx (100%) rename src/{components/layout/dialogs => features}/search/index.jsx (98%) rename src/{components/layout/dialogs => features}/search/renderInput.jsx (98%) rename src/{components/layout/dialogs => features}/search/renderOption.jsx (100%) rename src/{components/layout/dialogs => features}/search/useSendSearch.js (100%) diff --git a/src/components/layout/dialogs/search/OptionImage.jsx b/src/features/search/OptionImage.jsx similarity index 100% rename from src/components/layout/dialogs/search/OptionImage.jsx rename to src/features/search/OptionImage.jsx diff --git a/src/components/layout/dialogs/search/index.jsx b/src/features/search/index.jsx similarity index 98% rename from src/components/layout/dialogs/search/index.jsx rename to src/features/search/index.jsx index a2df51a3a..40f1b628c 100644 --- a/src/components/layout/dialogs/search/index.jsx +++ b/src/features/search/index.jsx @@ -13,7 +13,7 @@ import Utility from '@services/Utility' import { fromSearchCategory } from '@services/functions/fromSearchCategory' import { useMapStore } from '@hooks/useMapStore' -import Header from '../../general/Header' +import Header from '@components/layout/general/Header' import { renderInput } from './renderInput' import { renderOption } from './renderOption' import { useSendSearch } from './useSendSearch' diff --git a/src/components/layout/dialogs/search/renderInput.jsx b/src/features/search/renderInput.jsx similarity index 98% rename from src/components/layout/dialogs/search/renderInput.jsx rename to src/features/search/renderInput.jsx index 9a2bc7765..db4510365 100644 --- a/src/components/layout/dialogs/search/renderInput.jsx +++ b/src/features/search/renderInput.jsx @@ -15,7 +15,7 @@ import { useQuery } from '@apollo/client' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { SEARCHABLE } from '@services/queries/config' -import { Img } from '../../general/Img' +import { Img } from '@components/layout/general/Img' const SearchImage = React.memo( /** @param {{ name: string }} props */ ({ name }) => { diff --git a/src/components/layout/dialogs/search/renderOption.jsx b/src/features/search/renderOption.jsx similarity index 100% rename from src/components/layout/dialogs/search/renderOption.jsx rename to src/features/search/renderOption.jsx diff --git a/src/components/layout/dialogs/search/useSendSearch.js b/src/features/search/useSendSearch.js similarity index 100% rename from src/components/layout/dialogs/search/useSendSearch.js rename to src/features/search/useSendSearch.js diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index 4e346f4fe..206c04891 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -7,7 +7,7 @@ import FilterMenu from '@components/layout/dialogs/filters/FilterMenu' import UserOptions from '@components/layout/dialogs/UserOptions' import Tutorial from '@components/layout/dialogs/tutorial/Tutorial' import UserProfile from '@components/layout/dialogs/profile' -import Search from '@components/layout/dialogs/search' +import Search from '@features/search' import MessageOfTheDay from '@components/layout/dialogs/Motd' import DonorPage from '@components/layout/dialogs/DonorPage' import Feedback from '@components/layout/dialogs/Feedback' From 3422ca912e8fd93a182c6fd17420c7f91a6a448a Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:20:30 -0500 Subject: [PATCH 017/177] refactor: move webhooks into `features` folder --- src/components/layout/drawer/SelectorItem.jsx | 2 +- src/components/layout/general/Menu.jsx | 5 ++++- src/components/popups/Gym.jsx | 2 +- src/components/tiles/ScanArea.jsx | 4 ++-- .../layout/dialogs => features}/webhooks/Error.jsx | 0 .../layout/dialogs => features}/webhooks/Manage.jsx | 2 +- .../layout/dialogs => features}/webhooks/Notification.jsx | 0 .../layout/dialogs => features}/webhooks/Selecting.jsx | 0 .../layout/dialogs => features}/webhooks/Tracked.jsx | 0 .../layout/dialogs => features}/webhooks/Webhook.jsx | 0 .../layout/dialogs => features}/webhooks/WebhookAdv.jsx | 0 .../layout/dialogs => features}/webhooks/hooks.js | 0 .../dialogs => features}/webhooks/human/Draggable.jsx | 0 .../layout/dialogs => features}/webhooks/human/Location.jsx | 0 .../dialogs => features}/webhooks/human/area/AreaChip.jsx | 0 .../dialogs => features}/webhooks/human/area/AreaGroup.jsx | 0 .../webhooks/human/area/AreaSelection.jsx | 0 .../dialogs => features}/webhooks/human/area/Selected.jsx | 0 .../dialogs => features}/webhooks/human/area/index.jsx | 0 .../layout/dialogs => features}/webhooks/human/index.jsx | 0 .../webhooks/human/profile/ActiveHourChip.jsx | 0 .../webhooks/human/profile/CopyView.jsx | 0 .../webhooks/human/profile/DeleteVIew.jsx | 0 .../webhooks/human/profile/EditView.jsx | 0 .../webhooks/human/profile/NewProfile.jsx | 0 .../webhooks/human/profile/ProfileTile.jsx | 0 .../webhooks/human/profile/ProfileView.jsx | 0 .../dialogs => features}/webhooks/human/profile/index.jsx | 0 .../webhooks/human/status/EnableSwitch.jsx | 0 .../webhooks/human/status/HookSelection.jsx | 0 .../webhooks/human/status/ProfileSelect.jsx | 0 .../dialogs => features}/webhooks/human/status/index.jsx | 0 .../layout/dialogs => features}/webhooks/store.js | 0 .../dialogs => features}/webhooks/tiles/TrackedTile.jsx | 0 src/hooks/useWebhook.js | 2 +- src/pages/map/components/Container.jsx | 4 ++-- src/pages/map/components/FloatingBtn.jsx | 5 +---- src/pages/map/components/Nav.jsx | 6 +++--- src/services/Poracle.js | 4 ++-- 39 files changed, 18 insertions(+), 18 deletions(-) rename src/{components/layout/dialogs => features}/webhooks/Error.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/Manage.jsx (99%) rename src/{components/layout/dialogs => features}/webhooks/Notification.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/Selecting.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/Tracked.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/Webhook.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/WebhookAdv.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/hooks.js (100%) rename src/{components/layout/dialogs => features}/webhooks/human/Draggable.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/Location.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/area/AreaChip.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/area/AreaGroup.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/area/AreaSelection.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/area/Selected.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/area/index.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/index.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/profile/ActiveHourChip.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/profile/CopyView.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/profile/DeleteVIew.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/profile/EditView.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/profile/NewProfile.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/profile/ProfileTile.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/profile/ProfileView.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/profile/index.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/status/EnableSwitch.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/status/HookSelection.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/status/ProfileSelect.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/human/status/index.jsx (100%) rename src/{components/layout/dialogs => features}/webhooks/store.js (100%) rename src/{components/layout/dialogs => features}/webhooks/tiles/TrackedTile.jsx (100%) diff --git a/src/components/layout/drawer/SelectorItem.jsx b/src/components/layout/drawer/SelectorItem.jsx index c2aab5fcd..fe164e488 100644 --- a/src/components/layout/drawer/SelectorItem.jsx +++ b/src/components/layout/drawer/SelectorItem.jsx @@ -13,7 +13,7 @@ import { checkIfHasAll } from '@services/functions/hasAll' import Poracle from '@services/Poracle' import { ColoredTile } from '../general/ColoredTile' -import { useWebhookStore } from '../dialogs/webhooks/store' +import { useWebhookStore } from '../../../features/webhooks/store' import { ToggleTypography } from '../general/ToggleTypography' import { SQUARE_ITEM } from '../general/VirtualGrid' diff --git a/src/components/layout/general/Menu.jsx b/src/components/layout/general/Menu.jsx index 7c004e42e..ad779c864 100644 --- a/src/components/layout/general/Menu.jsx +++ b/src/components/layout/general/Menu.jsx @@ -19,7 +19,10 @@ import useGetAvailable from '@hooks/useGetAvailable' import OptionsContainer from '../dialogs/filters/OptionsContainer' import { VirtualGrid } from './VirtualGrid' import { GenericSearch } from '../drawer/ItemSearch' -import { applyToAllWebhooks, useWebhookStore } from '../dialogs/webhooks/store' +import { + applyToAllWebhooks, + useWebhookStore, +} from '../../../features/webhooks/store' /** * @template {import('@rm/types').AdvCategories} T diff --git a/src/components/popups/Gym.jsx b/src/components/popups/Gym.jsx index f75ce4c44..03e00fb52 100644 --- a/src/components/popups/Gym.jsx +++ b/src/components/popups/Gym.jsx @@ -14,7 +14,7 @@ import { import { useTranslation } from 'react-i18next' -import { useSyncData } from '@components/layout/dialogs/webhooks/hooks' +import { useSyncData } from '@features/webhooks/hooks' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { setDeepStore, useStorage } from '@hooks/useStorage' diff --git a/src/components/tiles/ScanArea.jsx b/src/components/tiles/ScanArea.jsx index 45b10941a..19e480810 100644 --- a/src/components/tiles/ScanArea.jsx +++ b/src/components/tiles/ScanArea.jsx @@ -5,8 +5,8 @@ import { GeoJSON } from 'react-leaflet' import { useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' -import { useWebhookStore } from '@components/layout/dialogs/webhooks/store' -import { handleClick } from '@components/layout/dialogs/webhooks/human/area/AreaChip' +import { useWebhookStore } from '@features/webhooks/store' +import { handleClick } from '@features/webhooks/human/area/AreaChip' import { Polygon } from 'leaflet' /** diff --git a/src/components/layout/dialogs/webhooks/Error.jsx b/src/features/webhooks/Error.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/Error.jsx rename to src/features/webhooks/Error.jsx diff --git a/src/components/layout/dialogs/webhooks/Manage.jsx b/src/features/webhooks/Manage.jsx similarity index 99% rename from src/components/layout/dialogs/webhooks/Manage.jsx rename to src/features/webhooks/Manage.jsx index 2993b0ba8..dc8646168 100644 --- a/src/components/layout/dialogs/webhooks/Manage.jsx +++ b/src/features/webhooks/Manage.jsx @@ -23,7 +23,7 @@ import { WebhookItem } from '@components/layout/drawer/SelectorItem' import Human from './human' import Tracked from './Tracked' -import Menu from '../../general/Menu' +import Menu from '../../components/layout/general/Menu' import { setMode, setSelected, useWebhookStore } from './store' import { useGenFullFilters, useGetHookContext } from './hooks' import ProfileEditing from './human/profile' diff --git a/src/components/layout/dialogs/webhooks/Notification.jsx b/src/features/webhooks/Notification.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/Notification.jsx rename to src/features/webhooks/Notification.jsx diff --git a/src/components/layout/dialogs/webhooks/Selecting.jsx b/src/features/webhooks/Selecting.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/Selecting.jsx rename to src/features/webhooks/Selecting.jsx diff --git a/src/components/layout/dialogs/webhooks/Tracked.jsx b/src/features/webhooks/Tracked.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/Tracked.jsx rename to src/features/webhooks/Tracked.jsx diff --git a/src/components/layout/dialogs/webhooks/Webhook.jsx b/src/features/webhooks/Webhook.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/Webhook.jsx rename to src/features/webhooks/Webhook.jsx diff --git a/src/components/layout/dialogs/webhooks/WebhookAdv.jsx b/src/features/webhooks/WebhookAdv.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/WebhookAdv.jsx rename to src/features/webhooks/WebhookAdv.jsx diff --git a/src/components/layout/dialogs/webhooks/hooks.js b/src/features/webhooks/hooks.js similarity index 100% rename from src/components/layout/dialogs/webhooks/hooks.js rename to src/features/webhooks/hooks.js diff --git a/src/components/layout/dialogs/webhooks/human/Draggable.jsx b/src/features/webhooks/human/Draggable.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/Draggable.jsx rename to src/features/webhooks/human/Draggable.jsx diff --git a/src/components/layout/dialogs/webhooks/human/Location.jsx b/src/features/webhooks/human/Location.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/Location.jsx rename to src/features/webhooks/human/Location.jsx diff --git a/src/components/layout/dialogs/webhooks/human/area/AreaChip.jsx b/src/features/webhooks/human/area/AreaChip.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/area/AreaChip.jsx rename to src/features/webhooks/human/area/AreaChip.jsx diff --git a/src/components/layout/dialogs/webhooks/human/area/AreaGroup.jsx b/src/features/webhooks/human/area/AreaGroup.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/area/AreaGroup.jsx rename to src/features/webhooks/human/area/AreaGroup.jsx diff --git a/src/components/layout/dialogs/webhooks/human/area/AreaSelection.jsx b/src/features/webhooks/human/area/AreaSelection.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/area/AreaSelection.jsx rename to src/features/webhooks/human/area/AreaSelection.jsx diff --git a/src/components/layout/dialogs/webhooks/human/area/Selected.jsx b/src/features/webhooks/human/area/Selected.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/area/Selected.jsx rename to src/features/webhooks/human/area/Selected.jsx diff --git a/src/components/layout/dialogs/webhooks/human/area/index.jsx b/src/features/webhooks/human/area/index.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/area/index.jsx rename to src/features/webhooks/human/area/index.jsx diff --git a/src/components/layout/dialogs/webhooks/human/index.jsx b/src/features/webhooks/human/index.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/index.jsx rename to src/features/webhooks/human/index.jsx diff --git a/src/components/layout/dialogs/webhooks/human/profile/ActiveHourChip.jsx b/src/features/webhooks/human/profile/ActiveHourChip.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/profile/ActiveHourChip.jsx rename to src/features/webhooks/human/profile/ActiveHourChip.jsx diff --git a/src/components/layout/dialogs/webhooks/human/profile/CopyView.jsx b/src/features/webhooks/human/profile/CopyView.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/profile/CopyView.jsx rename to src/features/webhooks/human/profile/CopyView.jsx diff --git a/src/components/layout/dialogs/webhooks/human/profile/DeleteVIew.jsx b/src/features/webhooks/human/profile/DeleteVIew.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/profile/DeleteVIew.jsx rename to src/features/webhooks/human/profile/DeleteVIew.jsx diff --git a/src/components/layout/dialogs/webhooks/human/profile/EditView.jsx b/src/features/webhooks/human/profile/EditView.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/profile/EditView.jsx rename to src/features/webhooks/human/profile/EditView.jsx diff --git a/src/components/layout/dialogs/webhooks/human/profile/NewProfile.jsx b/src/features/webhooks/human/profile/NewProfile.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/profile/NewProfile.jsx rename to src/features/webhooks/human/profile/NewProfile.jsx diff --git a/src/components/layout/dialogs/webhooks/human/profile/ProfileTile.jsx b/src/features/webhooks/human/profile/ProfileTile.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/profile/ProfileTile.jsx rename to src/features/webhooks/human/profile/ProfileTile.jsx diff --git a/src/components/layout/dialogs/webhooks/human/profile/ProfileView.jsx b/src/features/webhooks/human/profile/ProfileView.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/profile/ProfileView.jsx rename to src/features/webhooks/human/profile/ProfileView.jsx diff --git a/src/components/layout/dialogs/webhooks/human/profile/index.jsx b/src/features/webhooks/human/profile/index.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/profile/index.jsx rename to src/features/webhooks/human/profile/index.jsx diff --git a/src/components/layout/dialogs/webhooks/human/status/EnableSwitch.jsx b/src/features/webhooks/human/status/EnableSwitch.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/status/EnableSwitch.jsx rename to src/features/webhooks/human/status/EnableSwitch.jsx diff --git a/src/components/layout/dialogs/webhooks/human/status/HookSelection.jsx b/src/features/webhooks/human/status/HookSelection.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/status/HookSelection.jsx rename to src/features/webhooks/human/status/HookSelection.jsx diff --git a/src/components/layout/dialogs/webhooks/human/status/ProfileSelect.jsx b/src/features/webhooks/human/status/ProfileSelect.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/status/ProfileSelect.jsx rename to src/features/webhooks/human/status/ProfileSelect.jsx diff --git a/src/components/layout/dialogs/webhooks/human/status/index.jsx b/src/features/webhooks/human/status/index.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/human/status/index.jsx rename to src/features/webhooks/human/status/index.jsx diff --git a/src/components/layout/dialogs/webhooks/store.js b/src/features/webhooks/store.js similarity index 100% rename from src/components/layout/dialogs/webhooks/store.js rename to src/features/webhooks/store.js diff --git a/src/components/layout/dialogs/webhooks/tiles/TrackedTile.jsx b/src/features/webhooks/tiles/TrackedTile.jsx similarity index 100% rename from src/components/layout/dialogs/webhooks/tiles/TrackedTile.jsx rename to src/features/webhooks/tiles/TrackedTile.jsx diff --git a/src/hooks/useWebhook.js b/src/hooks/useWebhook.js index 08a483858..2d4807746 100644 --- a/src/hooks/useWebhook.js +++ b/src/hooks/useWebhook.js @@ -2,7 +2,7 @@ import { useEffect } from 'react' import { useMutation } from '@apollo/client' import { useTranslation } from 'react-i18next' import Query from '@services/Query' -import { useWebhookStore } from '@components/layout/dialogs/webhooks/store' +import { useWebhookStore } from '@features/webhooks/store' import { allProfiles } from '@services/queries/webhook' export default function useWebhook({ category }) { diff --git a/src/pages/map/components/Container.jsx b/src/pages/map/components/Container.jsx index b6b29ccdb..ffca059c0 100644 --- a/src/pages/map/components/Container.jsx +++ b/src/pages/map/components/Container.jsx @@ -8,8 +8,8 @@ import { useMapStore } from '@hooks/useMapStore' import Utility from '@services/Utility' import ScanOnDemand from '@features/scanner/ScanOnDemand' -import DraggableMarker from '@components/layout/dialogs/webhooks/human/Draggable' -import WebhookAreaSelection from '@components/layout/dialogs/webhooks/human/area/AreaSelection' +import DraggableMarker from '@features/webhooks/human/Draggable' +import WebhookAreaSelection from '@features/webhooks/human/area/AreaSelection' import { Effects } from './Effects' import DataView from './Data' diff --git a/src/pages/map/components/FloatingBtn.jsx b/src/pages/map/components/FloatingBtn.jsx index 5a5361a30..dbc0b9c20 100644 --- a/src/pages/map/components/FloatingBtn.jsx +++ b/src/pages/map/components/FloatingBtn.jsx @@ -32,10 +32,7 @@ import { useStorage } from '@hooks/useStorage' import { useScanStore } from '@features/scanner/store' import { I } from '@components/layout/general/I' -import { - setModeBtn, - useWebhookStore, -} from '@components/layout/dialogs/webhooks/store' +import { setModeBtn, useWebhookStore } from '@features/webhooks/store' /** @typedef {keyof ReturnType | keyof ReturnType} Keys */ diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index 206c04891..3a5158468 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -13,12 +13,12 @@ import DonorPage from '@components/layout/dialogs/DonorPage' import Feedback from '@components/layout/dialogs/Feedback' import ResetFilters from '@components/layout/dialogs/ResetFilters' import ScanDialog from '@features/scanner/ScanDialog' -import Webhook from '@components/layout/dialogs/webhooks/Webhook' +import Webhook from '@features/webhooks/Webhook' import ClientError from '@components/layout/dialogs/ClientError' -import { WebhookNotification } from '@components/layout/dialogs/webhooks/Notification' +import { WebhookNotification } from '@features/webhooks/Notification' import AdvancedFilter from '@components/layout/dialogs/filters/Advanced' import BadgeSelection from '@components/layout/dialogs/BadgeSelection' -import WebhookAdvanced from '@components/layout/dialogs/webhooks/WebhookAdv' +import WebhookAdvanced from '@features/webhooks/WebhookAdv' import SlotSelection from '@components/layout/dialogs/filters/SlotSelection' import { HelpDialog } from '@components/layout/dialogs/Help' import { PkmnFilterHelp } from '@components/layout/dialogs/filters/PkmnFilterHelp' diff --git a/src/services/Poracle.js b/src/services/Poracle.js index 79c5e7af5..e3c8c9057 100644 --- a/src/services/Poracle.js +++ b/src/services/Poracle.js @@ -1,6 +1,6 @@ // @ts-check import { t } from 'i18next' -import { useWebhookStore } from '@components/layout/dialogs/webhooks/store' +import { useWebhookStore } from '@features/webhooks/store' export default class Poracle { static getMapCategory(poracleCategory) { @@ -302,7 +302,7 @@ export default class Poracle { /** * * @param {object} item - * @param {Exclude} category + * @param {Exclude} category * @returns {string} */ static generateDescription(item, category) { From af847510cf24dff2aea87762dff2db8de6b02fb5 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:21:24 -0500 Subject: [PATCH 018/177] refactor: move profile into `features` folder --- .../layout/dialogs => features}/profile/Backups.jsx | 0 .../layout/dialogs => features}/profile/ExtraFields.jsx | 0 .../layout/dialogs => features}/profile/GymBadges.jsx | 0 .../layout/dialogs => features}/profile/LinkAccounts.jsx | 6 +++--- .../layout/dialogs => features}/profile/Permissions.jsx | 0 .../layout/dialogs => features}/profile/index.jsx | 6 +++--- src/pages/map/components/Nav.jsx | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) rename src/{components/layout/dialogs => features}/profile/Backups.jsx (100%) rename src/{components/layout/dialogs => features}/profile/ExtraFields.jsx (100%) rename src/{components/layout/dialogs => features}/profile/GymBadges.jsx (100%) rename src/{components/layout/dialogs => features}/profile/LinkAccounts.jsx (94%) rename src/{components/layout/dialogs => features}/profile/Permissions.jsx (100%) rename src/{components/layout/dialogs => features}/profile/index.jsx (94%) diff --git a/src/components/layout/dialogs/profile/Backups.jsx b/src/features/profile/Backups.jsx similarity index 100% rename from src/components/layout/dialogs/profile/Backups.jsx rename to src/features/profile/Backups.jsx diff --git a/src/components/layout/dialogs/profile/ExtraFields.jsx b/src/features/profile/ExtraFields.jsx similarity index 100% rename from src/components/layout/dialogs/profile/ExtraFields.jsx rename to src/features/profile/ExtraFields.jsx diff --git a/src/components/layout/dialogs/profile/GymBadges.jsx b/src/features/profile/GymBadges.jsx similarity index 100% rename from src/components/layout/dialogs/profile/GymBadges.jsx rename to src/features/profile/GymBadges.jsx diff --git a/src/components/layout/dialogs/profile/LinkAccounts.jsx b/src/features/profile/LinkAccounts.jsx similarity index 94% rename from src/components/layout/dialogs/profile/LinkAccounts.jsx rename to src/features/profile/LinkAccounts.jsx index 0265e8225..1bee66219 100644 --- a/src/components/layout/dialogs/profile/LinkAccounts.jsx +++ b/src/features/profile/LinkAccounts.jsx @@ -12,9 +12,9 @@ import Utility from '@services/Utility' import Query from '@services/Query' import { METHODS } from '@assets/constants' -import DiscordButton from '../../auth/Discord' -import Telegram from '../../auth/Telegram' -import Notification from '../../general/Notification' +import DiscordButton from '@components/layout/auth/Discord' +import Telegram from '@components/layout/auth/Telegram' +import Notification from '@components/layout/general/Notification' export function LinkAccounts() { const { t } = useTranslation() diff --git a/src/components/layout/dialogs/profile/Permissions.jsx b/src/features/profile/Permissions.jsx similarity index 100% rename from src/components/layout/dialogs/profile/Permissions.jsx rename to src/features/profile/Permissions.jsx diff --git a/src/components/layout/dialogs/profile/index.jsx b/src/features/profile/index.jsx similarity index 94% rename from src/components/layout/dialogs/profile/index.jsx rename to src/features/profile/index.jsx index 778af9abf..8098fabfc 100644 --- a/src/components/layout/dialogs/profile/index.jsx +++ b/src/features/profile/index.jsx @@ -10,10 +10,10 @@ import DialogContent from '@mui/material/DialogContent' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import Utility from '@services/Utility' +import Header from '@components/layout/general/Header' +import Footer from '@components/layout/general/Footer' +import { DialogWrapper } from '@components/layout/dialogs/DialogWrapper' -import Header from '../../general/Header' -import Footer from '../../general/Footer' -import { DialogWrapper } from '../DialogWrapper' import { UserBackups } from './Backups' import { UserPermissions } from './Permissions' import { UserGymBadges } from './GymBadges' diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index 3a5158468..9ebabaefc 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -6,7 +6,7 @@ import Sidebar from '@components/layout/drawer/Drawer' import FilterMenu from '@components/layout/dialogs/filters/FilterMenu' import UserOptions from '@components/layout/dialogs/UserOptions' import Tutorial from '@components/layout/dialogs/tutorial/Tutorial' -import UserProfile from '@components/layout/dialogs/profile' +import UserProfile from '@features/profile' import Search from '@features/search' import MessageOfTheDay from '@components/layout/dialogs/Motd' import DonorPage from '@components/layout/dialogs/DonorPage' From a6676d64d07257b91d3a9dd413e64cd5c78c0c18 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:23:57 -0500 Subject: [PATCH 019/177] refactor: move tutorial to `features` folder --- src/components/layout/dialogs/Help.jsx | 2 +- .../layout/dialogs => features}/tutorial/Advanced.jsx | 0 .../layout/dialogs => features}/tutorial/Closing.jsx | 0 src/{components/layout/dialogs => features}/tutorial/Popups.jsx | 0 .../layout/dialogs => features}/tutorial/Sidebar.jsx | 0 .../layout/dialogs => features}/tutorial/Sliders.jsx | 2 +- .../layout/dialogs => features}/tutorial/Welcome.jsx | 0 src/{components/layout/dialogs => features}/tutorial/data.js | 0 .../tutorial/Tutorial.jsx => features/tutorial/index.jsx} | 0 src/pages/map/components/Nav.jsx | 2 +- 10 files changed, 3 insertions(+), 3 deletions(-) rename src/{components/layout/dialogs => features}/tutorial/Advanced.jsx (100%) rename src/{components/layout/dialogs => features}/tutorial/Closing.jsx (100%) rename src/{components/layout/dialogs => features}/tutorial/Popups.jsx (100%) rename src/{components/layout/dialogs => features}/tutorial/Sidebar.jsx (100%) rename src/{components/layout/dialogs => features}/tutorial/Sliders.jsx (98%) rename src/{components/layout/dialogs => features}/tutorial/Welcome.jsx (100%) rename src/{components/layout/dialogs => features}/tutorial/data.js (100%) rename src/{components/layout/dialogs/tutorial/Tutorial.jsx => features/tutorial/index.jsx} (100%) diff --git a/src/components/layout/dialogs/Help.jsx b/src/components/layout/dialogs/Help.jsx index 85bbc433e..11caf5e19 100644 --- a/src/components/layout/dialogs/Help.jsx +++ b/src/components/layout/dialogs/Help.jsx @@ -3,7 +3,7 @@ import * as React from 'react' import { useLayoutStore } from '@hooks/useLayoutStore' -import Help from './tutorial/Advanced' +import Help from '@features/tutorial/Advanced' import { DialogWrapper } from './DialogWrapper' export function HelpDialog() { diff --git a/src/components/layout/dialogs/tutorial/Advanced.jsx b/src/features/tutorial/Advanced.jsx similarity index 100% rename from src/components/layout/dialogs/tutorial/Advanced.jsx rename to src/features/tutorial/Advanced.jsx diff --git a/src/components/layout/dialogs/tutorial/Closing.jsx b/src/features/tutorial/Closing.jsx similarity index 100% rename from src/components/layout/dialogs/tutorial/Closing.jsx rename to src/features/tutorial/Closing.jsx diff --git a/src/components/layout/dialogs/tutorial/Popups.jsx b/src/features/tutorial/Popups.jsx similarity index 100% rename from src/components/layout/dialogs/tutorial/Popups.jsx rename to src/features/tutorial/Popups.jsx diff --git a/src/components/layout/dialogs/tutorial/Sidebar.jsx b/src/features/tutorial/Sidebar.jsx similarity index 100% rename from src/components/layout/dialogs/tutorial/Sidebar.jsx rename to src/features/tutorial/Sidebar.jsx diff --git a/src/components/layout/dialogs/tutorial/Sliders.jsx b/src/features/tutorial/Sliders.jsx similarity index 98% rename from src/components/layout/dialogs/tutorial/Sliders.jsx rename to src/features/tutorial/Sliders.jsx index a70c03d32..207db8f3f 100644 --- a/src/components/layout/dialogs/tutorial/Sliders.jsx +++ b/src/features/tutorial/Sliders.jsx @@ -2,7 +2,7 @@ import React, { useState } from 'react' import { Grid, DialogContent, Typography, Divider } from '@mui/material' import { useTranslation, Trans } from 'react-i18next' -import SliderTile from '../filters/SliderTile' +import SliderTile from '../../components/layout/dialogs/filters/SliderTile' import data from './data' const relevant = ['iv', 'level', 'great', 'ultra'] diff --git a/src/components/layout/dialogs/tutorial/Welcome.jsx b/src/features/tutorial/Welcome.jsx similarity index 100% rename from src/components/layout/dialogs/tutorial/Welcome.jsx rename to src/features/tutorial/Welcome.jsx diff --git a/src/components/layout/dialogs/tutorial/data.js b/src/features/tutorial/data.js similarity index 100% rename from src/components/layout/dialogs/tutorial/data.js rename to src/features/tutorial/data.js diff --git a/src/components/layout/dialogs/tutorial/Tutorial.jsx b/src/features/tutorial/index.jsx similarity index 100% rename from src/components/layout/dialogs/tutorial/Tutorial.jsx rename to src/features/tutorial/index.jsx diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index 9ebabaefc..15669629e 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -5,7 +5,7 @@ import { useMemory } from '@hooks/useMemory' import Sidebar from '@components/layout/drawer/Drawer' import FilterMenu from '@components/layout/dialogs/filters/FilterMenu' import UserOptions from '@components/layout/dialogs/UserOptions' -import Tutorial from '@components/layout/dialogs/tutorial/Tutorial' +import Tutorial from '@features/tutorial' import UserProfile from '@features/profile' import Search from '@features/search' import MessageOfTheDay from '@components/layout/dialogs/Motd' From 1bb323eadf6752c863c009e9cbe7f7a3decb01c9 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:24:44 -0500 Subject: [PATCH 020/177] refactor: rename `ScanOnDemand.jsx` => `index.jsx` --- src/features/scanner/{ScanOnDemand.jsx => index.jsx} | 0 src/pages/map/components/Container.jsx | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/features/scanner/{ScanOnDemand.jsx => index.jsx} (100%) diff --git a/src/features/scanner/ScanOnDemand.jsx b/src/features/scanner/index.jsx similarity index 100% rename from src/features/scanner/ScanOnDemand.jsx rename to src/features/scanner/index.jsx diff --git a/src/pages/map/components/Container.jsx b/src/pages/map/components/Container.jsx index ffca059c0..11894c4c2 100644 --- a/src/pages/map/components/Container.jsx +++ b/src/pages/map/components/Container.jsx @@ -7,7 +7,7 @@ import { useStorage } from '@hooks/useStorage' import { useMapStore } from '@hooks/useMapStore' import Utility from '@services/Utility' -import ScanOnDemand from '@features/scanner/ScanOnDemand' +import ScanOnDemand from '@features/scanner' import DraggableMarker from '@features/webhooks/human/Draggable' import WebhookAreaSelection from '@features/webhooks/human/area/AreaSelection' import { Effects } from './Effects' From 7146274b0fc472d5556e128de55fec020bde8982 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:27:21 -0500 Subject: [PATCH 021/177] refactor: move `drawer` to `features` folder --- src/components/layout/dialogs/BadgeSelection.jsx | 2 +- src/components/layout/dialogs/filters/Advanced.jsx | 5 +---- src/components/layout/dialogs/filters/FilterMenu.jsx | 2 +- src/components/layout/dialogs/filters/Gender.jsx | 2 +- src/components/layout/dialogs/filters/Size.jsx | 2 +- .../layout/dialogs/filters/SlotSelection.jsx | 2 +- src/components/layout/general/Menu.jsx | 2 +- .../layout => features}/drawer/Actions.jsx | 4 ++-- .../layout => features}/drawer/BoolToggle.jsx | 0 .../layout => features}/drawer/CollapsibleItem.jsx | 0 .../layout => features}/drawer/Extras.jsx | 2 +- .../layout => features}/drawer/ItemSearch.jsx | 0 .../layout => features}/drawer/MultiSelector.jsx | 0 .../layout => features}/drawer/Pokemon.jsx | 10 +++++----- .../layout => features}/drawer/Section.jsx | 2 +- .../layout => features}/drawer/SelectorItem.jsx | 8 ++++---- .../layout => features}/drawer/SelectorList.jsx | 4 ++-- .../layout => features}/drawer/Settings.jsx | 4 ++-- .../layout => features}/drawer/areas/AreaTable.jsx | 0 .../layout => features}/drawer/areas/Child.jsx | 0 .../layout => features}/drawer/areas/Parent.jsx | 0 .../layout => features}/drawer/areas/index.jsx | 0 .../drawer/Drawer.jsx => features/drawer/index.jsx} | 12 ++++++------ src/features/tutorial/Advanced.jsx | 2 +- src/features/webhooks/Manage.jsx | 2 +- src/features/webhooks/Tracked.jsx | 2 +- src/pages/map/components/Nav.jsx | 4 ++-- 27 files changed, 35 insertions(+), 38 deletions(-) rename src/{components/layout => features}/drawer/Actions.jsx (97%) rename src/{components/layout => features}/drawer/BoolToggle.jsx (100%) rename src/{components/layout => features}/drawer/CollapsibleItem.jsx (100%) rename src/{components/layout => features}/drawer/Extras.jsx (99%) rename src/{components/layout => features}/drawer/ItemSearch.jsx (100%) rename src/{components/layout => features}/drawer/MultiSelector.jsx (100%) rename src/{components/layout => features}/drawer/Pokemon.jsx (93%) rename src/{components/layout => features}/drawer/Section.jsx (97%) rename src/{components/layout => features}/drawer/SelectorItem.jsx (94%) rename src/{components/layout => features}/drawer/SelectorList.jsx (98%) rename src/{components/layout => features}/drawer/Settings.jsx (97%) rename src/{components/layout => features}/drawer/areas/AreaTable.jsx (100%) rename src/{components/layout => features}/drawer/areas/Child.jsx (100%) rename src/{components/layout => features}/drawer/areas/Parent.jsx (100%) rename src/{components/layout => features}/drawer/areas/index.jsx (100%) rename src/{components/layout/drawer/Drawer.jsx => features/drawer/index.jsx} (88%) diff --git a/src/components/layout/dialogs/BadgeSelection.jsx b/src/components/layout/dialogs/BadgeSelection.jsx index bde2af3a1..bcecd1b50 100644 --- a/src/components/layout/dialogs/BadgeSelection.jsx +++ b/src/components/layout/dialogs/BadgeSelection.jsx @@ -8,10 +8,10 @@ import { apolloClient, apolloCache } from '@services/apollo' import Query from '@services/Query' import { ENUM_BADGES } from '@assets/constants' import { useLayoutStore } from '@hooks/useLayoutStore' +import { MultiSelector } from '@features/drawer/MultiSelector' import Header from '../general/Header' import Footer from '../general/Footer' -import { MultiSelector } from '../drawer/MultiSelector' const handleClose = () => useLayoutStore.setState({ diff --git a/src/components/layout/dialogs/filters/Advanced.jsx b/src/components/layout/dialogs/filters/Advanced.jsx index 8d86f440e..97470bd94 100644 --- a/src/components/layout/dialogs/filters/Advanced.jsx +++ b/src/components/layout/dialogs/filters/Advanced.jsx @@ -10,10 +10,7 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import { useDeepStore, useStorage } from '@hooks/useStorage' import Header from '@components/layout/general/Header' import Footer from '@components/layout/general/Footer' -import { - BoolToggle, - DualBoolToggle, -} from '@components/layout/drawer/BoolToggle' +import { BoolToggle, DualBoolToggle } from '@features/drawer/BoolToggle' import { ENABLED_ALL, XXS_XXL } from '@assets/constants' import { useTranslateById } from '@hooks/useTranslateById' import { STANDARD_BACKUP, applyToAll } from '@services/filtering/applyToAll' diff --git a/src/components/layout/dialogs/filters/FilterMenu.jsx b/src/components/layout/dialogs/filters/FilterMenu.jsx index c6c6e246e..89b9ddafb 100644 --- a/src/components/layout/dialogs/filters/FilterMenu.jsx +++ b/src/components/layout/dialogs/filters/FilterMenu.jsx @@ -4,7 +4,7 @@ import Menu from '@components/layout/general/Menu' import { toggleDialog, useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' -import { StandardItem } from '@components/layout/drawer/SelectorItem' +import { StandardItem } from '@features/drawer/SelectorItem' import { DialogWrapper } from '../DialogWrapper' diff --git a/src/components/layout/dialogs/filters/Gender.jsx b/src/components/layout/dialogs/filters/Gender.jsx index 393bc1e3f..fea073538 100644 --- a/src/components/layout/dialogs/filters/Gender.jsx +++ b/src/components/layout/dialogs/filters/Gender.jsx @@ -4,7 +4,7 @@ import ListItem from '@mui/material/ListItem' import ListItemText from '@mui/material/ListItemText' import { useTranslation } from 'react-i18next' -import { MultiSelectorStore } from '@components/layout/drawer/MultiSelector' +import { MultiSelectorStore } from '@features/drawer/MultiSelector' import { ENUM_GENDER } from '@assets/constants' /** diff --git a/src/components/layout/dialogs/filters/Size.jsx b/src/components/layout/dialogs/filters/Size.jsx index 41ccf2e89..25f4aefd5 100644 --- a/src/components/layout/dialogs/filters/Size.jsx +++ b/src/components/layout/dialogs/filters/Size.jsx @@ -4,7 +4,7 @@ import ListItem from '@mui/material/ListItem' import ListItemText from '@mui/material/ListItemText' import { useTranslation } from 'react-i18next' -import { MultiSelectorStore } from '@components/layout/drawer/MultiSelector' +import { MultiSelectorStore } from '@features/drawer/MultiSelector' import { ICON_SIZES } from '@assets/constants' /** diff --git a/src/components/layout/dialogs/filters/SlotSelection.jsx b/src/components/layout/dialogs/filters/SlotSelection.jsx index 5efa9fab8..909bf2137 100644 --- a/src/components/layout/dialogs/filters/SlotSelection.jsx +++ b/src/components/layout/dialogs/filters/SlotSelection.jsx @@ -11,7 +11,7 @@ import { basicEqualFn, useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage, useDeepStore } from '@hooks/useStorage' import { Img } from '@components/layout/general/Img' -import { DualBoolToggle } from '@components/layout/drawer/BoolToggle' +import { DualBoolToggle } from '@features/drawer/BoolToggle' import { ENABLED_ALL } from '@assets/constants' import Header from '@components/layout/general/Header' import Footer from '@components/layout/general/Footer' diff --git a/src/components/layout/general/Menu.jsx b/src/components/layout/general/Menu.jsx index ad779c864..6b4bf4902 100644 --- a/src/components/layout/general/Menu.jsx +++ b/src/components/layout/general/Menu.jsx @@ -18,7 +18,7 @@ import useGetAvailable from '@hooks/useGetAvailable' import OptionsContainer from '../dialogs/filters/OptionsContainer' import { VirtualGrid } from './VirtualGrid' -import { GenericSearch } from '../drawer/ItemSearch' +import { GenericSearch } from '../../../features/drawer/ItemSearch' import { applyToAllWebhooks, useWebhookStore, diff --git a/src/components/layout/drawer/Actions.jsx b/src/features/drawer/Actions.jsx similarity index 97% rename from src/components/layout/drawer/Actions.jsx rename to src/features/drawer/Actions.jsx index 53c891dbd..3370a56b0 100644 --- a/src/components/layout/drawer/Actions.jsx +++ b/src/features/drawer/Actions.jsx @@ -19,8 +19,8 @@ import { useMapStore } from '@hooks/useMapStore' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' -import { I } from '../general/I' -import { BasicListButton } from '../general/BasicListButton' +import { I } from '../../components/layout/general/I' +import { BasicListButton } from '../../components/layout/general/BasicListButton' /** @type {React.ChangeEventHandler} */ const importSettings = (e) => { diff --git a/src/components/layout/drawer/BoolToggle.jsx b/src/features/drawer/BoolToggle.jsx similarity index 100% rename from src/components/layout/drawer/BoolToggle.jsx rename to src/features/drawer/BoolToggle.jsx diff --git a/src/components/layout/drawer/CollapsibleItem.jsx b/src/features/drawer/CollapsibleItem.jsx similarity index 100% rename from src/components/layout/drawer/CollapsibleItem.jsx rename to src/features/drawer/CollapsibleItem.jsx diff --git a/src/components/layout/drawer/Extras.jsx b/src/features/drawer/Extras.jsx similarity index 99% rename from src/components/layout/drawer/Extras.jsx rename to src/features/drawer/Extras.jsx index 925f440b8..0f0fe5c85 100644 --- a/src/components/layout/drawer/Extras.jsx +++ b/src/features/drawer/Extras.jsx @@ -21,7 +21,7 @@ import { } from '@assets/constants' import { MultiSelectorStore } from './MultiSelector' -import SliderTile from '../dialogs/filters/SliderTile' +import SliderTile from '../../components/layout/dialogs/filters/SliderTile' import { CollapsibleItem } from './CollapsibleItem' import { MultiSelectorList, SelectorListMemo } from './SelectorList' import { BoolToggle } from './BoolToggle' diff --git a/src/components/layout/drawer/ItemSearch.jsx b/src/features/drawer/ItemSearch.jsx similarity index 100% rename from src/components/layout/drawer/ItemSearch.jsx rename to src/features/drawer/ItemSearch.jsx diff --git a/src/components/layout/drawer/MultiSelector.jsx b/src/features/drawer/MultiSelector.jsx similarity index 100% rename from src/components/layout/drawer/MultiSelector.jsx rename to src/features/drawer/MultiSelector.jsx diff --git a/src/components/layout/drawer/Pokemon.jsx b/src/features/drawer/Pokemon.jsx similarity index 93% rename from src/components/layout/drawer/Pokemon.jsx rename to src/features/drawer/Pokemon.jsx index 30aec3565..df1b6fcc1 100644 --- a/src/components/layout/drawer/Pokemon.jsx +++ b/src/features/drawer/Pokemon.jsx @@ -25,13 +25,13 @@ import Utility from '@services/Utility' import { XXS_XXL, NUNDO_HUNDO } from '@assets/constants' import { useLayoutStore } from '@hooks/useLayoutStore' -import { StringFilterMemo } from '../dialogs/filters/StringFilter' -import SliderTile from '../dialogs/filters/SliderTile' -import TabPanel from '../general/TabPanel' +import { StringFilterMemo } from '../../components/layout/dialogs/filters/StringFilter' +import SliderTile from '../../components/layout/dialogs/filters/SliderTile' +import TabPanel from '../../components/layout/general/TabPanel' import { BoolToggle, DualBoolToggle } from './BoolToggle' -import { GenderListItem } from '../dialogs/filters/Gender' +import { GenderListItem } from '../../components/layout/dialogs/filters/Gender' import { SelectorListMemo } from './SelectorList' -import { BasicListButton } from '../general/BasicListButton' +import { BasicListButton } from '../../components/layout/general/BasicListButton' function PokemonDrawer() { const filterMode = useStorage((s) => s.getPokemonFilterMode()) diff --git a/src/components/layout/drawer/Section.jsx b/src/features/drawer/Section.jsx similarity index 97% rename from src/components/layout/drawer/Section.jsx rename to src/features/drawer/Section.jsx index 7c8f4480a..2b6d53893 100644 --- a/src/components/layout/drawer/Section.jsx +++ b/src/features/drawer/Section.jsx @@ -21,7 +21,7 @@ import { PokemonDrawerMemo } from './Pokemon' import Areas from './areas' import Extras from './Extras' import { BoolToggle } from './BoolToggle' -import { BasicListButton } from '../general/BasicListButton' +import { BasicListButton } from '../../components/layout/general/BasicListButton' const ADV_CATEGORIES = new Set(['pokemon', 'gyms', 'pokestops', 'nests']) diff --git a/src/components/layout/drawer/SelectorItem.jsx b/src/features/drawer/SelectorItem.jsx similarity index 94% rename from src/components/layout/drawer/SelectorItem.jsx rename to src/features/drawer/SelectorItem.jsx index fe164e488..dc96e2ae4 100644 --- a/src/components/layout/drawer/SelectorItem.jsx +++ b/src/features/drawer/SelectorItem.jsx @@ -12,10 +12,10 @@ import { useDeepStore, useStorage } from '@hooks/useStorage' import { checkIfHasAll } from '@services/functions/hasAll' import Poracle from '@services/Poracle' -import { ColoredTile } from '../general/ColoredTile' -import { useWebhookStore } from '../../../features/webhooks/store' -import { ToggleTypography } from '../general/ToggleTypography' -import { SQUARE_ITEM } from '../general/VirtualGrid' +import { ColoredTile } from '../../components/layout/general/ColoredTile' +import { useWebhookStore } from '../webhooks/store' +import { ToggleTypography } from '../../components/layout/general/ToggleTypography' +import { SQUARE_ITEM } from '../../components/layout/general/VirtualGrid' /** * @template {string} T diff --git a/src/components/layout/drawer/SelectorList.jsx b/src/features/drawer/SelectorList.jsx similarity index 98% rename from src/components/layout/drawer/SelectorList.jsx rename to src/features/drawer/SelectorList.jsx index a4ba63dab..12563eaf2 100644 --- a/src/components/layout/drawer/SelectorList.jsx +++ b/src/features/drawer/SelectorList.jsx @@ -26,8 +26,8 @@ import useGetAvailable from '@hooks/useGetAvailable' import { BoolToggle } from './BoolToggle' import { GenericSearchMemo } from './ItemSearch' import { StandardItem } from './SelectorItem' -import { VirtualGrid } from '../general/VirtualGrid' -import TabPanel from '../general/TabPanel' +import { VirtualGrid } from '../../components/layout/general/VirtualGrid' +import TabPanel from '../../components/layout/general/TabPanel' /** * @template {keyof import('@rm/types').Available} T diff --git a/src/components/layout/drawer/Settings.jsx b/src/features/drawer/Settings.jsx similarity index 97% rename from src/components/layout/drawer/Settings.jsx rename to src/features/drawer/Settings.jsx index aa5cf16d7..e32622603 100644 --- a/src/components/layout/drawer/Settings.jsx +++ b/src/features/drawer/Settings.jsx @@ -36,8 +36,8 @@ import { import DrawerActions from './Actions' import { BoolToggle } from './BoolToggle' -import LocaleSelection from '../general/LocaleSelection' -import { DividerWithMargin } from '../general/StyledDivider' +import LocaleSelection from '../../components/layout/general/LocaleSelection' +import { DividerWithMargin } from '../../components/layout/general/StyledDivider' function FCSelect({ name, label, value, onChange, children, icon }) { return ( diff --git a/src/components/layout/drawer/areas/AreaTable.jsx b/src/features/drawer/areas/AreaTable.jsx similarity index 100% rename from src/components/layout/drawer/areas/AreaTable.jsx rename to src/features/drawer/areas/AreaTable.jsx diff --git a/src/components/layout/drawer/areas/Child.jsx b/src/features/drawer/areas/Child.jsx similarity index 100% rename from src/components/layout/drawer/areas/Child.jsx rename to src/features/drawer/areas/Child.jsx diff --git a/src/components/layout/drawer/areas/Parent.jsx b/src/features/drawer/areas/Parent.jsx similarity index 100% rename from src/components/layout/drawer/areas/Parent.jsx rename to src/features/drawer/areas/Parent.jsx diff --git a/src/components/layout/drawer/areas/index.jsx b/src/features/drawer/areas/index.jsx similarity index 100% rename from src/components/layout/drawer/areas/index.jsx rename to src/features/drawer/areas/index.jsx diff --git a/src/components/layout/drawer/Drawer.jsx b/src/features/drawer/index.jsx similarity index 88% rename from src/components/layout/drawer/Drawer.jsx rename to src/features/drawer/index.jsx index 3964753fd..72ed3f07a 100644 --- a/src/components/layout/drawer/Drawer.jsx +++ b/src/features/drawer/index.jsx @@ -2,7 +2,7 @@ import * as React from 'react' import Clear from '@mui/icons-material/Clear' import List from '@mui/material/List' -import Drawer from '@mui/material/Drawer' +import MuiDrawer from '@mui/material/Drawer' import IconButton from '@mui/material/IconButton' import ListItem from '@mui/material/ListItem' import ListItemText from '@mui/material/ListItemText' @@ -13,8 +13,8 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import Actions from './Actions' import { DrawerSectionMemo } from './Section' -import { Img } from '../general/Img' -import { DividerWithMargin } from '../general/StyledDivider' +import { Img } from '../../components/layout/general/Img' +import { DividerWithMargin } from '../../components/layout/general/StyledDivider' const handleClose = () => useLayoutStore.setState({ drawer: false }) @@ -48,12 +48,12 @@ const listItemSx = /** @type {import('@mui/material').SxProps} */ ({ display: 'block', }) -export default function Sidebar() { +export default function Drawer() { const drawer = useLayoutStore((s) => s.drawer) const { config, ui } = useMemory.getState() return ( - {config.general.separateDrawerActions && } - + ) } diff --git a/src/features/tutorial/Advanced.jsx b/src/features/tutorial/Advanced.jsx index 719814e22..f939a08f8 100644 --- a/src/features/tutorial/Advanced.jsx +++ b/src/features/tutorial/Advanced.jsx @@ -22,7 +22,7 @@ import Utility from '@services/Utility' import { useMemory } from '@hooks/useMemory' import { VirtualGrid } from '@components/layout/general/VirtualGrid' -import { StandardItem } from '@components/layout/drawer/SelectorItem' +import { StandardItem } from '@features/drawer/SelectorItem' import data from './data' export default function TutAdvanced({ toggleHelp, category }) { diff --git a/src/features/webhooks/Manage.jsx b/src/features/webhooks/Manage.jsx index dc8646168..b9fca71e5 100644 --- a/src/features/webhooks/Manage.jsx +++ b/src/features/webhooks/Manage.jsx @@ -19,7 +19,7 @@ import Header from '@components/layout/general/Header' import { apolloClient } from '@services/apollo' import Query from '@services/Query' import { allProfiles } from '@services/queries/webhook' -import { WebhookItem } from '@components/layout/drawer/SelectorItem' +import { WebhookItem } from '@features/drawer/SelectorItem' import Human from './human' import Tracked from './Tracked' diff --git a/src/features/webhooks/Tracked.jsx b/src/features/webhooks/Tracked.jsx index fc97bffb7..05e24e2f8 100644 --- a/src/features/webhooks/Tracked.jsx +++ b/src/features/webhooks/Tracked.jsx @@ -7,7 +7,7 @@ import Typography from '@mui/material/Typography' import Box from '@mui/material/Box' import { Loading } from '@components/layout/general/Loading' -import { GenericSearch } from '@components/layout/drawer/ItemSearch' +import { GenericSearch } from '@features/drawer/ItemSearch' import TrackedTile from './tiles/TrackedTile' import Selecting from './Selecting' diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index 15669629e..28a7b258e 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -2,7 +2,7 @@ import * as React from 'react' import { useMemory } from '@hooks/useMemory' -import Sidebar from '@components/layout/drawer/Drawer' +import Drawer from '@features/drawer' import FilterMenu from '@components/layout/dialogs/filters/FilterMenu' import UserOptions from '@components/layout/dialogs/UserOptions' import Tutorial from '@features/tutorial' @@ -32,7 +32,7 @@ export const Nav = React.memo( {iconsIsReady && ( <> - + From 345a27fc0a48485fb115cf1bcfce223faa0eeb1a Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:29:44 -0500 Subject: [PATCH 022/177] refactor: move holiday animations --- src/App.jsx | 2 +- src/{services => features/holiday}/HolidayAnimations.js | 0 .../HolidayEffects.jsx => features/holiday/index.jsx} | 5 +++-- 3 files changed, 4 insertions(+), 3 deletions(-) rename src/{services => features/holiday}/HolidayAnimations.js (100%) rename src/{components/HolidayEffects.jsx => features/holiday/index.jsx} (96%) diff --git a/src/App.jsx b/src/App.jsx index 7408ee795..3f9157dd5 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -16,7 +16,7 @@ import { isLocalStorageEnabled } from '@services/functions/isLocalStorageEnabled import { setLoadingText } from '@services/functions/setLoadingText' import '@services/events' import ErrorBoundary from '@components/ErrorBoundary' -import HolidayEffects from '@components/HolidayEffects' +import HolidayEffects from '@features/holiday' import ReactRouter from './pages' diff --git a/src/services/HolidayAnimations.js b/src/features/holiday/HolidayAnimations.js similarity index 100% rename from src/services/HolidayAnimations.js rename to src/features/holiday/HolidayAnimations.js diff --git a/src/components/HolidayEffects.jsx b/src/features/holiday/index.jsx similarity index 96% rename from src/components/HolidayEffects.jsx rename to src/features/holiday/index.jsx index a0e6be2cc..c8e5e3f46 100644 --- a/src/components/HolidayEffects.jsx +++ b/src/features/holiday/index.jsx @@ -1,9 +1,10 @@ // @ts-check import * as React from 'react' -import HolidayAnimations from '@services/HolidayAnimations' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' +import HolidayAnimations from './HolidayAnimations' + /** * * @param {import("@rm/types").Config['map']['holidayEffects'][number]} props @@ -57,7 +58,7 @@ export function HolidayEffect({ images, name, css, imageScale }) { } export default function HolidayEffects() { - const holidayEffects = useMemory((s) => s?.config?.holidayEffects || []) + const holidayEffects = useMemory((s) => s?.config?.holidayEffects) return ( <> From d736c65cf3c4646cec90793437a28dbf0ba38e34 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:34:29 -0500 Subject: [PATCH 023/177] refactor: move everything out of `src/components/layout` --- src/components/ErrorBoundary.jsx | 2 +- src/components/{layout => }/auth/Discord.jsx | 0 src/components/{layout => }/auth/Local.jsx | 0 src/components/{layout => }/auth/Telegram.jsx | 0 .../{layout => }/custom/AdvancedAccordion.jsx | 0 .../{layout => }/custom/CustomButton.jsx | 0 .../{layout => }/custom/CustomText.jsx | 0 .../{layout => }/custom/CustomTile.jsx | 0 .../{layout => }/custom/DialogWrapper.jsx | 0 .../{layout => }/custom/Generator.jsx | 0 .../{layout => }/custom/LinkWrapper.jsx | 0 .../{layout => }/dialogs/BadgeSelection.jsx | 0 .../{layout => }/dialogs/ClientError.jsx | 0 .../{layout => }/dialogs/DialogWrapper.jsx | 0 .../{layout => }/dialogs/DonorPage.jsx | 0 .../{layout => }/dialogs/Feedback.jsx | 0 src/components/{layout => }/dialogs/Help.jsx | 0 src/components/{layout => }/dialogs/Motd.jsx | 0 .../{layout => }/dialogs/NestSubmission.jsx | 0 .../{layout => }/dialogs/ResetFilters.jsx | 0 .../{layout => }/dialogs/UserOptions.jsx | 2 +- .../{layout => }/dialogs/filters/Advanced.jsx | 6 ++--- .../dialogs/filters/FilterMenu.jsx | 4 ++-- .../{layout => }/dialogs/filters/Gender.jsx | 0 .../{layout => }/dialogs/filters/MenuTile.jsx | 0 .../{layout => }/dialogs/filters/Options.jsx | 0 .../dialogs/filters/OptionsContainer.jsx | 2 +- .../dialogs/filters/PkmnFilterHelp.jsx | 6 ++--- .../dialogs/filters/QuestConditions.jsx | 2 +- .../{layout => }/dialogs/filters/Size.jsx | 0 .../dialogs/filters/SliderTile.jsx | 2 +- .../dialogs/filters/SlotSelection.jsx | 8 +++---- .../dialogs/filters/StringFilter.jsx | 0 .../{layout => }/general/BasicListButton.jsx | 0 .../{layout => }/general/ColoredTile.jsx | 0 .../{layout => }/general/Footer.jsx | 0 .../{layout => }/general/Header.jsx | 0 src/components/{layout => }/general/I.jsx | 0 src/components/{layout => }/general/Icons.jsx | 0 src/components/{layout => }/general/Img.jsx | 0 .../{layout => }/general/Loading.jsx | 0 .../{layout => }/general/LocaleSelection.jsx | 0 src/components/{layout => }/general/Menu.jsx | 12 +++++----- .../{layout => }/general/Notification.jsx | 0 .../{layout => }/general/QuestTitle.jsx | 0 .../{layout => }/general/StyledDivider.jsx | 0 .../{layout => }/general/TabPanel.jsx | 0 .../{layout => }/general/ThemeToggle.jsx | 0 .../{layout => }/general/ToggleTypography.jsx | 0 .../{layout => }/general/VirtualGrid.jsx | 0 src/components/popups/Gym.jsx | 2 +- src/components/popups/Nest.jsx | 2 +- src/components/popups/Pokemon.jsx | 2 +- src/components/popups/Pokestop.jsx | 2 +- src/components/tiles/S2Cell.jsx | 2 +- src/features/drawer/Actions.jsx | 4 ++-- src/features/drawer/Extras.jsx | 2 +- src/features/drawer/Pokemon.jsx | 13 +++++----- src/features/drawer/Section.jsx | 2 +- src/features/drawer/SelectorItem.jsx | 7 +++--- src/features/drawer/SelectorList.jsx | 4 ++-- src/features/drawer/Settings.jsx | 4 ++-- src/features/drawer/areas/index.jsx | 2 +- src/features/drawer/index.jsx | 4 ++-- src/features/profile/GymBadges.jsx | 6 ++--- src/features/profile/LinkAccounts.jsx | 6 ++--- src/features/profile/index.jsx | 6 ++--- src/features/scanner/Popup.jsx | 2 +- src/features/scanner/ScanDialog.jsx | 6 ++--- .../scanner/scanZone/PopupContent.jsx | 2 +- src/features/search/OptionImage.jsx | 2 +- src/features/search/index.jsx | 2 +- src/features/search/renderInput.jsx | 2 +- src/features/search/renderOption.jsx | 4 ++-- src/features/tutorial/Advanced.jsx | 2 +- src/features/tutorial/Sliders.jsx | 2 +- src/features/tutorial/Welcome.jsx | 2 +- src/features/tutorial/index.jsx | 2 +- src/features/webhooks/Manage.jsx | 8 +++---- src/features/webhooks/Notification.jsx | 2 +- src/features/webhooks/Tracked.jsx | 2 +- src/features/webhooks/WebhookAdv.jsx | 6 ++--- src/features/webhooks/human/Location.jsx | 2 +- .../webhooks/human/area/AreaGroup.jsx | 2 +- .../webhooks/human/area/AreaSelection.jsx | 2 +- src/features/webhooks/human/profile/index.jsx | 2 +- .../webhooks/human/status/HookSelection.jsx | 2 +- src/pages/Blocked.jsx | 6 ++--- src/pages/data/components/Shared.jsx | 2 +- src/pages/login/CustomPage.jsx | 4 ++-- src/pages/login/DefaultPage.jsx | 2 +- src/pages/login/Methods.jsx | 6 ++--- src/pages/login/index.jsx | 2 +- src/pages/map/components/ActiveWeather.jsx | 8 +++---- src/pages/map/components/Clustering.jsx | 2 +- src/pages/map/components/FloatingBtn.jsx | 2 +- src/pages/map/components/Nav.jsx | 24 +++++++++---------- src/pages/map/components/QueryData.jsx | 6 ++--- src/pages/playground/components/Viewer.jsx | 4 ++-- 99 files changed, 121 insertions(+), 119 deletions(-) rename src/components/{layout => }/auth/Discord.jsx (100%) rename src/components/{layout => }/auth/Local.jsx (100%) rename src/components/{layout => }/auth/Telegram.jsx (100%) rename src/components/{layout => }/custom/AdvancedAccordion.jsx (100%) rename src/components/{layout => }/custom/CustomButton.jsx (100%) rename src/components/{layout => }/custom/CustomText.jsx (100%) rename src/components/{layout => }/custom/CustomTile.jsx (100%) rename src/components/{layout => }/custom/DialogWrapper.jsx (100%) rename src/components/{layout => }/custom/Generator.jsx (100%) rename src/components/{layout => }/custom/LinkWrapper.jsx (100%) rename src/components/{layout => }/dialogs/BadgeSelection.jsx (100%) rename src/components/{layout => }/dialogs/ClientError.jsx (100%) rename src/components/{layout => }/dialogs/DialogWrapper.jsx (100%) rename src/components/{layout => }/dialogs/DonorPage.jsx (100%) rename src/components/{layout => }/dialogs/Feedback.jsx (100%) rename src/components/{layout => }/dialogs/Help.jsx (100%) rename src/components/{layout => }/dialogs/Motd.jsx (100%) rename src/components/{layout => }/dialogs/NestSubmission.jsx (100%) rename src/components/{layout => }/dialogs/ResetFilters.jsx (100%) rename src/components/{layout => }/dialogs/UserOptions.jsx (98%) rename src/components/{layout => }/dialogs/filters/Advanced.jsx (97%) rename src/components/{layout => }/dialogs/filters/FilterMenu.jsx (91%) rename src/components/{layout => }/dialogs/filters/Gender.jsx (100%) rename src/components/{layout => }/dialogs/filters/MenuTile.jsx (100%) rename src/components/{layout => }/dialogs/filters/Options.jsx (100%) rename src/components/{layout => }/dialogs/filters/OptionsContainer.jsx (97%) rename src/components/{layout => }/dialogs/filters/PkmnFilterHelp.jsx (96%) rename src/components/{layout => }/dialogs/filters/QuestConditions.jsx (98%) rename src/components/{layout => }/dialogs/filters/Size.jsx (100%) rename src/components/{layout => }/dialogs/filters/SliderTile.jsx (98%) rename src/components/{layout => }/dialogs/filters/SlotSelection.jsx (95%) rename src/components/{layout => }/dialogs/filters/StringFilter.jsx (100%) rename src/components/{layout => }/general/BasicListButton.jsx (100%) rename src/components/{layout => }/general/ColoredTile.jsx (100%) rename src/components/{layout => }/general/Footer.jsx (100%) rename src/components/{layout => }/general/Header.jsx (100%) rename src/components/{layout => }/general/I.jsx (100%) rename src/components/{layout => }/general/Icons.jsx (100%) rename src/components/{layout => }/general/Img.jsx (100%) rename src/components/{layout => }/general/Loading.jsx (100%) rename src/components/{layout => }/general/LocaleSelection.jsx (100%) rename src/components/{layout => }/general/Menu.jsx (93%) rename src/components/{layout => }/general/Notification.jsx (100%) rename src/components/{layout => }/general/QuestTitle.jsx (100%) rename src/components/{layout => }/general/StyledDivider.jsx (100%) rename src/components/{layout => }/general/TabPanel.jsx (100%) rename src/components/{layout => }/general/ThemeToggle.jsx (100%) rename src/components/{layout => }/general/ToggleTypography.jsx (100%) rename src/components/{layout => }/general/VirtualGrid.jsx (100%) diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx index 014a7e8ae..81d6c27af 100644 --- a/src/components/ErrorBoundary.jsx +++ b/src/components/ErrorBoundary.jsx @@ -12,7 +12,7 @@ import IconButton from '@mui/material/IconButton' import { withTranslation } from 'react-i18next' import Fetch from '@services/Fetch' -import Notification from './layout/general/Notification' +import Notification from './general/Notification' /** @type {React.CSSProperties} */ const defaultStyle = { diff --git a/src/components/layout/auth/Discord.jsx b/src/components/auth/Discord.jsx similarity index 100% rename from src/components/layout/auth/Discord.jsx rename to src/components/auth/Discord.jsx diff --git a/src/components/layout/auth/Local.jsx b/src/components/auth/Local.jsx similarity index 100% rename from src/components/layout/auth/Local.jsx rename to src/components/auth/Local.jsx diff --git a/src/components/layout/auth/Telegram.jsx b/src/components/auth/Telegram.jsx similarity index 100% rename from src/components/layout/auth/Telegram.jsx rename to src/components/auth/Telegram.jsx diff --git a/src/components/layout/custom/AdvancedAccordion.jsx b/src/components/custom/AdvancedAccordion.jsx similarity index 100% rename from src/components/layout/custom/AdvancedAccordion.jsx rename to src/components/custom/AdvancedAccordion.jsx diff --git a/src/components/layout/custom/CustomButton.jsx b/src/components/custom/CustomButton.jsx similarity index 100% rename from src/components/layout/custom/CustomButton.jsx rename to src/components/custom/CustomButton.jsx diff --git a/src/components/layout/custom/CustomText.jsx b/src/components/custom/CustomText.jsx similarity index 100% rename from src/components/layout/custom/CustomText.jsx rename to src/components/custom/CustomText.jsx diff --git a/src/components/layout/custom/CustomTile.jsx b/src/components/custom/CustomTile.jsx similarity index 100% rename from src/components/layout/custom/CustomTile.jsx rename to src/components/custom/CustomTile.jsx diff --git a/src/components/layout/custom/DialogWrapper.jsx b/src/components/custom/DialogWrapper.jsx similarity index 100% rename from src/components/layout/custom/DialogWrapper.jsx rename to src/components/custom/DialogWrapper.jsx diff --git a/src/components/layout/custom/Generator.jsx b/src/components/custom/Generator.jsx similarity index 100% rename from src/components/layout/custom/Generator.jsx rename to src/components/custom/Generator.jsx diff --git a/src/components/layout/custom/LinkWrapper.jsx b/src/components/custom/LinkWrapper.jsx similarity index 100% rename from src/components/layout/custom/LinkWrapper.jsx rename to src/components/custom/LinkWrapper.jsx diff --git a/src/components/layout/dialogs/BadgeSelection.jsx b/src/components/dialogs/BadgeSelection.jsx similarity index 100% rename from src/components/layout/dialogs/BadgeSelection.jsx rename to src/components/dialogs/BadgeSelection.jsx diff --git a/src/components/layout/dialogs/ClientError.jsx b/src/components/dialogs/ClientError.jsx similarity index 100% rename from src/components/layout/dialogs/ClientError.jsx rename to src/components/dialogs/ClientError.jsx diff --git a/src/components/layout/dialogs/DialogWrapper.jsx b/src/components/dialogs/DialogWrapper.jsx similarity index 100% rename from src/components/layout/dialogs/DialogWrapper.jsx rename to src/components/dialogs/DialogWrapper.jsx diff --git a/src/components/layout/dialogs/DonorPage.jsx b/src/components/dialogs/DonorPage.jsx similarity index 100% rename from src/components/layout/dialogs/DonorPage.jsx rename to src/components/dialogs/DonorPage.jsx diff --git a/src/components/layout/dialogs/Feedback.jsx b/src/components/dialogs/Feedback.jsx similarity index 100% rename from src/components/layout/dialogs/Feedback.jsx rename to src/components/dialogs/Feedback.jsx diff --git a/src/components/layout/dialogs/Help.jsx b/src/components/dialogs/Help.jsx similarity index 100% rename from src/components/layout/dialogs/Help.jsx rename to src/components/dialogs/Help.jsx diff --git a/src/components/layout/dialogs/Motd.jsx b/src/components/dialogs/Motd.jsx similarity index 100% rename from src/components/layout/dialogs/Motd.jsx rename to src/components/dialogs/Motd.jsx diff --git a/src/components/layout/dialogs/NestSubmission.jsx b/src/components/dialogs/NestSubmission.jsx similarity index 100% rename from src/components/layout/dialogs/NestSubmission.jsx rename to src/components/dialogs/NestSubmission.jsx diff --git a/src/components/layout/dialogs/ResetFilters.jsx b/src/components/dialogs/ResetFilters.jsx similarity index 100% rename from src/components/layout/dialogs/ResetFilters.jsx rename to src/components/dialogs/ResetFilters.jsx diff --git a/src/components/layout/dialogs/UserOptions.jsx b/src/components/dialogs/UserOptions.jsx similarity index 98% rename from src/components/layout/dialogs/UserOptions.jsx rename to src/components/dialogs/UserOptions.jsx index da0bd7714..709fdcfd9 100644 --- a/src/components/layout/dialogs/UserOptions.jsx +++ b/src/components/dialogs/UserOptions.jsx @@ -101,7 +101,7 @@ function UserOptions() { const footerOptions = React.useMemo( () => - /** @type {import('@components/layout/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/general/Footer').FooterButton[]} */ ([ { name: 'reset', action: () => { diff --git a/src/components/layout/dialogs/filters/Advanced.jsx b/src/components/dialogs/filters/Advanced.jsx similarity index 97% rename from src/components/layout/dialogs/filters/Advanced.jsx rename to src/components/dialogs/filters/Advanced.jsx index 97470bd94..7a1ae17e0 100644 --- a/src/components/layout/dialogs/filters/Advanced.jsx +++ b/src/components/dialogs/filters/Advanced.jsx @@ -8,8 +8,8 @@ import Utility from '@services/Utility' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useDeepStore, useStorage } from '@hooks/useStorage' -import Header from '@components/layout/general/Header' -import Footer from '@components/layout/general/Footer' +import Header from '@components/general/Header' +import Footer from '@components/general/Footer' import { BoolToggle, DualBoolToggle } from '@features/drawer/BoolToggle' import { ENABLED_ALL, XXS_XXL } from '@assets/constants' import { useTranslateById } from '@hooks/useTranslateById' @@ -79,7 +79,7 @@ export default function AdvancedFilter() { } } - /** @type {import('@components/layout/general/Footer').FooterButton[]} */ + /** @type {import('@components/general/Footer').FooterButton[]} */ const footerOptions = React.useMemo( () => [ { diff --git a/src/components/layout/dialogs/filters/FilterMenu.jsx b/src/components/dialogs/filters/FilterMenu.jsx similarity index 91% rename from src/components/layout/dialogs/filters/FilterMenu.jsx rename to src/components/dialogs/filters/FilterMenu.jsx index 89b9ddafb..72a74bb4a 100644 --- a/src/components/layout/dialogs/filters/FilterMenu.jsx +++ b/src/components/dialogs/filters/FilterMenu.jsx @@ -1,6 +1,6 @@ // @ts-check import * as React from 'react' -import Menu from '@components/layout/general/Menu' +import Menu from '@components/general/Menu' import { toggleDialog, useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' @@ -16,7 +16,7 @@ export default function FilterMenu() { const extraButtons = React.useMemo( () => - /** @type {import('@components/layout/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/general/Footer').FooterButton[]} */ ([ { name: 'close', action: toggleDialog(false, category, 'filters'), diff --git a/src/components/layout/dialogs/filters/Gender.jsx b/src/components/dialogs/filters/Gender.jsx similarity index 100% rename from src/components/layout/dialogs/filters/Gender.jsx rename to src/components/dialogs/filters/Gender.jsx diff --git a/src/components/layout/dialogs/filters/MenuTile.jsx b/src/components/dialogs/filters/MenuTile.jsx similarity index 100% rename from src/components/layout/dialogs/filters/MenuTile.jsx rename to src/components/dialogs/filters/MenuTile.jsx diff --git a/src/components/layout/dialogs/filters/Options.jsx b/src/components/dialogs/filters/Options.jsx similarity index 100% rename from src/components/layout/dialogs/filters/Options.jsx rename to src/components/dialogs/filters/Options.jsx diff --git a/src/components/layout/dialogs/filters/OptionsContainer.jsx b/src/components/dialogs/filters/OptionsContainer.jsx similarity index 97% rename from src/components/layout/dialogs/filters/OptionsContainer.jsx rename to src/components/dialogs/filters/OptionsContainer.jsx index dc101bd60..0e1abe443 100644 --- a/src/components/layout/dialogs/filters/OptionsContainer.jsx +++ b/src/components/dialogs/filters/OptionsContainer.jsx @@ -9,7 +9,7 @@ import ReplayIcon from '@mui/icons-material/Replay' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' -import { BasicListButton } from '@components/layout/general/BasicListButton' +import { BasicListButton } from '@components/general/BasicListButton' import Options from './Options' diff --git a/src/components/layout/dialogs/filters/PkmnFilterHelp.jsx b/src/components/dialogs/filters/PkmnFilterHelp.jsx similarity index 96% rename from src/components/layout/dialogs/filters/PkmnFilterHelp.jsx rename to src/components/dialogs/filters/PkmnFilterHelp.jsx index ca9fd855a..4d2abe4cc 100644 --- a/src/components/layout/dialogs/filters/PkmnFilterHelp.jsx +++ b/src/components/dialogs/filters/PkmnFilterHelp.jsx @@ -7,8 +7,8 @@ import Grid2 from '@mui/material/Unstable_Grid2' import { useTranslation } from 'react-i18next' import { Chip, Divider, useMediaQuery } from '@mui/material' -import Header from '@components/layout/general/Header' -import Footer from '@components/layout/general/Footer' +import Header from '@components/general/Header' +import Footer from '@components/general/Footer' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' @@ -94,7 +94,7 @@ function Card({ title, children, bgcolor, fullSize }) { const handleClose = () => useLayoutStore.setState({ pkmnFilterHelp: false }) const OPTIONS = - /** @type {import('@components/layout/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/general/Footer').FooterButton[]} */ ([ { name: 'close', color: 'error', action: handleClose }, ]) diff --git a/src/components/layout/dialogs/filters/QuestConditions.jsx b/src/components/dialogs/filters/QuestConditions.jsx similarity index 98% rename from src/components/layout/dialogs/filters/QuestConditions.jsx rename to src/components/dialogs/filters/QuestConditions.jsx index 67df5f22b..ad17b3d8f 100644 --- a/src/components/layout/dialogs/filters/QuestConditions.jsx +++ b/src/components/dialogs/filters/QuestConditions.jsx @@ -6,7 +6,7 @@ import { useMemory } from '@hooks/useMemory' import { useDeepStore, useStorage } from '@hooks/useStorage' import { FormControl, InputLabel, Select, MenuItem } from '@mui/material' import Typography from '@mui/material/Typography' -import QuestTitle from '@components/layout/general/QuestTitle' +import QuestTitle from '@components/general/QuestTitle' /** * diff --git a/src/components/layout/dialogs/filters/Size.jsx b/src/components/dialogs/filters/Size.jsx similarity index 100% rename from src/components/layout/dialogs/filters/Size.jsx rename to src/components/dialogs/filters/Size.jsx diff --git a/src/components/layout/dialogs/filters/SliderTile.jsx b/src/components/dialogs/filters/SliderTile.jsx similarity index 98% rename from src/components/layout/dialogs/filters/SliderTile.jsx rename to src/components/dialogs/filters/SliderTile.jsx index 81521d662..42eef08cf 100644 --- a/src/components/layout/dialogs/filters/SliderTile.jsx +++ b/src/components/dialogs/filters/SliderTile.jsx @@ -6,7 +6,7 @@ import TextField from '@mui/material/TextField' import Slider from '@mui/material/Slider' import { styled } from '@mui/material/styles' import { useTranslation } from 'react-i18next' -import { ToggleTypography } from '@components/layout/general/ToggleTypography' +import { ToggleTypography } from '@components/general/ToggleTypography' import { MIN_MAX } from '@assets/constants' const StyledTextField = diff --git a/src/components/layout/dialogs/filters/SlotSelection.jsx b/src/components/dialogs/filters/SlotSelection.jsx similarity index 95% rename from src/components/layout/dialogs/filters/SlotSelection.jsx rename to src/components/dialogs/filters/SlotSelection.jsx index 909bf2137..9da401305 100644 --- a/src/components/layout/dialogs/filters/SlotSelection.jsx +++ b/src/components/dialogs/filters/SlotSelection.jsx @@ -10,11 +10,11 @@ import Divider from '@mui/material/Divider' import { basicEqualFn, useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage, useDeepStore } from '@hooks/useStorage' -import { Img } from '@components/layout/general/Img' +import { Img } from '@components/general/Img' import { DualBoolToggle } from '@features/drawer/BoolToggle' import { ENABLED_ALL } from '@assets/constants' -import Header from '@components/layout/general/Header' -import Footer from '@components/layout/general/Footer' +import Header from '@components/general/Header' +import Footer from '@components/general/Footer' import Size from './Size' import { DialogWrapper } from '../DialogWrapper' @@ -67,7 +67,7 @@ export default function SlotSelection() { const footerOptions = React.useMemo( () => - /** @type {import('@components/layout/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/general/Footer').FooterButton[]} */ ([ { name: 'disable_all', action: () => handleSizeChange(false, id), diff --git a/src/components/layout/dialogs/filters/StringFilter.jsx b/src/components/dialogs/filters/StringFilter.jsx similarity index 100% rename from src/components/layout/dialogs/filters/StringFilter.jsx rename to src/components/dialogs/filters/StringFilter.jsx diff --git a/src/components/layout/general/BasicListButton.jsx b/src/components/general/BasicListButton.jsx similarity index 100% rename from src/components/layout/general/BasicListButton.jsx rename to src/components/general/BasicListButton.jsx diff --git a/src/components/layout/general/ColoredTile.jsx b/src/components/general/ColoredTile.jsx similarity index 100% rename from src/components/layout/general/ColoredTile.jsx rename to src/components/general/ColoredTile.jsx diff --git a/src/components/layout/general/Footer.jsx b/src/components/general/Footer.jsx similarity index 100% rename from src/components/layout/general/Footer.jsx rename to src/components/general/Footer.jsx diff --git a/src/components/layout/general/Header.jsx b/src/components/general/Header.jsx similarity index 100% rename from src/components/layout/general/Header.jsx rename to src/components/general/Header.jsx diff --git a/src/components/layout/general/I.jsx b/src/components/general/I.jsx similarity index 100% rename from src/components/layout/general/I.jsx rename to src/components/general/I.jsx diff --git a/src/components/layout/general/Icons.jsx b/src/components/general/Icons.jsx similarity index 100% rename from src/components/layout/general/Icons.jsx rename to src/components/general/Icons.jsx diff --git a/src/components/layout/general/Img.jsx b/src/components/general/Img.jsx similarity index 100% rename from src/components/layout/general/Img.jsx rename to src/components/general/Img.jsx diff --git a/src/components/layout/general/Loading.jsx b/src/components/general/Loading.jsx similarity index 100% rename from src/components/layout/general/Loading.jsx rename to src/components/general/Loading.jsx diff --git a/src/components/layout/general/LocaleSelection.jsx b/src/components/general/LocaleSelection.jsx similarity index 100% rename from src/components/layout/general/LocaleSelection.jsx rename to src/components/general/LocaleSelection.jsx diff --git a/src/components/layout/general/Menu.jsx b/src/components/general/Menu.jsx similarity index 93% rename from src/components/layout/general/Menu.jsx rename to src/components/general/Menu.jsx index 6b4bf4902..f2be91390 100644 --- a/src/components/layout/general/Menu.jsx +++ b/src/components/general/Menu.jsx @@ -11,18 +11,18 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import useFilter from '@hooks/useFilter' -import Header from '@components/layout/general/Header' -import Footer from '@components/layout/general/Footer' +import Header from '@components/general/Header' +import Footer from '@components/general/Footer' import { applyToAll } from '@services/filtering/applyToAll' import useGetAvailable from '@hooks/useGetAvailable' import OptionsContainer from '../dialogs/filters/OptionsContainer' import { VirtualGrid } from './VirtualGrid' -import { GenericSearch } from '../../../features/drawer/ItemSearch' +import { GenericSearch } from '../../features/drawer/ItemSearch' import { applyToAllWebhooks, useWebhookStore, -} from '../../../features/webhooks/store' +} from '../../features/webhooks/store' /** * @template {import('@rm/types').AdvCategories} T @@ -34,7 +34,7 @@ import { * categories?: import('@rm/types').Available[] * title: string * titleAction: () => void - * extraButtons?: import('@components/layout/general/Footer').FooterButton[] + * extraButtons?: import('@components/general/Footer').FooterButton[] * }} props */ export default function Menu({ @@ -79,7 +79,7 @@ export default function Menu({ const footerButtons = React.useMemo( () => - /** @type {import('@components/layout/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/general/Footer').FooterButton[]} */ ([ { name: 'help', action: () => diff --git a/src/components/layout/general/Notification.jsx b/src/components/general/Notification.jsx similarity index 100% rename from src/components/layout/general/Notification.jsx rename to src/components/general/Notification.jsx diff --git a/src/components/layout/general/QuestTitle.jsx b/src/components/general/QuestTitle.jsx similarity index 100% rename from src/components/layout/general/QuestTitle.jsx rename to src/components/general/QuestTitle.jsx diff --git a/src/components/layout/general/StyledDivider.jsx b/src/components/general/StyledDivider.jsx similarity index 100% rename from src/components/layout/general/StyledDivider.jsx rename to src/components/general/StyledDivider.jsx diff --git a/src/components/layout/general/TabPanel.jsx b/src/components/general/TabPanel.jsx similarity index 100% rename from src/components/layout/general/TabPanel.jsx rename to src/components/general/TabPanel.jsx diff --git a/src/components/layout/general/ThemeToggle.jsx b/src/components/general/ThemeToggle.jsx similarity index 100% rename from src/components/layout/general/ThemeToggle.jsx rename to src/components/general/ThemeToggle.jsx diff --git a/src/components/layout/general/ToggleTypography.jsx b/src/components/general/ToggleTypography.jsx similarity index 100% rename from src/components/layout/general/ToggleTypography.jsx rename to src/components/general/ToggleTypography.jsx diff --git a/src/components/layout/general/VirtualGrid.jsx b/src/components/general/VirtualGrid.jsx similarity index 100% rename from src/components/layout/general/VirtualGrid.jsx rename to src/components/general/VirtualGrid.jsx diff --git a/src/components/popups/Gym.jsx b/src/components/popups/Gym.jsx index 03e00fb52..e33ea6c07 100644 --- a/src/components/popups/Gym.jsx +++ b/src/components/popups/Gym.jsx @@ -21,7 +21,7 @@ import { setDeepStore, useStorage } from '@hooks/useStorage' import useWebhook from '@hooks/useWebhook' import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' -import { TextWithIcon } from '@components/layout/general/Img' +import { TextWithIcon } from '@components/general/Img' import Title from './common/Title' import PowerUp from './common/PowerUp' diff --git a/src/components/popups/Nest.jsx b/src/components/popups/Nest.jsx index ee844a4da..f9aac66e4 100644 --- a/src/components/popups/Nest.jsx +++ b/src/components/popups/Nest.jsx @@ -18,7 +18,7 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import { setDeepStore } from '@hooks/useStorage' import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' -import NestSubmission from '@components/layout/dialogs/NestSubmission' +import NestSubmission from '@components/dialogs/NestSubmission' const getColor = (timeSince) => { let color = 'success' diff --git a/src/components/popups/Pokemon.jsx b/src/components/popups/Pokemon.jsx index e10fc8d53..083f06a8a 100644 --- a/src/components/popups/Pokemon.jsx +++ b/src/components/popups/Pokemon.jsx @@ -22,7 +22,7 @@ import { useMemory } from '@hooks/useMemory' import { setDeepStore, useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' -import { TextWithIcon } from '@components/layout/general/Img' +import { TextWithIcon } from '@components/general/Img' import NameTT from './common/NameTT' import GenderIcon from './common/GenderIcon' diff --git a/src/components/popups/Pokestop.jsx b/src/components/popups/Pokestop.jsx index 3068ef69e..aecb37e04 100644 --- a/src/components/popups/Pokestop.jsx +++ b/src/components/popups/Pokestop.jsx @@ -18,7 +18,7 @@ import { import { useTranslation, Trans } from 'react-i18next' import ErrorBoundary from '@components/ErrorBoundary' -import { Check, Help } from '@components/layout/general/Icons' +import { Check, Help } from '@components/general/Icons' import { useMemory } from '@hooks/useMemory' import { setDeepStore, useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' diff --git a/src/components/tiles/S2Cell.jsx b/src/components/tiles/S2Cell.jsx index 2dd40f74e..ea684bf3f 100644 --- a/src/components/tiles/S2Cell.jsx +++ b/src/components/tiles/S2Cell.jsx @@ -12,7 +12,7 @@ import { import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import Notification from '@components/layout/general/Notification' +import Notification from '@components/general/Notification' import { getQueryArgs } from '@services/functions/getQueryArgs' /** diff --git a/src/features/drawer/Actions.jsx b/src/features/drawer/Actions.jsx index 3370a56b0..a5ed9936a 100644 --- a/src/features/drawer/Actions.jsx +++ b/src/features/drawer/Actions.jsx @@ -19,8 +19,8 @@ import { useMapStore } from '@hooks/useMapStore' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' -import { I } from '../../components/layout/general/I' -import { BasicListButton } from '../../components/layout/general/BasicListButton' +import { I } from '@components/general/I' +import { BasicListButton } from '@components/general/BasicListButton' /** @type {React.ChangeEventHandler} */ const importSettings = (e) => { diff --git a/src/features/drawer/Extras.jsx b/src/features/drawer/Extras.jsx index 0f0fe5c85..0bb390866 100644 --- a/src/features/drawer/Extras.jsx +++ b/src/features/drawer/Extras.jsx @@ -19,9 +19,9 @@ import { ENUM_TTH, WAYFARER_OPTIONS, } from '@assets/constants' +import SliderTile from '@components/dialogs/filters/SliderTile' import { MultiSelectorStore } from './MultiSelector' -import SliderTile from '../../components/layout/dialogs/filters/SliderTile' import { CollapsibleItem } from './CollapsibleItem' import { MultiSelectorList, SelectorListMemo } from './SelectorList' import { BoolToggle } from './BoolToggle' diff --git a/src/features/drawer/Pokemon.jsx b/src/features/drawer/Pokemon.jsx index df1b6fcc1..6cf7840fc 100644 --- a/src/features/drawer/Pokemon.jsx +++ b/src/features/drawer/Pokemon.jsx @@ -25,13 +25,14 @@ import Utility from '@services/Utility' import { XXS_XXL, NUNDO_HUNDO } from '@assets/constants' import { useLayoutStore } from '@hooks/useLayoutStore' -import { StringFilterMemo } from '../../components/layout/dialogs/filters/StringFilter' -import SliderTile from '../../components/layout/dialogs/filters/SliderTile' -import TabPanel from '../../components/layout/general/TabPanel' -import { BoolToggle, DualBoolToggle } from './BoolToggle' -import { GenderListItem } from '../../components/layout/dialogs/filters/Gender' +import { StringFilterMemo } from '@components/dialogs/filters/StringFilter' +import SliderTile from '@components/dialogs/filters/SliderTile' +import TabPanel from '@components/general/TabPanel' +import { GenderListItem } from '@components/dialogs/filters/Gender' +import { BasicListButton } from '@components/general/BasicListButton' + import { SelectorListMemo } from './SelectorList' -import { BasicListButton } from '../../components/layout/general/BasicListButton' +import { BoolToggle, DualBoolToggle } from './BoolToggle' function PokemonDrawer() { const filterMode = useStorage((s) => s.getPokemonFilterMode()) diff --git a/src/features/drawer/Section.jsx b/src/features/drawer/Section.jsx index 2b6d53893..1ff78107c 100644 --- a/src/features/drawer/Section.jsx +++ b/src/features/drawer/Section.jsx @@ -15,13 +15,13 @@ import { useMemory } from '@hooks/useMemory' import { toggleDialog, useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' +import { BasicListButton } from '@components/general/BasicListButton' import SettingsMenu from './Settings' import { PokemonDrawerMemo } from './Pokemon' import Areas from './areas' import Extras from './Extras' import { BoolToggle } from './BoolToggle' -import { BasicListButton } from '../../components/layout/general/BasicListButton' const ADV_CATEGORIES = new Set(['pokemon', 'gyms', 'pokestops', 'nests']) diff --git a/src/features/drawer/SelectorItem.jsx b/src/features/drawer/SelectorItem.jsx index dc96e2ae4..30da1baaf 100644 --- a/src/features/drawer/SelectorItem.jsx +++ b/src/features/drawer/SelectorItem.jsx @@ -11,11 +11,11 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import { useDeepStore, useStorage } from '@hooks/useStorage' import { checkIfHasAll } from '@services/functions/hasAll' import Poracle from '@services/Poracle' +import { ColoredTile } from '@components/general/ColoredTile' +import { ToggleTypography } from '@components/general/ToggleTypography' +import { SQUARE_ITEM } from '@components/general/VirtualGrid' -import { ColoredTile } from '../../components/layout/general/ColoredTile' import { useWebhookStore } from '../webhooks/store' -import { ToggleTypography } from '../../components/layout/general/ToggleTypography' -import { SQUARE_ITEM } from '../../components/layout/general/VirtualGrid' /** * @template {string} T @@ -96,6 +96,7 @@ export function WebhookItem({ id, category, ...props }) { useWebhookStore.setState({ advanced: { id, + uid: 0, open: true, category, selectedIds: [], diff --git a/src/features/drawer/SelectorList.jsx b/src/features/drawer/SelectorList.jsx index 12563eaf2..f056c89c5 100644 --- a/src/features/drawer/SelectorList.jsx +++ b/src/features/drawer/SelectorList.jsx @@ -22,12 +22,12 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useDeepStore, useStorage } from '@hooks/useStorage' import useGetAvailable from '@hooks/useGetAvailable' +import { VirtualGrid } from '@components/general/VirtualGrid' +import TabPanel from '@components/general/TabPanel' import { BoolToggle } from './BoolToggle' import { GenericSearchMemo } from './ItemSearch' import { StandardItem } from './SelectorItem' -import { VirtualGrid } from '../../components/layout/general/VirtualGrid' -import TabPanel from '../../components/layout/general/TabPanel' /** * @template {keyof import('@rm/types').Available} T diff --git a/src/features/drawer/Settings.jsx b/src/features/drawer/Settings.jsx index e32622603..bf79f99b4 100644 --- a/src/features/drawer/Settings.jsx +++ b/src/features/drawer/Settings.jsx @@ -33,11 +33,11 @@ import { getPermission, requestPermission, } from '@services/desktopNotification' +import LocaleSelection from '@components/general/LocaleSelection' +import { DividerWithMargin } from '@components/general/StyledDivider' import DrawerActions from './Actions' import { BoolToggle } from './BoolToggle' -import LocaleSelection from '../../components/layout/general/LocaleSelection' -import { DividerWithMargin } from '../../components/layout/general/StyledDivider' function FCSelect({ name, label, value, onChange, children, icon }) { return ( diff --git a/src/features/drawer/areas/index.jsx b/src/features/drawer/areas/index.jsx index 8642da9b4..33adc1fd3 100644 --- a/src/features/drawer/areas/index.jsx +++ b/src/features/drawer/areas/index.jsx @@ -4,7 +4,7 @@ import ListItem from '@mui/material/ListItem' import RestartAltIcon from '@mui/icons-material/RestartAlt' import { useStorage } from '@hooks/useStorage' -import { BasicListButton } from '@components/layout/general/BasicListButton' +import { BasicListButton } from '@components/general/BasicListButton' import { GenericSearch } from '../ItemSearch' import { ScanAreasTable } from './AreaTable' diff --git a/src/features/drawer/index.jsx b/src/features/drawer/index.jsx index 72ed3f07a..98c07edeb 100644 --- a/src/features/drawer/index.jsx +++ b/src/features/drawer/index.jsx @@ -10,11 +10,11 @@ import ListItemIcon from '@mui/material/ListItemIcon' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' +import { Img } from '@components/general/Img' +import { DividerWithMargin } from '@components/general/StyledDivider' import Actions from './Actions' import { DrawerSectionMemo } from './Section' -import { Img } from '../../components/layout/general/Img' -import { DividerWithMargin } from '../../components/layout/general/StyledDivider' const handleClose = () => useLayoutStore.setState({ drawer: false }) diff --git a/src/features/profile/GymBadges.jsx b/src/features/profile/GymBadges.jsx index d09377125..9d997bbaa 100644 --- a/src/features/profile/GymBadges.jsx +++ b/src/features/profile/GymBadges.jsx @@ -10,9 +10,9 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import Query from '@services/Query' -import { VirtualGrid } from '@components/layout/general/VirtualGrid' -import { Img } from '@components/layout/general/Img' -import { ToggleTypography } from '@components/layout/general/ToggleTypography' +import { VirtualGrid } from '@components/general/VirtualGrid' +import { Img } from '@components/general/Img' +import { ToggleTypography } from '@components/general/ToggleTypography' export function UserGymBadges() { const { t } = useTranslation() diff --git a/src/features/profile/LinkAccounts.jsx b/src/features/profile/LinkAccounts.jsx index 1bee66219..71acc3859 100644 --- a/src/features/profile/LinkAccounts.jsx +++ b/src/features/profile/LinkAccounts.jsx @@ -12,9 +12,9 @@ import Utility from '@services/Utility' import Query from '@services/Query' import { METHODS } from '@assets/constants' -import DiscordButton from '@components/layout/auth/Discord' -import Telegram from '@components/layout/auth/Telegram' -import Notification from '@components/layout/general/Notification' +import DiscordButton from '@components/auth/Discord' +import Telegram from '@components/auth/Telegram' +import Notification from '@components/general/Notification' export function LinkAccounts() { const { t } = useTranslation() diff --git a/src/features/profile/index.jsx b/src/features/profile/index.jsx index 8098fabfc..ac4d77ef8 100644 --- a/src/features/profile/index.jsx +++ b/src/features/profile/index.jsx @@ -10,9 +10,9 @@ import DialogContent from '@mui/material/DialogContent' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import Utility from '@services/Utility' -import Header from '@components/layout/general/Header' -import Footer from '@components/layout/general/Footer' -import { DialogWrapper } from '@components/layout/dialogs/DialogWrapper' +import Header from '@components/general/Header' +import Footer from '@components/general/Footer' +import { DialogWrapper } from '@components/dialogs/DialogWrapper' import { UserBackups } from './Backups' import { UserPermissions } from './Permissions' diff --git a/src/features/scanner/Popup.jsx b/src/features/scanner/Popup.jsx index 799045c94..a1c8ac7d3 100644 --- a/src/features/scanner/Popup.jsx +++ b/src/features/scanner/Popup.jsx @@ -4,7 +4,7 @@ import List from '@mui/material/List' import { Popup } from 'react-leaflet' import { useTranslation } from 'react-i18next' -import { DividerWithMargin } from '@components/layout/general/StyledDivider' +import { DividerWithMargin } from '@components/general/StyledDivider' import { InAllowedArea, diff --git a/src/features/scanner/ScanDialog.jsx b/src/features/scanner/ScanDialog.jsx index 73092d48f..34c6c3ecb 100644 --- a/src/features/scanner/ScanDialog.jsx +++ b/src/features/scanner/ScanDialog.jsx @@ -3,8 +3,8 @@ import * as React from 'react' import { Dialog, DialogContent, Typography } from '@mui/material' import { useTranslation } from 'react-i18next' -import Header from '@components/layout/general/Header' -import Footer from '@components/layout/general/Footer' +import Header from '@components/general/Header' +import Footer from '@components/general/Footer' import { SCAN_MODES } from '@assets/constants' import { useScanStore } from './store' @@ -28,7 +28,7 @@ export default function ScanDialog() { const footerOptions = React.useMemo( () => - /** @type {import('@components/layout/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/general/Footer').FooterButton[]} */ ([ { name: 'close', icon: 'Clear', diff --git a/src/features/scanner/scanZone/PopupContent.jsx b/src/features/scanner/scanZone/PopupContent.jsx index 16640fdb6..0f98bf055 100644 --- a/src/features/scanner/scanZone/PopupContent.jsx +++ b/src/features/scanner/scanZone/PopupContent.jsx @@ -4,7 +4,7 @@ import { Button, ButtonGroup, Slider, List, ListItem } from '@mui/material' import { useTranslation } from 'react-i18next' import { debounce } from 'lodash' -import AdvancedAccordion from '@components/layout/custom/AdvancedAccordion' +import AdvancedAccordion from '@components/custom/AdvancedAccordion' import { RADIUS_CHOICES } from '@assets/constants' import { StyledSubHeader } from '../Shared' diff --git a/src/features/search/OptionImage.jsx b/src/features/search/OptionImage.jsx index 75b154e5f..39f209c57 100644 --- a/src/features/search/OptionImage.jsx +++ b/src/features/search/OptionImage.jsx @@ -8,7 +8,7 @@ import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import getRewardInfo from '@services/functions/getRewardInfo' import { useTranslateById } from '@hooks/useTranslateById' -import { Img } from '@components/layout/general/Img' +import { Img } from '@components/general/Img' /** @param {Partial} props */ function QuestImage(props) { diff --git a/src/features/search/index.jsx b/src/features/search/index.jsx index 40f1b628c..557158b08 100644 --- a/src/features/search/index.jsx +++ b/src/features/search/index.jsx @@ -13,7 +13,7 @@ import Utility from '@services/Utility' import { fromSearchCategory } from '@services/functions/fromSearchCategory' import { useMapStore } from '@hooks/useMapStore' -import Header from '@components/layout/general/Header' +import Header from '@components/general/Header' import { renderInput } from './renderInput' import { renderOption } from './renderOption' import { useSendSearch } from './useSendSearch' diff --git a/src/features/search/renderInput.jsx b/src/features/search/renderInput.jsx index db4510365..08f3b5f14 100644 --- a/src/features/search/renderInput.jsx +++ b/src/features/search/renderInput.jsx @@ -15,7 +15,7 @@ import { useQuery } from '@apollo/client' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { SEARCHABLE } from '@services/queries/config' -import { Img } from '@components/layout/general/Img' +import { Img } from '@components/general/Img' const SearchImage = React.memo( /** @param {{ name: string }} props */ ({ name }) => { diff --git a/src/features/search/renderOption.jsx b/src/features/search/renderOption.jsx index 75ca913a5..be70f981c 100644 --- a/src/features/search/renderOption.jsx +++ b/src/features/search/renderOption.jsx @@ -6,10 +6,10 @@ import ListItemIcon from '@mui/material/ListItemIcon' import ListItemText from '@mui/material/ListItemText' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' -import { Img } from '@components/layout/general/Img' +import { Img } from '@components/general/Img' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import { RawQuestTitle } from '@components/layout/general/QuestTitle' +import { RawQuestTitle } from '@components/general/QuestTitle' import { Divider, Typography } from '@mui/material' import Utility from '@services/Utility' diff --git a/src/features/tutorial/Advanced.jsx b/src/features/tutorial/Advanced.jsx index f939a08f8..74c3066ab 100644 --- a/src/features/tutorial/Advanced.jsx +++ b/src/features/tutorial/Advanced.jsx @@ -21,7 +21,7 @@ import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' import { useMemory } from '@hooks/useMemory' -import { VirtualGrid } from '@components/layout/general/VirtualGrid' +import { VirtualGrid } from '@components/general/VirtualGrid' import { StandardItem } from '@features/drawer/SelectorItem' import data from './data' diff --git a/src/features/tutorial/Sliders.jsx b/src/features/tutorial/Sliders.jsx index 207db8f3f..77b6690bf 100644 --- a/src/features/tutorial/Sliders.jsx +++ b/src/features/tutorial/Sliders.jsx @@ -2,7 +2,7 @@ import React, { useState } from 'react' import { Grid, DialogContent, Typography, Divider } from '@mui/material' import { useTranslation, Trans } from 'react-i18next' -import SliderTile from '../../components/layout/dialogs/filters/SliderTile' +import SliderTile from '@components/dialogs/filters/SliderTile' import data from './data' const relevant = ['iv', 'level', 'great', 'ultra'] diff --git a/src/features/tutorial/Welcome.jsx b/src/features/tutorial/Welcome.jsx index 1b91cc744..4d4af73de 100644 --- a/src/features/tutorial/Welcome.jsx +++ b/src/features/tutorial/Welcome.jsx @@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' -import LocaleSelection from '@components/layout/general/LocaleSelection' +import LocaleSelection from '@components/general/LocaleSelection' export default function TutWelcome() { const { t } = useTranslation() diff --git a/src/features/tutorial/index.jsx b/src/features/tutorial/index.jsx index 60db2043a..da0208445 100644 --- a/src/features/tutorial/index.jsx +++ b/src/features/tutorial/index.jsx @@ -13,7 +13,7 @@ import { useMutation } from '@apollo/client' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import Query from '@services/Query' -import Header from '@components/layout/general/Header' +import Header from '@components/general/Header' import Welcome from './Welcome' import Advanced from './Advanced' diff --git a/src/features/webhooks/Manage.jsx b/src/features/webhooks/Manage.jsx index b9fca71e5..52a6d9c3f 100644 --- a/src/features/webhooks/Manage.jsx +++ b/src/features/webhooks/Manage.jsx @@ -14,8 +14,8 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import Poracle from '@services/Poracle' import Utility from '@services/Utility' -import Footer from '@components/layout/general/Footer' -import Header from '@components/layout/general/Header' +import Footer from '@components/general/Footer' +import Header from '@components/general/Header' import { apolloClient } from '@services/apollo' import Query from '@services/Query' import { allProfiles } from '@services/queries/webhook' @@ -23,7 +23,7 @@ import { WebhookItem } from '@features/drawer/SelectorItem' import Human from './human' import Tracked from './Tracked' -import Menu from '../../components/layout/general/Menu' +import Menu from '../../components/general/Menu' import { setMode, setSelected, useWebhookStore } from './store' import { useGenFullFilters, useGetHookContext } from './hooks' import ProfileEditing from './human/profile' @@ -46,7 +46,7 @@ export default function Manage() { const [height, setHeight] = React.useState(0) const footerButtons = React.useMemo(() => { - /** @type {import('@components/layout/general/Footer').FooterButton[]} */ + /** @type {import('@components/general/Footer').FooterButton[]} */ const buttons = [ { name: 'feedback', diff --git a/src/features/webhooks/Notification.jsx b/src/features/webhooks/Notification.jsx index 0944db2df..309efa1f1 100644 --- a/src/features/webhooks/Notification.jsx +++ b/src/features/webhooks/Notification.jsx @@ -1,6 +1,6 @@ // @ts-check import * as React from 'react' -import Notification from '@components/layout/general/Notification' +import Notification from '@components/general/Notification' import { resetAlert, useWebhookStore } from './store' diff --git a/src/features/webhooks/Tracked.jsx b/src/features/webhooks/Tracked.jsx index 05e24e2f8..58bfc32b9 100644 --- a/src/features/webhooks/Tracked.jsx +++ b/src/features/webhooks/Tracked.jsx @@ -6,7 +6,7 @@ import { Virtuoso } from 'react-virtuoso' import Typography from '@mui/material/Typography' import Box from '@mui/material/Box' -import { Loading } from '@components/layout/general/Loading' +import { Loading } from '@components/general/Loading' import { GenericSearch } from '@features/drawer/ItemSearch' import TrackedTile from './tiles/TrackedTile' diff --git a/src/features/webhooks/WebhookAdv.jsx b/src/features/webhooks/WebhookAdv.jsx index 810d4b4a9..2c5a4d232 100644 --- a/src/features/webhooks/WebhookAdv.jsx +++ b/src/features/webhooks/WebhookAdv.jsx @@ -31,9 +31,9 @@ import Query from '@services/Query' import Utility from '@services/Utility' import Poracle from '@services/Poracle' -import SliderTile from '@components/layout/dialogs/filters/SliderTile' -import Header from '@components/layout/general/Header' -import Footer from '@components/layout/general/Footer' +import SliderTile from '@components/dialogs/filters/SliderTile' +import Header from '@components/general/Header' +import Footer from '@components/general/Footer' import { useWebhookStore } from './store' const skipFields = new Set([ diff --git a/src/features/webhooks/human/Location.jsx b/src/features/webhooks/human/Location.jsx index 1d86e0cdb..7d1b46b87 100644 --- a/src/features/webhooks/human/Location.jsx +++ b/src/features/webhooks/human/Location.jsx @@ -18,7 +18,7 @@ import { useMapEvents } from 'react-leaflet' import { setHuman } from '@services/queries/webhook' import { WEBHOOK_NOMINATIM } from '@services/queries/geocoder' import useLocation from '@hooks/useLocation' -import { Loading } from '@components/layout/general/Loading' +import { Loading } from '@components/general/Loading' import { basicEqualFn } from '@hooks/useMemory' import { setModeBtn, useWebhookStore } from '../store' diff --git a/src/features/webhooks/human/area/AreaGroup.jsx b/src/features/webhooks/human/area/AreaGroup.jsx index cb673710a..08ea13ced 100644 --- a/src/features/webhooks/human/area/AreaGroup.jsx +++ b/src/features/webhooks/human/area/AreaGroup.jsx @@ -6,7 +6,7 @@ import Divider from '@mui/material/Divider' import Button from '@mui/material/Button' import { useTranslation } from 'react-i18next' -import { Loading } from '@components/layout/general/Loading' +import { Loading } from '@components/general/Loading' import { useGetAreas } from '../../hooks' import { MemoAreaChip, handleClick } from './AreaChip' diff --git a/src/features/webhooks/human/area/AreaSelection.jsx b/src/features/webhooks/human/area/AreaSelection.jsx index 12818d795..685701083 100644 --- a/src/features/webhooks/human/area/AreaSelection.jsx +++ b/src/features/webhooks/human/area/AreaSelection.jsx @@ -4,7 +4,7 @@ import { useQuery } from '@apollo/client' import { useTranslation } from 'react-i18next' import { WEBHOOK_GEOJSON } from '@services/queries/webhook' -import { Loading } from '@components/layout/general/Loading' +import { Loading } from '@components/general/Loading' import MemoScanArea from '@components/tiles/ScanArea' import { useWebhookStore } from '../../store' diff --git a/src/features/webhooks/human/profile/index.jsx b/src/features/webhooks/human/profile/index.jsx index c845c8b69..062f152fb 100644 --- a/src/features/webhooks/human/profile/index.jsx +++ b/src/features/webhooks/human/profile/index.jsx @@ -3,7 +3,7 @@ import * as React from 'react' import Grid from '@mui/material/Unstable_Grid2' import { useTranslation } from 'react-i18next' -import { Loading } from '@components/layout/general/Loading' +import { Loading } from '@components/general/Loading' import { useGetWebhookData } from '../../hooks' import { MemoNewProfile } from './NewProfile' diff --git a/src/features/webhooks/human/status/HookSelection.jsx b/src/features/webhooks/human/status/HookSelection.jsx index 535108834..c34e2ebed 100644 --- a/src/features/webhooks/human/status/HookSelection.jsx +++ b/src/features/webhooks/human/status/HookSelection.jsx @@ -15,7 +15,7 @@ import { WEBHOOK_USER, allProfiles, } from '@services/queries/webhook' -import { Loading } from '@components/layout/general/Loading' +import { Loading } from '@components/general/Loading' import { useGetWebhookData } from '../../hooks' import { useWebhookStore } from '../../store' diff --git a/src/pages/Blocked.jsx b/src/pages/Blocked.jsx index c8b9afed6..010143049 100644 --- a/src/pages/Blocked.jsx +++ b/src/pages/Blocked.jsx @@ -17,9 +17,9 @@ import ListItemText from '@mui/material/ListItemText' import { useMemory } from '@hooks/useMemory' -import DiscordButton from '@components/layout/auth/Discord' -import ThemeToggle from '@components/layout/general/ThemeToggle' -import { I } from '@components/layout/general/I' +import DiscordButton from '@components/auth/Discord' +import ThemeToggle from '@components/general/ThemeToggle' +import { I } from '@components/general/I' export default function BlockedPage() { const { t } = useTranslation() diff --git a/src/pages/data/components/Shared.jsx b/src/pages/data/components/Shared.jsx index 51bb41b21..91b3b3ebf 100644 --- a/src/pages/data/components/Shared.jsx +++ b/src/pages/data/components/Shared.jsx @@ -8,7 +8,7 @@ import { styled } from '@mui/material/styles' import CheckIcon from '@mui/icons-material/Check' import ClearIcon from '@mui/icons-material/Clear' -import { BasicListButton } from '@components/layout/general/BasicListButton' +import { BasicListButton } from '@components/general/BasicListButton' import { setNotification, useDataManagementStore } from '../hooks/store' diff --git a/src/pages/login/CustomPage.jsx b/src/pages/login/CustomPage.jsx index 7e43e35ae..f88fdf82c 100644 --- a/src/pages/login/CustomPage.jsx +++ b/src/pages/login/CustomPage.jsx @@ -6,8 +6,8 @@ import Grid from '@mui/material/Unstable_Grid2' import { useQuery } from '@apollo/client' import { CUSTOM_COMPONENT } from '@services/queries/config' -import CustomTile from '@components/layout/custom/CustomTile' -import { Loading } from '@components/layout/general/Loading' +import CustomTile from '@components/custom/CustomTile' +import { Loading } from '@components/general/Loading' export function CustomLoginPage() { const { t, i18n } = useTranslation() diff --git a/src/pages/login/DefaultPage.jsx b/src/pages/login/DefaultPage.jsx index 0626655bc..31f710583 100644 --- a/src/pages/login/DefaultPage.jsx +++ b/src/pages/login/DefaultPage.jsx @@ -7,7 +7,7 @@ import Divider from '@mui/material/Divider' import { styled } from '@mui/material/styles' import { useMemory } from '@hooks/useMemory' -import LocaleSelection from '@components/layout/general/LocaleSelection' +import LocaleSelection from '@components/general/LocaleSelection' import methods from './Methods' diff --git a/src/pages/login/Methods.jsx b/src/pages/login/Methods.jsx index dfe54a787..3a387748e 100644 --- a/src/pages/login/Methods.jsx +++ b/src/pages/login/Methods.jsx @@ -3,9 +3,9 @@ import * as React from 'react' import Grid from '@mui/material/Unstable_Grid2' import { useTranslation } from 'react-i18next' -import DiscordButton from '@components/layout/auth/Discord' -import TelegramWidget from '@components/layout/auth/Telegram' -import LocalLogin from '@components/layout/auth/Local' +import DiscordButton from '@components/auth/Discord' +import TelegramWidget from '@components/auth/Telegram' +import LocalLogin from '@components/auth/Local' import { useMemory } from '@hooks/useMemory' function Discord() { diff --git a/src/pages/login/index.jsx b/src/pages/login/index.jsx index be1cf1897..dadc6d0df 100644 --- a/src/pages/login/index.jsx +++ b/src/pages/login/index.jsx @@ -4,7 +4,7 @@ import { Navigate } from 'react-router-dom' import Box from '@mui/material/Box' import { useMemory } from '@hooks/useMemory' -import ThemeToggle from '@components/layout/general/ThemeToggle' +import ThemeToggle from '@components/general/ThemeToggle' import { CustomLoginPage } from './CustomPage' import { DefaultLoginPage } from './DefaultPage' diff --git a/src/pages/map/components/ActiveWeather.jsx b/src/pages/map/components/ActiveWeather.jsx index 5085631be..501f79643 100644 --- a/src/pages/map/components/ActiveWeather.jsx +++ b/src/pages/map/components/ActiveWeather.jsx @@ -12,9 +12,9 @@ import WeatherPopup from '@components/popups/Weather' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { apolloClient } from '@services/apollo' -import Header from '@components/layout/general/Header' -import Footer from '@components/layout/general/Footer' -import { Img } from '@components/layout/general/Img' +import Header from '@components/general/Header' +import Footer from '@components/general/Footer' +import { Img } from '@components/general/Img' const StyledBox = styled(Box)(({ theme }) => ({ zIndex: 1000, @@ -67,7 +67,7 @@ export default function ActiveWeather() { const footerOptions = React.useMemo( () => - /** @type {import('../../../components/layout/general/Footer').FooterButton[]} */ ([ + /** @type {import('../../../components/general/Footer').FooterButton[]} */ ([ { name: 'close', action: () => setOpen(false), diff --git a/src/pages/map/components/Clustering.jsx b/src/pages/map/components/Clustering.jsx index 888b913e0..2bc569a82 100644 --- a/src/pages/map/components/Clustering.jsx +++ b/src/pages/map/components/Clustering.jsx @@ -5,7 +5,7 @@ import Supercluster from 'supercluster' import { marker, divIcon, point } from 'leaflet' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import Notification from '../../../components/layout/general/Notification' +import Notification from '@components/general/Notification' const IGNORE_CLUSTERING = new Set([ 'devices', diff --git a/src/pages/map/components/FloatingBtn.jsx b/src/pages/map/components/FloatingBtn.jsx index dbc0b9c20..b15ce355a 100644 --- a/src/pages/map/components/FloatingBtn.jsx +++ b/src/pages/map/components/FloatingBtn.jsx @@ -31,7 +31,7 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import { useScanStore } from '@features/scanner/store' -import { I } from '@components/layout/general/I' +import { I } from '@components/general/I' import { setModeBtn, useWebhookStore } from '@features/webhooks/store' /** @typedef {keyof ReturnType | keyof ReturnType} Keys */ diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index 28a7b258e..fe91f016f 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -3,25 +3,25 @@ import * as React from 'react' import { useMemory } from '@hooks/useMemory' import Drawer from '@features/drawer' -import FilterMenu from '@components/layout/dialogs/filters/FilterMenu' -import UserOptions from '@components/layout/dialogs/UserOptions' +import FilterMenu from '@components/dialogs/filters/FilterMenu' +import UserOptions from '@components/dialogs/UserOptions' import Tutorial from '@features/tutorial' import UserProfile from '@features/profile' import Search from '@features/search' -import MessageOfTheDay from '@components/layout/dialogs/Motd' -import DonorPage from '@components/layout/dialogs/DonorPage' -import Feedback from '@components/layout/dialogs/Feedback' -import ResetFilters from '@components/layout/dialogs/ResetFilters' +import MessageOfTheDay from '@components/dialogs/Motd' +import DonorPage from '@components/dialogs/DonorPage' +import Feedback from '@components/dialogs/Feedback' +import ResetFilters from '@components/dialogs/ResetFilters' import ScanDialog from '@features/scanner/ScanDialog' import Webhook from '@features/webhooks/Webhook' -import ClientError from '@components/layout/dialogs/ClientError' +import ClientError from '@components/dialogs/ClientError' import { WebhookNotification } from '@features/webhooks/Notification' -import AdvancedFilter from '@components/layout/dialogs/filters/Advanced' -import BadgeSelection from '@components/layout/dialogs/BadgeSelection' +import AdvancedFilter from '@components/dialogs/filters/Advanced' +import BadgeSelection from '@components/dialogs/BadgeSelection' import WebhookAdvanced from '@features/webhooks/WebhookAdv' -import SlotSelection from '@components/layout/dialogs/filters/SlotSelection' -import { HelpDialog } from '@components/layout/dialogs/Help' -import { PkmnFilterHelp } from '@components/layout/dialogs/filters/PkmnFilterHelp' +import SlotSelection from '@components/dialogs/filters/SlotSelection' +import { HelpDialog } from '@components/dialogs/Help' +import { PkmnFilterHelp } from '@components/dialogs/filters/PkmnFilterHelp' import { FloatingButtonsMemo } from './FloatingBtn' export const Nav = React.memo( diff --git a/src/pages/map/components/QueryData.jsx b/src/pages/map/components/QueryData.jsx index 4e6b54095..b24ba7c69 100644 --- a/src/pages/map/components/QueryData.jsx +++ b/src/pages/map/components/QueryData.jsx @@ -11,11 +11,11 @@ import { getQueryArgs } from '@services/functions/getQueryArgs' import RobustTimeout from '@services/apollo/RobustTimeout' import Utility from '@services/Utility' import { FILTER_SKIP_LIST } from '@assets/constants' +import * as index from '@components/tiles/index' +import Notification from '@components/general/Notification' +import { GenerateCells } from '@components/tiles/S2Cell' -import * as index from '../../../components/tiles/index' import Clustering from './Clustering' -import Notification from '../../../components/layout/general/Notification' -import { GenerateCells } from '../../../components/tiles/S2Cell' /** @param {string} category */ const userSettingsCategory = (category) => { diff --git a/src/pages/playground/components/Viewer.jsx b/src/pages/playground/components/Viewer.jsx index d3cf4c106..292fea8bc 100644 --- a/src/pages/playground/components/Viewer.jsx +++ b/src/pages/playground/components/Viewer.jsx @@ -4,8 +4,8 @@ import * as React from 'react' import Grid from '@mui/material/Unstable_Grid2' import { useTranslation } from 'react-i18next' -import CustomTile from '@components/layout/custom/CustomTile' -import DialogWrapper from '@components/layout/custom/DialogWrapper' +import CustomTile from '@components/custom/CustomTile' +import DialogWrapper from '@components/custom/DialogWrapper' import ErrorBoundary from '@components/ErrorBoundary' import { useSafeParse } from '../hooks/useSafeParse' From 8399dc027eb4767ec695298d6bd892fd5e335848 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:46:38 -0500 Subject: [PATCH 024/177] refactor: `src/services/functions` => `src/utils` --- .eslintrc | 3 ++- jsconfig.json | 3 ++- src/App.jsx | 4 ++-- src/components/Config.jsx | 8 ++++---- src/components/dialogs/filters/Advanced.jsx | 2 +- src/components/dialogs/filters/StringFilter.jsx | 2 +- src/components/popups/Pokestop.jsx | 6 +++--- src/components/popups/Route.jsx | 2 +- src/components/tiles/Pokemon.jsx | 4 ++-- src/components/tiles/S2Cell.jsx | 2 +- src/features/drawer/Actions.jsx | 4 ++-- src/features/drawer/BoolToggle.jsx | 2 +- src/features/drawer/SelectorItem.jsx | 2 +- src/features/search/OptionImage.jsx | 2 +- src/features/search/index.jsx | 2 +- src/features/search/renderOption.jsx | 4 ++-- src/hooks/useFormatDistance.js | 2 +- src/hooks/useRefresh.js | 2 +- src/hooks/useStorage.js | 6 +++--- src/pages/Reset.jsx | 2 +- src/pages/data/components/ResetFilters.jsx | 2 +- src/pages/data/components/ResetGeneral.jsx | 2 +- src/pages/data/components/TopRow.jsx | 2 +- src/pages/map/components/QueryData.jsx | 2 +- src/pages/playground/hooks/store.js | 2 +- src/services/Utility.js | 10 +++++----- src/{services/functions => utils}/checkAdvFilter.js | 0 src/{services/functions => utils}/checkHoliday.js | 0 src/{services/functions => utils}/dayCheck.js | 0 src/{services/functions => utils}/deepMerge.js | 0 src/{services/functions => utils}/downloadJson.js | 0 src/{services/functions => utils}/formatDistance.js | 0 src/{services/functions => utils}/formatInterval.js | 0 .../functions => utils}/fromSearchCategory.js | 0 src/{services/functions => utils}/fromSnakeCase.js | 0 src/{services/functions => utils}/getBadge.js | 0 src/{services/functions => utils}/getGlowRules.js | 0 src/{services/functions => utils}/getGruntReward.js | 0 src/{services/functions => utils}/getProperName.js | 0 src/{services/functions => utils}/getQueryArgs.js | 0 src/{services/functions => utils}/getRewardInfo.js | 0 src/{services/functions => utils}/hasAll.js | 0 .../functions => utils}/isLocalStorageEnabled.js | 0 src/{services/functions => utils}/offset.js | 0 src/{services/functions => utils}/parseConditions.js | 0 src/{services/functions => utils}/resetState.js | 0 src/{services/functions => utils}/setDeep.js | 0 src/{services/functions => utils}/setLoadingText.js | 0 vite.config.js | 1 + 49 files changed, 44 insertions(+), 41 deletions(-) rename src/{services/functions => utils}/checkAdvFilter.js (100%) rename src/{services/functions => utils}/checkHoliday.js (100%) rename src/{services/functions => utils}/dayCheck.js (100%) rename src/{services/functions => utils}/deepMerge.js (100%) rename src/{services/functions => utils}/downloadJson.js (100%) rename src/{services/functions => utils}/formatDistance.js (100%) rename src/{services/functions => utils}/formatInterval.js (100%) rename src/{services/functions => utils}/fromSearchCategory.js (100%) rename src/{services/functions => utils}/fromSnakeCase.js (100%) rename src/{services/functions => utils}/getBadge.js (100%) rename src/{services/functions => utils}/getGlowRules.js (100%) rename src/{services/functions => utils}/getGruntReward.js (100%) rename src/{services/functions => utils}/getProperName.js (100%) rename src/{services/functions => utils}/getQueryArgs.js (100%) rename src/{services/functions => utils}/getRewardInfo.js (100%) rename src/{services/functions => utils}/hasAll.js (100%) rename src/{services/functions => utils}/isLocalStorageEnabled.js (100%) rename src/{services/functions => utils}/offset.js (100%) rename src/{services/functions => utils}/parseConditions.js (100%) rename src/{services/functions => utils}/resetState.js (100%) rename src/{services/functions => utils}/setDeep.js (100%) rename src/{services/functions => utils}/setLoadingText.js (100%) diff --git a/.eslintrc b/.eslintrc index 4db5dc269..182e432cf 100644 --- a/.eslintrc +++ b/.eslintrc @@ -78,7 +78,8 @@ ["@features", "./src/features/"], ["@services", "./src/services/"], ["@hooks", "./src/hooks/"], - ["@assets", "./src/assets/"] + ["@assets", "./src/assets/"], + ["@utils", "./src/utils/"] ], "extensions": [".mjs", ".js", ".jsx", ".ts", ".tsx"] } diff --git a/jsconfig.json b/jsconfig.json index 9e23add5a..71471fcdc 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -14,7 +14,8 @@ "@components/*": ["./src/components/*"], "@features/*": ["./src/features/*"], "@services/*": ["./src/services/*"], - "@hooks/*": ["./src/hooks/*"] + "@hooks/*": ["./src/hooks/*"], + "@utils/*": ["./src/utils/*"] } }, "exclude": ["node_modules", "**/node_modules/*", "dist"] diff --git a/src/App.jsx b/src/App.jsx index 3f9157dd5..f70069986 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -12,8 +12,8 @@ import { ApolloProvider } from '@apollo/client' import useCustomTheme from '@assets/mui/theme' import { globalStyles } from '@assets/mui/global' import { apolloClient } from '@services/apollo' -import { isLocalStorageEnabled } from '@services/functions/isLocalStorageEnabled' -import { setLoadingText } from '@services/functions/setLoadingText' +import { isLocalStorageEnabled } from '@utils/isLocalStorageEnabled' +import { setLoadingText } from '@utils/setLoadingText' import '@services/events' import ErrorBoundary from '@components/ErrorBoundary' import HolidayEffects from '@features/holiday' diff --git a/src/components/Config.jsx b/src/components/Config.jsx index 0db3a5332..95085790c 100644 --- a/src/components/Config.jsx +++ b/src/components/Config.jsx @@ -6,12 +6,12 @@ import { Navigate } from 'react-router-dom' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import Fetch from '@services/Fetch' -import { setLoadingText } from '@services/functions/setLoadingText' +import { setLoadingText } from '@utils/setLoadingText' import Utility from '@services/Utility' -import { deepMerge } from '@services/functions/deepMerge' -import { checkHoliday } from '@services/functions/checkHoliday' +import { deepMerge } from '@utils/deepMerge' +import { checkHoliday } from '@utils/checkHoliday' import { useHideElement } from '@hooks/useHideElement' -import { getGlowRules } from '@services/functions/getGlowRules' +import { getGlowRules } from '@utils/getGlowRules' import { useScannerSessionStorage } from '@features/scanner/store' export default function Config({ children }) { diff --git a/src/components/dialogs/filters/Advanced.jsx b/src/components/dialogs/filters/Advanced.jsx index 7a1ae17e0..7b33adb37 100644 --- a/src/components/dialogs/filters/Advanced.jsx +++ b/src/components/dialogs/filters/Advanced.jsx @@ -14,7 +14,7 @@ import { BoolToggle, DualBoolToggle } from '@features/drawer/BoolToggle' import { ENABLED_ALL, XXS_XXL } from '@assets/constants' import { useTranslateById } from '@hooks/useTranslateById' import { STANDARD_BACKUP, applyToAll } from '@services/filtering/applyToAll' -import { checkIfHasAll } from '@services/functions/hasAll' +import { checkIfHasAll } from '@utils/hasAll' import { StringFilter } from './StringFilter' import SliderTile from './SliderTile' diff --git a/src/components/dialogs/filters/StringFilter.jsx b/src/components/dialogs/filters/StringFilter.jsx index 9b69116fe..a855b5700 100644 --- a/src/components/dialogs/filters/StringFilter.jsx +++ b/src/components/dialogs/filters/StringFilter.jsx @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next' import dlv from 'dlv' import { useStorage } from '@hooks/useStorage' -import { setDeep } from '@services/functions/setDeep' +import { setDeep } from '@utils/setDeep' import Utility from '@services/Utility' /** diff --git a/src/components/popups/Pokestop.jsx b/src/components/popups/Pokestop.jsx index aecb37e04..1166fd5ce 100644 --- a/src/components/popups/Pokestop.jsx +++ b/src/components/popups/Pokestop.jsx @@ -22,9 +22,9 @@ import { Check, Help } from '@components/general/Icons' import { useMemory } from '@hooks/useMemory' import { setDeepStore, useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' -import { getBadge } from '@services/functions/getBadge' -import getRewardInfo from '@services/functions/getRewardInfo' -import { getGruntReward } from '@services/functions/getGruntReward' +import { getBadge } from '@utils/getBadge' +import getRewardInfo from '@utils/getRewardInfo' +import { getGruntReward } from '@utils/getGruntReward' import Dropdown from './common/Dropdown' import TimeTile from './common/TimeTile' diff --git a/src/components/popups/Route.jsx b/src/components/popups/Route.jsx index c45bf477a..0b7c229ec 100644 --- a/src/components/popups/Route.jsx +++ b/src/components/popups/Route.jsx @@ -22,7 +22,7 @@ import Typography from '@mui/material/Typography' import DownloadIcon from '@mui/icons-material/Download' import Query from '@services/Query' -import formatInterval from '@services/functions/formatInterval' +import formatInterval from '@utils/formatInterval' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { useFormatDistance } from '@hooks/useFormatDistance' diff --git a/src/components/tiles/Pokemon.jsx b/src/components/tiles/Pokemon.jsx index 8ec0d1c5f..f728f2008 100644 --- a/src/components/tiles/Pokemon.jsx +++ b/src/components/tiles/Pokemon.jsx @@ -5,8 +5,8 @@ import { Marker, Popup, Circle } from 'react-leaflet' import { t } from 'i18next' import useMarkerTimer from '@hooks/useMarkerTimer' -import { getOffset } from '@services/functions/offset' -import { getBadge } from '@services/functions/getBadge' +import { getOffset } from '@utils/offset' +import { getBadge } from '@utils/getBadge' import { basicEqualFn, useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import useOpacity from '@hooks/useOpacity' diff --git a/src/components/tiles/S2Cell.jsx b/src/components/tiles/S2Cell.jsx index ea684bf3f..9bb1802a8 100644 --- a/src/components/tiles/S2Cell.jsx +++ b/src/components/tiles/S2Cell.jsx @@ -13,7 +13,7 @@ import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import Notification from '@components/general/Notification' -import { getQueryArgs } from '@services/functions/getQueryArgs' +import { getQueryArgs } from '@utils/getQueryArgs' /** * diff --git a/src/features/drawer/Actions.jsx b/src/features/drawer/Actions.jsx index a5ed9936a..b64d396b6 100644 --- a/src/features/drawer/Actions.jsx +++ b/src/features/drawer/Actions.jsx @@ -12,8 +12,8 @@ import ImportExportIcon from '@mui/icons-material/ImportExport' import TrendingUpIcon from '@mui/icons-material/TrendingUp' import FeedbackIcon from '@mui/icons-material/Feedback' import HeartIcon from '@mui/icons-material/Favorite' -import { downloadJson } from '@services/functions/downloadJson' -import { deepMerge } from '@services/functions/deepMerge' +import { downloadJson } from '@utils/downloadJson' +import { deepMerge } from '@utils/deepMerge' import { useMapStore } from '@hooks/useMapStore' import { useMemory } from '@hooks/useMemory' diff --git a/src/features/drawer/BoolToggle.jsx b/src/features/drawer/BoolToggle.jsx index c43e0d614..e56073165 100644 --- a/src/features/drawer/BoolToggle.jsx +++ b/src/features/drawer/BoolToggle.jsx @@ -9,7 +9,7 @@ import { useDeepStore } from '@hooks/useStorage' import { useTranslation } from 'react-i18next' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' import Utility from '@services/Utility' -import { fromSnakeCase } from '@services/functions/fromSnakeCase' +import { fromSnakeCase } from '@utils/fromSnakeCase' /** * @typedef {{ diff --git a/src/features/drawer/SelectorItem.jsx b/src/features/drawer/SelectorItem.jsx index 30da1baaf..5193c7cbb 100644 --- a/src/features/drawer/SelectorItem.jsx +++ b/src/features/drawer/SelectorItem.jsx @@ -9,7 +9,7 @@ import { useTranslateById } from '@hooks/useTranslateById' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useDeepStore, useStorage } from '@hooks/useStorage' -import { checkIfHasAll } from '@services/functions/hasAll' +import { checkIfHasAll } from '@utils/hasAll' import Poracle from '@services/Poracle' import { ColoredTile } from '@components/general/ColoredTile' import { ToggleTypography } from '@components/general/ToggleTypography' diff --git a/src/features/search/OptionImage.jsx b/src/features/search/OptionImage.jsx index 39f209c57..b7b2991ed 100644 --- a/src/features/search/OptionImage.jsx +++ b/src/features/search/OptionImage.jsx @@ -6,7 +6,7 @@ import Box from '@mui/material/Box' import NameTT from '@components/popups/common/NameTT' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import getRewardInfo from '@services/functions/getRewardInfo' +import getRewardInfo from '@utils/getRewardInfo' import { useTranslateById } from '@hooks/useTranslateById' import { Img } from '@components/general/Img' diff --git a/src/features/search/index.jsx b/src/features/search/index.jsx index 557158b08..70d392d02 100644 --- a/src/features/search/index.jsx +++ b/src/features/search/index.jsx @@ -10,7 +10,7 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' -import { fromSearchCategory } from '@services/functions/fromSearchCategory' +import { fromSearchCategory } from '@utils/fromSearchCategory' import { useMapStore } from '@hooks/useMapStore' import Header from '@components/general/Header' diff --git a/src/features/search/renderOption.jsx b/src/features/search/renderOption.jsx index be70f981c..e3d0f9417 100644 --- a/src/features/search/renderOption.jsx +++ b/src/features/search/renderOption.jsx @@ -14,8 +14,8 @@ import { RawQuestTitle } from '@components/general/QuestTitle' import { Divider, Typography } from '@mui/material' import Utility from '@services/Utility' import { RawTimeSince } from '@components/popups/common/Timer' -import { getGruntReward } from '@services/functions/getGruntReward' -import { formatDistance } from '@services/functions/formatDistance' +import { getGruntReward } from '@utils/getGruntReward' +import { formatDistance } from '@utils/formatDistance' import { OptionImageMemo } from './OptionImage' diff --git a/src/hooks/useFormatDistance.js b/src/hooks/useFormatDistance.js index 34a8d0059..7dd67f6e7 100644 --- a/src/hooks/useFormatDistance.js +++ b/src/hooks/useFormatDistance.js @@ -1,7 +1,7 @@ // @ts-check import { useTranslation } from 'react-i18next' -import { formatDistance } from '@services/functions/formatDistance' +import { formatDistance } from '@utils/formatDistance' import { useStorage } from './useStorage' diff --git a/src/hooks/useRefresh.js b/src/hooks/useRefresh.js index 182f8abd5..d12754470 100644 --- a/src/hooks/useRefresh.js +++ b/src/hooks/useRefresh.js @@ -3,7 +3,7 @@ import { useEffect } from 'react' import { useQuery } from '@apollo/client' import { getMapData } from '@services/queries/available' -import { deepMerge } from '@services/functions/deepMerge' +import { deepMerge } from '@utils/deepMerge' import UAssets from '@services/Icons' import { useMemory } from './useMemory' diff --git a/src/hooks/useStorage.js b/src/hooks/useStorage.js index 1a1144d0f..8810a8e13 100644 --- a/src/hooks/useStorage.js +++ b/src/hooks/useStorage.js @@ -1,4 +1,4 @@ -import { setDeep } from '@services/functions/setDeep' +import { setDeep } from '@utils/setDeep' import dlv from 'dlv' import { useCallback, useMemo } from 'react' import { create } from 'zustand' @@ -22,7 +22,7 @@ import { persist, createJSONStorage } from 'zustand/middleware' * }, * searches: Record, * tabs: Record, - * menus: ReturnType + * menus: ReturnType * holidayEffects: Record, * motdIndex: number * tutorial: boolean, @@ -31,7 +31,7 @@ import { persist, createJSONStorage } from 'zustand/middleware' * filters: import('@rm/types').AllFilters, * icons: Record * audio: Record - * userSettings: ReturnType['clientValues'] + * userSettings: ReturnType['clientValues'] * profiling: boolean * stateTraceLog: boolean * desktopNotifications: boolean diff --git a/src/pages/Reset.jsx b/src/pages/Reset.jsx index 449914b0a..eb29733c8 100644 --- a/src/pages/Reset.jsx +++ b/src/pages/Reset.jsx @@ -2,7 +2,7 @@ import * as React from 'react' import { Navigate } from 'react-router-dom' -import { hardReset } from '@services/functions/resetState' +import { hardReset } from '@utils/resetState' export default function ResetPage() { hardReset() diff --git a/src/pages/data/components/ResetFilters.jsx b/src/pages/data/components/ResetFilters.jsx index 69d3435ea..c3dded19b 100644 --- a/src/pages/data/components/ResetFilters.jsx +++ b/src/pages/data/components/ResetFilters.jsx @@ -3,7 +3,7 @@ import * as React from 'react' import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' -import { resetFilter, resetFilters } from '@services/functions/resetState' +import { resetFilter, resetFilters } from '@utils/resetState' import Utility from '@services/Utility' import { diff --git a/src/pages/data/components/ResetGeneral.jsx b/src/pages/data/components/ResetGeneral.jsx index e7492e682..c1fa58ba9 100644 --- a/src/pages/data/components/ResetGeneral.jsx +++ b/src/pages/data/components/ResetGeneral.jsx @@ -11,7 +11,7 @@ import { resetSettings, resetUI, resetUserSettings, -} from '@services/functions/resetState' +} from '@utils/resetState' import { ButtonWithNotification, diff --git a/src/pages/data/components/TopRow.jsx b/src/pages/data/components/TopRow.jsx index 23be3e261..c4d9646c1 100644 --- a/src/pages/data/components/TopRow.jsx +++ b/src/pages/data/components/TopRow.jsx @@ -6,7 +6,7 @@ import Divider from '@mui/material/Divider' import Button from '@mui/material/Button' import { useTranslation } from 'react-i18next' -import { hardReset } from '@services/functions/resetState' +import { hardReset } from '@utils/resetState' import { BORDER_SX } from './Shared' import { setNotification, useDataManagementStore } from '../hooks/store' diff --git a/src/pages/map/components/QueryData.jsx b/src/pages/map/components/QueryData.jsx index b24ba7c69..b366dc7b8 100644 --- a/src/pages/map/components/QueryData.jsx +++ b/src/pages/map/components/QueryData.jsx @@ -7,7 +7,7 @@ import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { usePermCheck } from '@hooks/usePermCheck' import Query from '@services/Query' -import { getQueryArgs } from '@services/functions/getQueryArgs' +import { getQueryArgs } from '@utils/getQueryArgs' import RobustTimeout from '@services/apollo/RobustTimeout' import Utility from '@services/Utility' import { FILTER_SKIP_LIST } from '@assets/constants' diff --git a/src/pages/playground/hooks/store.js b/src/pages/playground/hooks/store.js index e5076a520..3363ebe0e 100644 --- a/src/pages/playground/hooks/store.js +++ b/src/pages/playground/hooks/store.js @@ -1,6 +1,6 @@ // @ts-check import { create } from 'zustand' -import { downloadJson } from '@services/functions/downloadJson' +import { downloadJson } from '@utils/downloadJson' /** * @typedef {{ diff --git a/src/services/Utility.js b/src/services/Utility.js index fcc4fe35e..1fbcd1ed1 100644 --- a/src/services/Utility.js +++ b/src/services/Utility.js @@ -1,11 +1,11 @@ import ReactGA from 'react-ga4' import SunCalc from 'suncalc' -import formatInterval from './functions/formatInterval' -import getProperName from './functions/getProperName' -import checkAdvFilter from './functions/checkAdvFilter' -import dayCheck from './functions/dayCheck' -import parseQuestConditions from './functions/parseConditions' +import formatInterval from '@utils/formatInterval' +import getProperName from '@utils/getProperName' +import checkAdvFilter from '@utils/checkAdvFilter' +import dayCheck from '@utils/dayCheck' +import parseQuestConditions from '@utils/parseConditions' export default class Utility { static getProperName(word) { diff --git a/src/services/functions/checkAdvFilter.js b/src/utils/checkAdvFilter.js similarity index 100% rename from src/services/functions/checkAdvFilter.js rename to src/utils/checkAdvFilter.js diff --git a/src/services/functions/checkHoliday.js b/src/utils/checkHoliday.js similarity index 100% rename from src/services/functions/checkHoliday.js rename to src/utils/checkHoliday.js diff --git a/src/services/functions/dayCheck.js b/src/utils/dayCheck.js similarity index 100% rename from src/services/functions/dayCheck.js rename to src/utils/dayCheck.js diff --git a/src/services/functions/deepMerge.js b/src/utils/deepMerge.js similarity index 100% rename from src/services/functions/deepMerge.js rename to src/utils/deepMerge.js diff --git a/src/services/functions/downloadJson.js b/src/utils/downloadJson.js similarity index 100% rename from src/services/functions/downloadJson.js rename to src/utils/downloadJson.js diff --git a/src/services/functions/formatDistance.js b/src/utils/formatDistance.js similarity index 100% rename from src/services/functions/formatDistance.js rename to src/utils/formatDistance.js diff --git a/src/services/functions/formatInterval.js b/src/utils/formatInterval.js similarity index 100% rename from src/services/functions/formatInterval.js rename to src/utils/formatInterval.js diff --git a/src/services/functions/fromSearchCategory.js b/src/utils/fromSearchCategory.js similarity index 100% rename from src/services/functions/fromSearchCategory.js rename to src/utils/fromSearchCategory.js diff --git a/src/services/functions/fromSnakeCase.js b/src/utils/fromSnakeCase.js similarity index 100% rename from src/services/functions/fromSnakeCase.js rename to src/utils/fromSnakeCase.js diff --git a/src/services/functions/getBadge.js b/src/utils/getBadge.js similarity index 100% rename from src/services/functions/getBadge.js rename to src/utils/getBadge.js diff --git a/src/services/functions/getGlowRules.js b/src/utils/getGlowRules.js similarity index 100% rename from src/services/functions/getGlowRules.js rename to src/utils/getGlowRules.js diff --git a/src/services/functions/getGruntReward.js b/src/utils/getGruntReward.js similarity index 100% rename from src/services/functions/getGruntReward.js rename to src/utils/getGruntReward.js diff --git a/src/services/functions/getProperName.js b/src/utils/getProperName.js similarity index 100% rename from src/services/functions/getProperName.js rename to src/utils/getProperName.js diff --git a/src/services/functions/getQueryArgs.js b/src/utils/getQueryArgs.js similarity index 100% rename from src/services/functions/getQueryArgs.js rename to src/utils/getQueryArgs.js diff --git a/src/services/functions/getRewardInfo.js b/src/utils/getRewardInfo.js similarity index 100% rename from src/services/functions/getRewardInfo.js rename to src/utils/getRewardInfo.js diff --git a/src/services/functions/hasAll.js b/src/utils/hasAll.js similarity index 100% rename from src/services/functions/hasAll.js rename to src/utils/hasAll.js diff --git a/src/services/functions/isLocalStorageEnabled.js b/src/utils/isLocalStorageEnabled.js similarity index 100% rename from src/services/functions/isLocalStorageEnabled.js rename to src/utils/isLocalStorageEnabled.js diff --git a/src/services/functions/offset.js b/src/utils/offset.js similarity index 100% rename from src/services/functions/offset.js rename to src/utils/offset.js diff --git a/src/services/functions/parseConditions.js b/src/utils/parseConditions.js similarity index 100% rename from src/services/functions/parseConditions.js rename to src/utils/parseConditions.js diff --git a/src/services/functions/resetState.js b/src/utils/resetState.js similarity index 100% rename from src/services/functions/resetState.js rename to src/utils/resetState.js diff --git a/src/services/functions/setDeep.js b/src/utils/setDeep.js similarity index 100% rename from src/services/functions/setDeep.js rename to src/utils/setDeep.js diff --git a/src/services/functions/setLoadingText.js b/src/utils/setLoadingText.js similarity index 100% rename from src/services/functions/setLoadingText.js rename to src/utils/setLoadingText.js diff --git a/vite.config.js b/vite.config.js index 6dc395fbe..18bc0d0a8 100644 --- a/vite.config.js +++ b/vite.config.js @@ -113,6 +113,7 @@ const viteConfig = defineConfig(({ mode }) => { '@features': resolve(__dirname, './src/features'), '@hooks': resolve(__dirname, './src/hooks'), '@services': resolve(__dirname, './src/services'), + '@utils': resolve(__dirname, './src/utils'), }, }, define: { From c49c68611e1983860a51d5b1c03a41b544259518 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:48:09 -0500 Subject: [PATCH 025/177] refactor: rename `Icons.js` => `Assets.js` --- packages/types/lib/client.d.ts | 2 +- src/hooks/useMemory.js | 4 ++-- src/hooks/useRefresh.js | 2 +- src/services/{Icons.js => Assets.js} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename src/services/{Icons.js => Assets.js} (100%) diff --git a/packages/types/lib/client.d.ts b/packages/types/lib/client.d.ts index b1a455e5f..260af49c7 100644 --- a/packages/types/lib/client.d.ts +++ b/packages/types/lib/client.d.ts @@ -1,6 +1,6 @@ import * as React from 'react' import { Config } from './config' -import UAssets from '@services/Icons' +import UAssets from '@services/Assets' import { ButtonProps, SxProps, Theme } from '@mui/material' import { SystemStyleObject } from '@mui/system' diff --git a/src/hooks/useMemory.js b/src/hooks/useMemory.js index d275f5f16..8a35bbd01 100644 --- a/src/hooks/useMemory.js +++ b/src/hooks/useMemory.js @@ -8,8 +8,8 @@ import { create } from 'zustand' * active: boolean, * online: boolean, * searchLoading: boolean, - * Icons: InstanceType, - * Audio: InstanceType, + * Icons: InstanceType, + * Audio: InstanceType, * config: import('@rm/types').Config['map'], * ui: import('@rm/types').UIObject, * auth: { diff --git a/src/hooks/useRefresh.js b/src/hooks/useRefresh.js index d12754470..86af58ce6 100644 --- a/src/hooks/useRefresh.js +++ b/src/hooks/useRefresh.js @@ -4,7 +4,7 @@ import { useQuery } from '@apollo/client' import { getMapData } from '@services/queries/available' import { deepMerge } from '@utils/deepMerge' -import UAssets from '@services/Icons' +import UAssets from '@services/Assets' import { useMemory } from './useMemory' import { useStorage } from './useStorage' diff --git a/src/services/Icons.js b/src/services/Assets.js similarity index 100% rename from src/services/Icons.js rename to src/services/Assets.js From 65e32afdb4ac23180d59078b530c470d177a6efa Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:49:04 -0500 Subject: [PATCH 026/177] refactor: rename `ttlcache.js` => `SimpleTTLCache.js` --- src/services/{ttlcache.js => SimpleTTLCache.js} | 0 src/services/desktopNotification.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/services/{ttlcache.js => SimpleTTLCache.js} (100%) diff --git a/src/services/ttlcache.js b/src/services/SimpleTTLCache.js similarity index 100% rename from src/services/ttlcache.js rename to src/services/SimpleTTLCache.js diff --git a/src/services/desktopNotification.js b/src/services/desktopNotification.js index 940a5e44f..73dff5bb2 100644 --- a/src/services/desktopNotification.js +++ b/src/services/desktopNotification.js @@ -3,7 +3,7 @@ import { t } from 'i18next' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import SimpleTTLCache from '@services/ttlcache' +import SimpleTTLCache from '@services/SimpleTTLCache' import { useMapStore } from '@hooks/useMapStore' export const HAS_API = 'Notification' in window From a3f24927d33f6624286136d4c81c786f65a40977 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:50:11 -0500 Subject: [PATCH 027/177] refactor: move theme/global styles --- src/App.jsx | 4 ++-- src/assets/{mui => }/theme.js | 0 src/{assets/mui/global.jsx => components/Global.jsx} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename src/assets/{mui => }/theme.js (100%) rename src/{assets/mui/global.jsx => components/Global.jsx} (100%) diff --git a/src/App.jsx b/src/App.jsx index f70069986..2691adf86 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -9,8 +9,8 @@ import CssBaseline from '@mui/material/CssBaseline' import { ThemeProvider } from '@mui/material/styles' import { ApolloProvider } from '@apollo/client' -import useCustomTheme from '@assets/mui/theme' -import { globalStyles } from '@assets/mui/global' +import useCustomTheme from '@assets/theme' +import { globalStyles } from '@components/Global' import { apolloClient } from '@services/apollo' import { isLocalStorageEnabled } from '@utils/isLocalStorageEnabled' import { setLoadingText } from '@utils/setLoadingText' diff --git a/src/assets/mui/theme.js b/src/assets/theme.js similarity index 100% rename from src/assets/mui/theme.js rename to src/assets/theme.js diff --git a/src/assets/mui/global.jsx b/src/components/Global.jsx similarity index 100% rename from src/assets/mui/global.jsx rename to src/components/Global.jsx From cab177885b7f9e3460a5e5dc0a8d6705d2eeecce Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:53:10 -0500 Subject: [PATCH 028/177] refactor: remove `ApplyGlobal` export since its unused --- src/components/Global.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Global.jsx b/src/components/Global.jsx index df39a0e2e..7a415a4fe 100644 --- a/src/components/Global.jsx +++ b/src/components/Global.jsx @@ -4,7 +4,7 @@ import GlobalStyles from '@mui/material/GlobalStyles' import { darken, lighten } from '@mui/material/styles' import { useMemory } from '@hooks/useMemory' -export function ApplyGlobal() { +function ApplyGlobal() { const online = useMemory((s) => s.online) return ( From 3b12eddca1ec65d5e3970585a43e47639475acdf Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 15:56:51 -0500 Subject: [PATCH 029/177] refactor: remove `src/components/general` folder --- .../{general => }/BasicListButton.jsx | 0 src/components/{general => }/ColoredTile.jsx | 0 src/components/ErrorBoundary.jsx | 2 +- src/components/{general => }/Footer.jsx | 0 src/components/{general => }/Header.jsx | 0 src/components/{general => }/I.jsx | 0 src/components/{general => }/Icons.jsx | 0 src/components/{general => }/Img.jsx | 0 src/components/{general => }/Loading.jsx | 0 .../{general => }/LocaleSelection.jsx | 0 src/components/{general => }/Menu.jsx | 17 +++++++-------- src/components/{general => }/Notification.jsx | 0 src/components/{general => }/QuestTitle.jsx | 0 .../{general => }/StyledDivider.jsx | 0 src/components/{general => }/TabPanel.jsx | 0 src/components/{general => }/ThemeToggle.jsx | 0 .../{general => }/ToggleTypography.jsx | 0 src/components/{general => }/VirtualGrid.jsx | 0 src/components/auth/Discord.jsx | 2 +- src/components/custom/CustomButton.jsx | 2 +- src/components/custom/DialogWrapper.jsx | 4 ++-- src/components/custom/Generator.jsx | 4 ++-- src/components/dialogs/BadgeSelection.jsx | 21 +++++++++---------- src/components/dialogs/ClientError.jsx | 2 +- src/components/dialogs/DonorPage.jsx | 2 +- src/components/dialogs/Feedback.jsx | 4 ++-- src/components/dialogs/Motd.jsx | 2 +- src/components/dialogs/NestSubmission.jsx | 4 ++-- src/components/dialogs/ResetFilters.jsx | 21 +++++++++---------- src/components/dialogs/UserOptions.jsx | 6 +++--- src/components/dialogs/filters/Advanced.jsx | 6 +++--- src/components/dialogs/filters/FilterMenu.jsx | 4 ++-- .../dialogs/filters/OptionsContainer.jsx | 2 +- .../dialogs/filters/PkmnFilterHelp.jsx | 11 +++++----- .../dialogs/filters/QuestConditions.jsx | 2 +- src/components/dialogs/filters/SliderTile.jsx | 2 +- .../dialogs/filters/SlotSelection.jsx | 8 +++---- src/components/popups/Gym.jsx | 2 +- src/components/popups/Pokemon.jsx | 2 +- src/components/popups/Pokestop.jsx | 2 +- src/components/tiles/S2Cell.jsx | 2 +- src/features/drawer/Actions.jsx | 4 ++-- src/features/drawer/Pokemon.jsx | 4 ++-- src/features/drawer/Section.jsx | 2 +- src/features/drawer/SelectorItem.jsx | 6 +++--- src/features/drawer/SelectorList.jsx | 4 ++-- src/features/drawer/Settings.jsx | 4 ++-- src/features/drawer/areas/index.jsx | 2 +- src/features/drawer/index.jsx | 4 ++-- src/features/profile/GymBadges.jsx | 6 +++--- src/features/profile/LinkAccounts.jsx | 2 +- src/features/profile/index.jsx | 4 ++-- src/features/scanner/Popup.jsx | 2 +- src/features/scanner/ScanDialog.jsx | 6 +++--- src/features/search/OptionImage.jsx | 2 +- src/features/search/index.jsx | 2 +- src/features/search/renderInput.jsx | 2 +- src/features/search/renderOption.jsx | 4 ++-- src/features/tutorial/Advanced.jsx | 2 +- src/features/tutorial/Welcome.jsx | 2 +- src/features/tutorial/index.jsx | 2 +- src/features/webhooks/Manage.jsx | 8 +++---- src/features/webhooks/Notification.jsx | 2 +- src/features/webhooks/Tracked.jsx | 2 +- src/features/webhooks/WebhookAdv.jsx | 4 ++-- src/features/webhooks/human/Location.jsx | 2 +- .../webhooks/human/area/AreaGroup.jsx | 2 +- .../webhooks/human/area/AreaSelection.jsx | 2 +- src/features/webhooks/human/profile/index.jsx | 2 +- .../webhooks/human/status/HookSelection.jsx | 2 +- src/pages/Blocked.jsx | 4 ++-- src/pages/data/components/Shared.jsx | 2 +- src/pages/login/CustomPage.jsx | 2 +- src/pages/login/DefaultPage.jsx | 2 +- src/pages/login/index.jsx | 2 +- src/pages/map/components/ActiveWeather.jsx | 8 +++---- src/pages/map/components/Clustering.jsx | 2 +- src/pages/map/components/FloatingBtn.jsx | 2 +- src/pages/map/components/QueryData.jsx | 2 +- 79 files changed, 124 insertions(+), 130 deletions(-) rename src/components/{general => }/BasicListButton.jsx (100%) rename src/components/{general => }/ColoredTile.jsx (100%) rename src/components/{general => }/Footer.jsx (100%) rename src/components/{general => }/Header.jsx (100%) rename src/components/{general => }/I.jsx (100%) rename src/components/{general => }/Icons.jsx (100%) rename src/components/{general => }/Img.jsx (100%) rename src/components/{general => }/Loading.jsx (100%) rename src/components/{general => }/LocaleSelection.jsx (100%) rename src/components/{general => }/Menu.jsx (91%) rename src/components/{general => }/Notification.jsx (100%) rename src/components/{general => }/QuestTitle.jsx (100%) rename src/components/{general => }/StyledDivider.jsx (100%) rename src/components/{general => }/TabPanel.jsx (100%) rename src/components/{general => }/ThemeToggle.jsx (100%) rename src/components/{general => }/ToggleTypography.jsx (100%) rename src/components/{general => }/VirtualGrid.jsx (100%) diff --git a/src/components/general/BasicListButton.jsx b/src/components/BasicListButton.jsx similarity index 100% rename from src/components/general/BasicListButton.jsx rename to src/components/BasicListButton.jsx diff --git a/src/components/general/ColoredTile.jsx b/src/components/ColoredTile.jsx similarity index 100% rename from src/components/general/ColoredTile.jsx rename to src/components/ColoredTile.jsx diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx index 81d6c27af..11675262c 100644 --- a/src/components/ErrorBoundary.jsx +++ b/src/components/ErrorBoundary.jsx @@ -12,7 +12,7 @@ import IconButton from '@mui/material/IconButton' import { withTranslation } from 'react-i18next' import Fetch from '@services/Fetch' -import Notification from './general/Notification' +import Notification from './Notification' /** @type {React.CSSProperties} */ const defaultStyle = { diff --git a/src/components/general/Footer.jsx b/src/components/Footer.jsx similarity index 100% rename from src/components/general/Footer.jsx rename to src/components/Footer.jsx diff --git a/src/components/general/Header.jsx b/src/components/Header.jsx similarity index 100% rename from src/components/general/Header.jsx rename to src/components/Header.jsx diff --git a/src/components/general/I.jsx b/src/components/I.jsx similarity index 100% rename from src/components/general/I.jsx rename to src/components/I.jsx diff --git a/src/components/general/Icons.jsx b/src/components/Icons.jsx similarity index 100% rename from src/components/general/Icons.jsx rename to src/components/Icons.jsx diff --git a/src/components/general/Img.jsx b/src/components/Img.jsx similarity index 100% rename from src/components/general/Img.jsx rename to src/components/Img.jsx diff --git a/src/components/general/Loading.jsx b/src/components/Loading.jsx similarity index 100% rename from src/components/general/Loading.jsx rename to src/components/Loading.jsx diff --git a/src/components/general/LocaleSelection.jsx b/src/components/LocaleSelection.jsx similarity index 100% rename from src/components/general/LocaleSelection.jsx rename to src/components/LocaleSelection.jsx diff --git a/src/components/general/Menu.jsx b/src/components/Menu.jsx similarity index 91% rename from src/components/general/Menu.jsx rename to src/components/Menu.jsx index f2be91390..81766e76d 100644 --- a/src/components/general/Menu.jsx +++ b/src/components/Menu.jsx @@ -11,18 +11,15 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import useFilter from '@hooks/useFilter' -import Header from '@components/general/Header' -import Footer from '@components/general/Footer' +import Header from '@components/Header' +import Footer from '@components/Footer' import { applyToAll } from '@services/filtering/applyToAll' import useGetAvailable from '@hooks/useGetAvailable' -import OptionsContainer from '../dialogs/filters/OptionsContainer' +import OptionsContainer from './dialogs/filters/OptionsContainer' import { VirtualGrid } from './VirtualGrid' -import { GenericSearch } from '../../features/drawer/ItemSearch' -import { - applyToAllWebhooks, - useWebhookStore, -} from '../../features/webhooks/store' +import { GenericSearch } from '../features/drawer/ItemSearch' +import { applyToAllWebhooks, useWebhookStore } from '../features/webhooks/store' /** * @template {import('@rm/types').AdvCategories} T @@ -34,7 +31,7 @@ import { * categories?: import('@rm/types').Available[] * title: string * titleAction: () => void - * extraButtons?: import('@components/general/Footer').FooterButton[] + * extraButtons?: import('@components/Footer').FooterButton[] * }} props */ export default function Menu({ @@ -79,7 +76,7 @@ export default function Menu({ const footerButtons = React.useMemo( () => - /** @type {import('@components/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/Footer').FooterButton[]} */ ([ { name: 'help', action: () => diff --git a/src/components/general/Notification.jsx b/src/components/Notification.jsx similarity index 100% rename from src/components/general/Notification.jsx rename to src/components/Notification.jsx diff --git a/src/components/general/QuestTitle.jsx b/src/components/QuestTitle.jsx similarity index 100% rename from src/components/general/QuestTitle.jsx rename to src/components/QuestTitle.jsx diff --git a/src/components/general/StyledDivider.jsx b/src/components/StyledDivider.jsx similarity index 100% rename from src/components/general/StyledDivider.jsx rename to src/components/StyledDivider.jsx diff --git a/src/components/general/TabPanel.jsx b/src/components/TabPanel.jsx similarity index 100% rename from src/components/general/TabPanel.jsx rename to src/components/TabPanel.jsx diff --git a/src/components/general/ThemeToggle.jsx b/src/components/ThemeToggle.jsx similarity index 100% rename from src/components/general/ThemeToggle.jsx rename to src/components/ThemeToggle.jsx diff --git a/src/components/general/ToggleTypography.jsx b/src/components/ToggleTypography.jsx similarity index 100% rename from src/components/general/ToggleTypography.jsx rename to src/components/ToggleTypography.jsx diff --git a/src/components/general/VirtualGrid.jsx b/src/components/VirtualGrid.jsx similarity index 100% rename from src/components/general/VirtualGrid.jsx rename to src/components/VirtualGrid.jsx diff --git a/src/components/auth/Discord.jsx b/src/components/auth/Discord.jsx index 0e608b751..ee24bf957 100644 --- a/src/components/auth/Discord.jsx +++ b/src/components/auth/Discord.jsx @@ -2,7 +2,7 @@ import * as React from 'react' import Button from '@mui/material/Button' import { useTranslation } from 'react-i18next' -import { I } from '../general/I' +import { I } from '../I' /** * diff --git a/src/components/custom/CustomButton.jsx b/src/components/custom/CustomButton.jsx index 06588afee..cef4709c4 100644 --- a/src/components/custom/CustomButton.jsx +++ b/src/components/custom/CustomButton.jsx @@ -1,7 +1,7 @@ import * as React from 'react' import Button from '@mui/material/Button' -import { I } from '../general/I' +import { I } from '../I' const THEME_COLORS = new Set([ 'success', diff --git a/src/components/custom/DialogWrapper.jsx b/src/components/custom/DialogWrapper.jsx index 5d7564a15..f57304e67 100644 --- a/src/components/custom/DialogWrapper.jsx +++ b/src/components/custom/DialogWrapper.jsx @@ -5,8 +5,8 @@ import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' -import Header from '../general/Header' -import Footer from '../general/Footer' +import Header from '../Header' +import Footer from '../Footer' export default function DialogWrapper({ configObj, diff --git a/src/components/custom/Generator.jsx b/src/components/custom/Generator.jsx index 28bae18f2..ff0697083 100644 --- a/src/components/custom/Generator.jsx +++ b/src/components/custom/Generator.jsx @@ -10,8 +10,8 @@ import LocalLogin from '../auth/Local' import Telegram from '../auth/Telegram' import CustomText from './CustomText' import CustomButton from './CustomButton' -import { Img } from '../general/Img' -import LocaleSelection from '../general/LocaleSelection' +import { Img } from '../Img' +import LocaleSelection from '../LocaleSelection' import LinkWrapper from './LinkWrapper' export default function Generator({ block = {}, defaultReturn = null }) { diff --git a/src/components/dialogs/BadgeSelection.jsx b/src/components/dialogs/BadgeSelection.jsx index bcecd1b50..c409939b4 100644 --- a/src/components/dialogs/BadgeSelection.jsx +++ b/src/components/dialogs/BadgeSelection.jsx @@ -10,8 +10,8 @@ import { ENUM_BADGES } from '@assets/constants' import { useLayoutStore } from '@hooks/useLayoutStore' import { MultiSelector } from '@features/drawer/MultiSelector' -import Header from '../general/Header' -import Footer from '../general/Footer' +import Header from '../Header' +import Footer from '../Footer' const handleClose = () => useLayoutStore.setState({ @@ -22,15 +22,14 @@ const handleClose = () => }, }) -const footerOptions = - /** @type {import('../general/Footer').FooterButton[]} */ ([ - { - name: 'close', - action: handleClose, - color: 'primary', - align: 'right', - }, - ]) +const footerOptions = /** @type {import('../Footer').FooterButton[]} */ ([ + { + name: 'close', + action: handleClose, + color: 'primary', + align: 'right', + }, +]) export default function BadgeSelection() { const { gymId, badge, open } = useLayoutStore((s) => s.gymBadge) diff --git a/src/components/dialogs/ClientError.jsx b/src/components/dialogs/ClientError.jsx index a1fb4552a..50b018442 100644 --- a/src/components/dialogs/ClientError.jsx +++ b/src/components/dialogs/ClientError.jsx @@ -9,7 +9,7 @@ import Button from '@mui/material/Button' import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' -import Header from '../general/Header' +import Header from '../Header' export default function ClientError() { const { t } = useTranslation() diff --git a/src/components/dialogs/DonorPage.jsx b/src/components/dialogs/DonorPage.jsx index 10f840330..a5957d551 100644 --- a/src/components/dialogs/DonorPage.jsx +++ b/src/components/dialogs/DonorPage.jsx @@ -10,7 +10,7 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import DialogWrapper from '../custom/DialogWrapper' import CustomTile from '../custom/CustomTile' -import { Loading } from '../general/Loading' +import { Loading } from '../Loading' const DEFAULT = { settings: {}, diff --git a/src/components/dialogs/Feedback.jsx b/src/components/dialogs/Feedback.jsx index 515de03c8..85c5e743f 100644 --- a/src/components/dialogs/Feedback.jsx +++ b/src/components/dialogs/Feedback.jsx @@ -10,8 +10,8 @@ import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' -import Header from '../general/Header' -import Footer from '../general/Footer' +import Header from '../Header' +import Footer from '../Footer' import { DialogWrapper } from './DialogWrapper' export default function Feedback() { diff --git a/src/components/dialogs/Motd.jsx b/src/components/dialogs/Motd.jsx index af758a928..0c6fc8c47 100644 --- a/src/components/dialogs/Motd.jsx +++ b/src/components/dialogs/Motd.jsx @@ -13,7 +13,7 @@ import Utility from '@services/Utility' import DialogWrapper from '../custom/DialogWrapper' import CustomTile from '../custom/CustomTile' -import { Loading } from '../general/Loading' +import { Loading } from '../Loading' const DEFAULT = /** @type {import('@rm/types').Config['map']['messageOfTheDay']} */ ({ diff --git a/src/components/dialogs/NestSubmission.jsx b/src/components/dialogs/NestSubmission.jsx index ad33de4e2..539b5e6fe 100644 --- a/src/components/dialogs/NestSubmission.jsx +++ b/src/components/dialogs/NestSubmission.jsx @@ -9,8 +9,8 @@ import Query from '@services/Query' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' -import Header from '../general/Header' -import Footer from '../general/Footer' +import Header from '../Header' +import Footer from '../Footer' export default function NestSubmission({ id, name }) { const open = useLayoutStore((s) => s.nestSubmissions) diff --git a/src/components/dialogs/ResetFilters.jsx b/src/components/dialogs/ResetFilters.jsx index a27aa7176..e15806097 100644 --- a/src/components/dialogs/ResetFilters.jsx +++ b/src/components/dialogs/ResetFilters.jsx @@ -9,21 +9,20 @@ import { useTranslation } from 'react-i18next' import { useLayoutStore } from '@hooks/useLayoutStore' -import Header from '../general/Header' -import Footer from '../general/Footer' +import Header from '../Header' +import Footer from '../Footer' import { DialogWrapper } from './DialogWrapper' const handleClose = () => useLayoutStore.setState({ resetFilters: false }) -const FOOTER_OPTIONS = - /** @type {import('../general/Footer').FooterButton[]} */ ([ - { - name: 'close', - action: handleClose, - color: 'primary', - align: 'right', - }, - ]) +const FOOTER_OPTIONS = /** @type {import('../Footer').FooterButton[]} */ ([ + { + name: 'close', + action: handleClose, + color: 'primary', + align: 'right', + }, +]) export default function ResetFilters() { const { t } = useTranslation() diff --git a/src/components/dialogs/UserOptions.jsx b/src/components/dialogs/UserOptions.jsx index 709fdcfd9..dc3a9ce33 100644 --- a/src/components/dialogs/UserOptions.jsx +++ b/src/components/dialogs/UserOptions.jsx @@ -15,8 +15,8 @@ import { toggleDialog, useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import { getPermission } from '@services/desktopNotification' -import Header from '../general/Header' -import Footer from '../general/Footer' +import Header from '../Header' +import Footer from '../Footer' import { DialogWrapper } from './DialogWrapper' function InputType({ option, subOption, localState, handleChange, category }) { @@ -101,7 +101,7 @@ function UserOptions() { const footerOptions = React.useMemo( () => - /** @type {import('@components/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/Footer').FooterButton[]} */ ([ { name: 'reset', action: () => { diff --git a/src/components/dialogs/filters/Advanced.jsx b/src/components/dialogs/filters/Advanced.jsx index 7b33adb37..0296e34de 100644 --- a/src/components/dialogs/filters/Advanced.jsx +++ b/src/components/dialogs/filters/Advanced.jsx @@ -8,8 +8,8 @@ import Utility from '@services/Utility' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useDeepStore, useStorage } from '@hooks/useStorage' -import Header from '@components/general/Header' -import Footer from '@components/general/Footer' +import Header from '@components/Header' +import Footer from '@components/Footer' import { BoolToggle, DualBoolToggle } from '@features/drawer/BoolToggle' import { ENABLED_ALL, XXS_XXL } from '@assets/constants' import { useTranslateById } from '@hooks/useTranslateById' @@ -79,7 +79,7 @@ export default function AdvancedFilter() { } } - /** @type {import('@components/general/Footer').FooterButton[]} */ + /** @type {import('@components/Footer').FooterButton[]} */ const footerOptions = React.useMemo( () => [ { diff --git a/src/components/dialogs/filters/FilterMenu.jsx b/src/components/dialogs/filters/FilterMenu.jsx index 72a74bb4a..2a4338dbb 100644 --- a/src/components/dialogs/filters/FilterMenu.jsx +++ b/src/components/dialogs/filters/FilterMenu.jsx @@ -1,6 +1,6 @@ // @ts-check import * as React from 'react' -import Menu from '@components/general/Menu' +import Menu from '@components/Menu' import { toggleDialog, useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' @@ -16,7 +16,7 @@ export default function FilterMenu() { const extraButtons = React.useMemo( () => - /** @type {import('@components/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/Footer').FooterButton[]} */ ([ { name: 'close', action: toggleDialog(false, category, 'filters'), diff --git a/src/components/dialogs/filters/OptionsContainer.jsx b/src/components/dialogs/filters/OptionsContainer.jsx index 0e1abe443..b95da85c7 100644 --- a/src/components/dialogs/filters/OptionsContainer.jsx +++ b/src/components/dialogs/filters/OptionsContainer.jsx @@ -9,7 +9,7 @@ import ReplayIcon from '@mui/icons-material/Replay' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' -import { BasicListButton } from '@components/general/BasicListButton' +import { BasicListButton } from '@components/BasicListButton' import Options from './Options' diff --git a/src/components/dialogs/filters/PkmnFilterHelp.jsx b/src/components/dialogs/filters/PkmnFilterHelp.jsx index 4d2abe4cc..d4e5b6d05 100644 --- a/src/components/dialogs/filters/PkmnFilterHelp.jsx +++ b/src/components/dialogs/filters/PkmnFilterHelp.jsx @@ -7,8 +7,8 @@ import Grid2 from '@mui/material/Unstable_Grid2' import { useTranslation } from 'react-i18next' import { Chip, Divider, useMediaQuery } from '@mui/material' -import Header from '@components/general/Header' -import Footer from '@components/general/Footer' +import Header from '@components/Header' +import Footer from '@components/Footer' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' @@ -93,10 +93,9 @@ function Card({ title, children, bgcolor, fullSize }) { const handleClose = () => useLayoutStore.setState({ pkmnFilterHelp: false }) -const OPTIONS = - /** @type {import('@components/general/Footer').FooterButton[]} */ ([ - { name: 'close', color: 'error', action: handleClose }, - ]) +const OPTIONS = /** @type {import('@components/Footer').FooterButton[]} */ ([ + { name: 'close', color: 'error', action: handleClose }, +]) export function PkmnFilterHelp() { const { t } = useTranslation() diff --git a/src/components/dialogs/filters/QuestConditions.jsx b/src/components/dialogs/filters/QuestConditions.jsx index ad17b3d8f..7382395bc 100644 --- a/src/components/dialogs/filters/QuestConditions.jsx +++ b/src/components/dialogs/filters/QuestConditions.jsx @@ -6,7 +6,7 @@ import { useMemory } from '@hooks/useMemory' import { useDeepStore, useStorage } from '@hooks/useStorage' import { FormControl, InputLabel, Select, MenuItem } from '@mui/material' import Typography from '@mui/material/Typography' -import QuestTitle from '@components/general/QuestTitle' +import QuestTitle from '@components/QuestTitle' /** * diff --git a/src/components/dialogs/filters/SliderTile.jsx b/src/components/dialogs/filters/SliderTile.jsx index 42eef08cf..1a92779ef 100644 --- a/src/components/dialogs/filters/SliderTile.jsx +++ b/src/components/dialogs/filters/SliderTile.jsx @@ -6,7 +6,7 @@ import TextField from '@mui/material/TextField' import Slider from '@mui/material/Slider' import { styled } from '@mui/material/styles' import { useTranslation } from 'react-i18next' -import { ToggleTypography } from '@components/general/ToggleTypography' +import { ToggleTypography } from '@components/ToggleTypography' import { MIN_MAX } from '@assets/constants' const StyledTextField = diff --git a/src/components/dialogs/filters/SlotSelection.jsx b/src/components/dialogs/filters/SlotSelection.jsx index 9da401305..15f192de6 100644 --- a/src/components/dialogs/filters/SlotSelection.jsx +++ b/src/components/dialogs/filters/SlotSelection.jsx @@ -10,11 +10,11 @@ import Divider from '@mui/material/Divider' import { basicEqualFn, useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage, useDeepStore } from '@hooks/useStorage' -import { Img } from '@components/general/Img' +import { Img } from '@components/Img' import { DualBoolToggle } from '@features/drawer/BoolToggle' import { ENABLED_ALL } from '@assets/constants' -import Header from '@components/general/Header' -import Footer from '@components/general/Footer' +import Header from '@components/Header' +import Footer from '@components/Footer' import Size from './Size' import { DialogWrapper } from '../DialogWrapper' @@ -67,7 +67,7 @@ export default function SlotSelection() { const footerOptions = React.useMemo( () => - /** @type {import('@components/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/Footer').FooterButton[]} */ ([ { name: 'disable_all', action: () => handleSizeChange(false, id), diff --git a/src/components/popups/Gym.jsx b/src/components/popups/Gym.jsx index e33ea6c07..5826330d0 100644 --- a/src/components/popups/Gym.jsx +++ b/src/components/popups/Gym.jsx @@ -21,7 +21,7 @@ import { setDeepStore, useStorage } from '@hooks/useStorage' import useWebhook from '@hooks/useWebhook' import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' -import { TextWithIcon } from '@components/general/Img' +import { TextWithIcon } from '@components/Img' import Title from './common/Title' import PowerUp from './common/PowerUp' diff --git a/src/components/popups/Pokemon.jsx b/src/components/popups/Pokemon.jsx index 083f06a8a..d0d95be1d 100644 --- a/src/components/popups/Pokemon.jsx +++ b/src/components/popups/Pokemon.jsx @@ -22,7 +22,7 @@ import { useMemory } from '@hooks/useMemory' import { setDeepStore, useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' -import { TextWithIcon } from '@components/general/Img' +import { TextWithIcon } from '@components/Img' import NameTT from './common/NameTT' import GenderIcon from './common/GenderIcon' diff --git a/src/components/popups/Pokestop.jsx b/src/components/popups/Pokestop.jsx index 1166fd5ce..1185db282 100644 --- a/src/components/popups/Pokestop.jsx +++ b/src/components/popups/Pokestop.jsx @@ -18,7 +18,7 @@ import { import { useTranslation, Trans } from 'react-i18next' import ErrorBoundary from '@components/ErrorBoundary' -import { Check, Help } from '@components/general/Icons' +import { Check, Help } from '@components/Icons' import { useMemory } from '@hooks/useMemory' import { setDeepStore, useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' diff --git a/src/components/tiles/S2Cell.jsx b/src/components/tiles/S2Cell.jsx index 9bb1802a8..6df6bb599 100644 --- a/src/components/tiles/S2Cell.jsx +++ b/src/components/tiles/S2Cell.jsx @@ -12,7 +12,7 @@ import { import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import Notification from '@components/general/Notification' +import Notification from '@components/Notification' import { getQueryArgs } from '@utils/getQueryArgs' /** diff --git a/src/features/drawer/Actions.jsx b/src/features/drawer/Actions.jsx index b64d396b6..24759a855 100644 --- a/src/features/drawer/Actions.jsx +++ b/src/features/drawer/Actions.jsx @@ -19,8 +19,8 @@ import { useMapStore } from '@hooks/useMapStore' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' -import { I } from '@components/general/I' -import { BasicListButton } from '@components/general/BasicListButton' +import { I } from '@components/I' +import { BasicListButton } from '@components/BasicListButton' /** @type {React.ChangeEventHandler} */ const importSettings = (e) => { diff --git a/src/features/drawer/Pokemon.jsx b/src/features/drawer/Pokemon.jsx index 6cf7840fc..11d23395f 100644 --- a/src/features/drawer/Pokemon.jsx +++ b/src/features/drawer/Pokemon.jsx @@ -27,9 +27,9 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import { StringFilterMemo } from '@components/dialogs/filters/StringFilter' import SliderTile from '@components/dialogs/filters/SliderTile' -import TabPanel from '@components/general/TabPanel' +import TabPanel from '@components/TabPanel' import { GenderListItem } from '@components/dialogs/filters/Gender' -import { BasicListButton } from '@components/general/BasicListButton' +import { BasicListButton } from '@components/BasicListButton' import { SelectorListMemo } from './SelectorList' import { BoolToggle, DualBoolToggle } from './BoolToggle' diff --git a/src/features/drawer/Section.jsx b/src/features/drawer/Section.jsx index 1ff78107c..5aa2a65f8 100644 --- a/src/features/drawer/Section.jsx +++ b/src/features/drawer/Section.jsx @@ -15,7 +15,7 @@ import { useMemory } from '@hooks/useMemory' import { toggleDialog, useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' -import { BasicListButton } from '@components/general/BasicListButton' +import { BasicListButton } from '@components/BasicListButton' import SettingsMenu from './Settings' import { PokemonDrawerMemo } from './Pokemon' diff --git a/src/features/drawer/SelectorItem.jsx b/src/features/drawer/SelectorItem.jsx index 5193c7cbb..96dd9e696 100644 --- a/src/features/drawer/SelectorItem.jsx +++ b/src/features/drawer/SelectorItem.jsx @@ -11,9 +11,9 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import { useDeepStore, useStorage } from '@hooks/useStorage' import { checkIfHasAll } from '@utils/hasAll' import Poracle from '@services/Poracle' -import { ColoredTile } from '@components/general/ColoredTile' -import { ToggleTypography } from '@components/general/ToggleTypography' -import { SQUARE_ITEM } from '@components/general/VirtualGrid' +import { ColoredTile } from '@components/ColoredTile' +import { ToggleTypography } from '@components/ToggleTypography' +import { SQUARE_ITEM } from '@components/VirtualGrid' import { useWebhookStore } from '../webhooks/store' diff --git a/src/features/drawer/SelectorList.jsx b/src/features/drawer/SelectorList.jsx index f056c89c5..1de5252fa 100644 --- a/src/features/drawer/SelectorList.jsx +++ b/src/features/drawer/SelectorList.jsx @@ -22,8 +22,8 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useDeepStore, useStorage } from '@hooks/useStorage' import useGetAvailable from '@hooks/useGetAvailable' -import { VirtualGrid } from '@components/general/VirtualGrid' -import TabPanel from '@components/general/TabPanel' +import { VirtualGrid } from '@components/VirtualGrid' +import TabPanel from '@components/TabPanel' import { BoolToggle } from './BoolToggle' import { GenericSearchMemo } from './ItemSearch' diff --git a/src/features/drawer/Settings.jsx b/src/features/drawer/Settings.jsx index bf79f99b4..339e9c2f5 100644 --- a/src/features/drawer/Settings.jsx +++ b/src/features/drawer/Settings.jsx @@ -33,8 +33,8 @@ import { getPermission, requestPermission, } from '@services/desktopNotification' -import LocaleSelection from '@components/general/LocaleSelection' -import { DividerWithMargin } from '@components/general/StyledDivider' +import LocaleSelection from '@components/LocaleSelection' +import { DividerWithMargin } from '@components/StyledDivider' import DrawerActions from './Actions' import { BoolToggle } from './BoolToggle' diff --git a/src/features/drawer/areas/index.jsx b/src/features/drawer/areas/index.jsx index 33adc1fd3..daecd2d82 100644 --- a/src/features/drawer/areas/index.jsx +++ b/src/features/drawer/areas/index.jsx @@ -4,7 +4,7 @@ import ListItem from '@mui/material/ListItem' import RestartAltIcon from '@mui/icons-material/RestartAlt' import { useStorage } from '@hooks/useStorage' -import { BasicListButton } from '@components/general/BasicListButton' +import { BasicListButton } from '@components/BasicListButton' import { GenericSearch } from '../ItemSearch' import { ScanAreasTable } from './AreaTable' diff --git a/src/features/drawer/index.jsx b/src/features/drawer/index.jsx index 98c07edeb..e280a0d23 100644 --- a/src/features/drawer/index.jsx +++ b/src/features/drawer/index.jsx @@ -10,8 +10,8 @@ import ListItemIcon from '@mui/material/ListItemIcon' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' -import { Img } from '@components/general/Img' -import { DividerWithMargin } from '@components/general/StyledDivider' +import { Img } from '@components/Img' +import { DividerWithMargin } from '@components/StyledDivider' import Actions from './Actions' import { DrawerSectionMemo } from './Section' diff --git a/src/features/profile/GymBadges.jsx b/src/features/profile/GymBadges.jsx index 9d997bbaa..9f063d7ec 100644 --- a/src/features/profile/GymBadges.jsx +++ b/src/features/profile/GymBadges.jsx @@ -10,9 +10,9 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import Query from '@services/Query' -import { VirtualGrid } from '@components/general/VirtualGrid' -import { Img } from '@components/general/Img' -import { ToggleTypography } from '@components/general/ToggleTypography' +import { VirtualGrid } from '@components/VirtualGrid' +import { Img } from '@components/Img' +import { ToggleTypography } from '@components/ToggleTypography' export function UserGymBadges() { const { t } = useTranslation() diff --git a/src/features/profile/LinkAccounts.jsx b/src/features/profile/LinkAccounts.jsx index 71acc3859..b7d29d861 100644 --- a/src/features/profile/LinkAccounts.jsx +++ b/src/features/profile/LinkAccounts.jsx @@ -14,7 +14,7 @@ import { METHODS } from '@assets/constants' import DiscordButton from '@components/auth/Discord' import Telegram from '@components/auth/Telegram' -import Notification from '@components/general/Notification' +import Notification from '@components/Notification' export function LinkAccounts() { const { t } = useTranslation() diff --git a/src/features/profile/index.jsx b/src/features/profile/index.jsx index ac4d77ef8..be2155789 100644 --- a/src/features/profile/index.jsx +++ b/src/features/profile/index.jsx @@ -10,8 +10,8 @@ import DialogContent from '@mui/material/DialogContent' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import Utility from '@services/Utility' -import Header from '@components/general/Header' -import Footer from '@components/general/Footer' +import Header from '@components/Header' +import Footer from '@components/Footer' import { DialogWrapper } from '@components/dialogs/DialogWrapper' import { UserBackups } from './Backups' diff --git a/src/features/scanner/Popup.jsx b/src/features/scanner/Popup.jsx index a1c8ac7d3..abd00af17 100644 --- a/src/features/scanner/Popup.jsx +++ b/src/features/scanner/Popup.jsx @@ -4,7 +4,7 @@ import List from '@mui/material/List' import { Popup } from 'react-leaflet' import { useTranslation } from 'react-i18next' -import { DividerWithMargin } from '@components/general/StyledDivider' +import { DividerWithMargin } from '@components/StyledDivider' import { InAllowedArea, diff --git a/src/features/scanner/ScanDialog.jsx b/src/features/scanner/ScanDialog.jsx index 34c6c3ecb..15e69995a 100644 --- a/src/features/scanner/ScanDialog.jsx +++ b/src/features/scanner/ScanDialog.jsx @@ -3,8 +3,8 @@ import * as React from 'react' import { Dialog, DialogContent, Typography } from '@mui/material' import { useTranslation } from 'react-i18next' -import Header from '@components/general/Header' -import Footer from '@components/general/Footer' +import Header from '@components/Header' +import Footer from '@components/Footer' import { SCAN_MODES } from '@assets/constants' import { useScanStore } from './store' @@ -28,7 +28,7 @@ export default function ScanDialog() { const footerOptions = React.useMemo( () => - /** @type {import('@components/general/Footer').FooterButton[]} */ ([ + /** @type {import('@components/Footer').FooterButton[]} */ ([ { name: 'close', icon: 'Clear', diff --git a/src/features/search/OptionImage.jsx b/src/features/search/OptionImage.jsx index b7b2991ed..de880e4fd 100644 --- a/src/features/search/OptionImage.jsx +++ b/src/features/search/OptionImage.jsx @@ -8,7 +8,7 @@ import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import getRewardInfo from '@utils/getRewardInfo' import { useTranslateById } from '@hooks/useTranslateById' -import { Img } from '@components/general/Img' +import { Img } from '@components/Img' /** @param {Partial} props */ function QuestImage(props) { diff --git a/src/features/search/index.jsx b/src/features/search/index.jsx index 70d392d02..b3fed9904 100644 --- a/src/features/search/index.jsx +++ b/src/features/search/index.jsx @@ -13,7 +13,7 @@ import Utility from '@services/Utility' import { fromSearchCategory } from '@utils/fromSearchCategory' import { useMapStore } from '@hooks/useMapStore' -import Header from '@components/general/Header' +import Header from '@components/Header' import { renderInput } from './renderInput' import { renderOption } from './renderOption' import { useSendSearch } from './useSendSearch' diff --git a/src/features/search/renderInput.jsx b/src/features/search/renderInput.jsx index 08f3b5f14..c852f04c6 100644 --- a/src/features/search/renderInput.jsx +++ b/src/features/search/renderInput.jsx @@ -15,7 +15,7 @@ import { useQuery } from '@apollo/client' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { SEARCHABLE } from '@services/queries/config' -import { Img } from '@components/general/Img' +import { Img } from '@components/Img' const SearchImage = React.memo( /** @param {{ name: string }} props */ ({ name }) => { diff --git a/src/features/search/renderOption.jsx b/src/features/search/renderOption.jsx index e3d0f9417..7fd8df12d 100644 --- a/src/features/search/renderOption.jsx +++ b/src/features/search/renderOption.jsx @@ -6,10 +6,10 @@ import ListItemIcon from '@mui/material/ListItemIcon' import ListItemText from '@mui/material/ListItemText' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' -import { Img } from '@components/general/Img' +import { Img } from '@components/Img' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import { RawQuestTitle } from '@components/general/QuestTitle' +import { RawQuestTitle } from '@components/QuestTitle' import { Divider, Typography } from '@mui/material' import Utility from '@services/Utility' diff --git a/src/features/tutorial/Advanced.jsx b/src/features/tutorial/Advanced.jsx index 74c3066ab..c1c619e69 100644 --- a/src/features/tutorial/Advanced.jsx +++ b/src/features/tutorial/Advanced.jsx @@ -21,7 +21,7 @@ import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' import { useMemory } from '@hooks/useMemory' -import { VirtualGrid } from '@components/general/VirtualGrid' +import { VirtualGrid } from '@components/VirtualGrid' import { StandardItem } from '@features/drawer/SelectorItem' import data from './data' diff --git a/src/features/tutorial/Welcome.jsx b/src/features/tutorial/Welcome.jsx index 4d4af73de..34c1dec6b 100644 --- a/src/features/tutorial/Welcome.jsx +++ b/src/features/tutorial/Welcome.jsx @@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' -import LocaleSelection from '@components/general/LocaleSelection' +import LocaleSelection from '@components/LocaleSelection' export default function TutWelcome() { const { t } = useTranslation() diff --git a/src/features/tutorial/index.jsx b/src/features/tutorial/index.jsx index da0208445..071da5722 100644 --- a/src/features/tutorial/index.jsx +++ b/src/features/tutorial/index.jsx @@ -13,7 +13,7 @@ import { useMutation } from '@apollo/client' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import Query from '@services/Query' -import Header from '@components/general/Header' +import Header from '@components/Header' import Welcome from './Welcome' import Advanced from './Advanced' diff --git a/src/features/webhooks/Manage.jsx b/src/features/webhooks/Manage.jsx index 52a6d9c3f..2c26414d7 100644 --- a/src/features/webhooks/Manage.jsx +++ b/src/features/webhooks/Manage.jsx @@ -14,8 +14,8 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import Poracle from '@services/Poracle' import Utility from '@services/Utility' -import Footer from '@components/general/Footer' -import Header from '@components/general/Header' +import Footer from '@components/Footer' +import Header from '@components/Header' import { apolloClient } from '@services/apollo' import Query from '@services/Query' import { allProfiles } from '@services/queries/webhook' @@ -23,7 +23,7 @@ import { WebhookItem } from '@features/drawer/SelectorItem' import Human from './human' import Tracked from './Tracked' -import Menu from '../../components/general/Menu' +import Menu from '../../components/Menu' import { setMode, setSelected, useWebhookStore } from './store' import { useGenFullFilters, useGetHookContext } from './hooks' import ProfileEditing from './human/profile' @@ -46,7 +46,7 @@ export default function Manage() { const [height, setHeight] = React.useState(0) const footerButtons = React.useMemo(() => { - /** @type {import('@components/general/Footer').FooterButton[]} */ + /** @type {import('@components/Footer').FooterButton[]} */ const buttons = [ { name: 'feedback', diff --git a/src/features/webhooks/Notification.jsx b/src/features/webhooks/Notification.jsx index 309efa1f1..14ec049ae 100644 --- a/src/features/webhooks/Notification.jsx +++ b/src/features/webhooks/Notification.jsx @@ -1,6 +1,6 @@ // @ts-check import * as React from 'react' -import Notification from '@components/general/Notification' +import Notification from '@components/Notification' import { resetAlert, useWebhookStore } from './store' diff --git a/src/features/webhooks/Tracked.jsx b/src/features/webhooks/Tracked.jsx index 58bfc32b9..983447222 100644 --- a/src/features/webhooks/Tracked.jsx +++ b/src/features/webhooks/Tracked.jsx @@ -6,7 +6,7 @@ import { Virtuoso } from 'react-virtuoso' import Typography from '@mui/material/Typography' import Box from '@mui/material/Box' -import { Loading } from '@components/general/Loading' +import { Loading } from '@components/Loading' import { GenericSearch } from '@features/drawer/ItemSearch' import TrackedTile from './tiles/TrackedTile' diff --git a/src/features/webhooks/WebhookAdv.jsx b/src/features/webhooks/WebhookAdv.jsx index 2c5a4d232..40e1bb470 100644 --- a/src/features/webhooks/WebhookAdv.jsx +++ b/src/features/webhooks/WebhookAdv.jsx @@ -32,8 +32,8 @@ import Utility from '@services/Utility' import Poracle from '@services/Poracle' import SliderTile from '@components/dialogs/filters/SliderTile' -import Header from '@components/general/Header' -import Footer from '@components/general/Footer' +import Header from '@components/Header' +import Footer from '@components/Footer' import { useWebhookStore } from './store' const skipFields = new Set([ diff --git a/src/features/webhooks/human/Location.jsx b/src/features/webhooks/human/Location.jsx index 7d1b46b87..f92d012f6 100644 --- a/src/features/webhooks/human/Location.jsx +++ b/src/features/webhooks/human/Location.jsx @@ -18,7 +18,7 @@ import { useMapEvents } from 'react-leaflet' import { setHuman } from '@services/queries/webhook' import { WEBHOOK_NOMINATIM } from '@services/queries/geocoder' import useLocation from '@hooks/useLocation' -import { Loading } from '@components/general/Loading' +import { Loading } from '@components/Loading' import { basicEqualFn } from '@hooks/useMemory' import { setModeBtn, useWebhookStore } from '../store' diff --git a/src/features/webhooks/human/area/AreaGroup.jsx b/src/features/webhooks/human/area/AreaGroup.jsx index 08ea13ced..eb6553460 100644 --- a/src/features/webhooks/human/area/AreaGroup.jsx +++ b/src/features/webhooks/human/area/AreaGroup.jsx @@ -6,7 +6,7 @@ import Divider from '@mui/material/Divider' import Button from '@mui/material/Button' import { useTranslation } from 'react-i18next' -import { Loading } from '@components/general/Loading' +import { Loading } from '@components/Loading' import { useGetAreas } from '../../hooks' import { MemoAreaChip, handleClick } from './AreaChip' diff --git a/src/features/webhooks/human/area/AreaSelection.jsx b/src/features/webhooks/human/area/AreaSelection.jsx index 685701083..818c14877 100644 --- a/src/features/webhooks/human/area/AreaSelection.jsx +++ b/src/features/webhooks/human/area/AreaSelection.jsx @@ -4,7 +4,7 @@ import { useQuery } from '@apollo/client' import { useTranslation } from 'react-i18next' import { WEBHOOK_GEOJSON } from '@services/queries/webhook' -import { Loading } from '@components/general/Loading' +import { Loading } from '@components/Loading' import MemoScanArea from '@components/tiles/ScanArea' import { useWebhookStore } from '../../store' diff --git a/src/features/webhooks/human/profile/index.jsx b/src/features/webhooks/human/profile/index.jsx index 062f152fb..74a2b7ec1 100644 --- a/src/features/webhooks/human/profile/index.jsx +++ b/src/features/webhooks/human/profile/index.jsx @@ -3,7 +3,7 @@ import * as React from 'react' import Grid from '@mui/material/Unstable_Grid2' import { useTranslation } from 'react-i18next' -import { Loading } from '@components/general/Loading' +import { Loading } from '@components/Loading' import { useGetWebhookData } from '../../hooks' import { MemoNewProfile } from './NewProfile' diff --git a/src/features/webhooks/human/status/HookSelection.jsx b/src/features/webhooks/human/status/HookSelection.jsx index c34e2ebed..0abf6e39c 100644 --- a/src/features/webhooks/human/status/HookSelection.jsx +++ b/src/features/webhooks/human/status/HookSelection.jsx @@ -15,7 +15,7 @@ import { WEBHOOK_USER, allProfiles, } from '@services/queries/webhook' -import { Loading } from '@components/general/Loading' +import { Loading } from '@components/Loading' import { useGetWebhookData } from '../../hooks' import { useWebhookStore } from '../../store' diff --git a/src/pages/Blocked.jsx b/src/pages/Blocked.jsx index 010143049..774ef4fbc 100644 --- a/src/pages/Blocked.jsx +++ b/src/pages/Blocked.jsx @@ -18,8 +18,8 @@ import ListItemText from '@mui/material/ListItemText' import { useMemory } from '@hooks/useMemory' import DiscordButton from '@components/auth/Discord' -import ThemeToggle from '@components/general/ThemeToggle' -import { I } from '@components/general/I' +import ThemeToggle from '@components/ThemeToggle' +import { I } from '@components/I' export default function BlockedPage() { const { t } = useTranslation() diff --git a/src/pages/data/components/Shared.jsx b/src/pages/data/components/Shared.jsx index 91b3b3ebf..229a4681e 100644 --- a/src/pages/data/components/Shared.jsx +++ b/src/pages/data/components/Shared.jsx @@ -8,7 +8,7 @@ import { styled } from '@mui/material/styles' import CheckIcon from '@mui/icons-material/Check' import ClearIcon from '@mui/icons-material/Clear' -import { BasicListButton } from '@components/general/BasicListButton' +import { BasicListButton } from '@components/BasicListButton' import { setNotification, useDataManagementStore } from '../hooks/store' diff --git a/src/pages/login/CustomPage.jsx b/src/pages/login/CustomPage.jsx index f88fdf82c..2a876a021 100644 --- a/src/pages/login/CustomPage.jsx +++ b/src/pages/login/CustomPage.jsx @@ -7,7 +7,7 @@ import { useQuery } from '@apollo/client' import { CUSTOM_COMPONENT } from '@services/queries/config' import CustomTile from '@components/custom/CustomTile' -import { Loading } from '@components/general/Loading' +import { Loading } from '@components/Loading' export function CustomLoginPage() { const { t, i18n } = useTranslation() diff --git a/src/pages/login/DefaultPage.jsx b/src/pages/login/DefaultPage.jsx index 31f710583..eea676f09 100644 --- a/src/pages/login/DefaultPage.jsx +++ b/src/pages/login/DefaultPage.jsx @@ -7,7 +7,7 @@ import Divider from '@mui/material/Divider' import { styled } from '@mui/material/styles' import { useMemory } from '@hooks/useMemory' -import LocaleSelection from '@components/general/LocaleSelection' +import LocaleSelection from '@components/LocaleSelection' import methods from './Methods' diff --git a/src/pages/login/index.jsx b/src/pages/login/index.jsx index dadc6d0df..d9a1f38b1 100644 --- a/src/pages/login/index.jsx +++ b/src/pages/login/index.jsx @@ -4,7 +4,7 @@ import { Navigate } from 'react-router-dom' import Box from '@mui/material/Box' import { useMemory } from '@hooks/useMemory' -import ThemeToggle from '@components/general/ThemeToggle' +import ThemeToggle from '@components/ThemeToggle' import { CustomLoginPage } from './CustomPage' import { DefaultLoginPage } from './DefaultPage' diff --git a/src/pages/map/components/ActiveWeather.jsx b/src/pages/map/components/ActiveWeather.jsx index 501f79643..1b8a3e7a6 100644 --- a/src/pages/map/components/ActiveWeather.jsx +++ b/src/pages/map/components/ActiveWeather.jsx @@ -12,9 +12,9 @@ import WeatherPopup from '@components/popups/Weather' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { apolloClient } from '@services/apollo' -import Header from '@components/general/Header' -import Footer from '@components/general/Footer' -import { Img } from '@components/general/Img' +import Header from '@components/Header' +import Footer from '@components/Footer' +import { Img } from '@components/Img' const StyledBox = styled(Box)(({ theme }) => ({ zIndex: 1000, @@ -67,7 +67,7 @@ export default function ActiveWeather() { const footerOptions = React.useMemo( () => - /** @type {import('../../../components/general/Footer').FooterButton[]} */ ([ + /** @type {import('../../../components/Footer').FooterButton[]} */ ([ { name: 'close', action: () => setOpen(false), diff --git a/src/pages/map/components/Clustering.jsx b/src/pages/map/components/Clustering.jsx index 2bc569a82..61b49d664 100644 --- a/src/pages/map/components/Clustering.jsx +++ b/src/pages/map/components/Clustering.jsx @@ -5,7 +5,7 @@ import Supercluster from 'supercluster' import { marker, divIcon, point } from 'leaflet' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import Notification from '@components/general/Notification' +import Notification from '@components/Notification' const IGNORE_CLUSTERING = new Set([ 'devices', diff --git a/src/pages/map/components/FloatingBtn.jsx b/src/pages/map/components/FloatingBtn.jsx index b15ce355a..a097f9cbb 100644 --- a/src/pages/map/components/FloatingBtn.jsx +++ b/src/pages/map/components/FloatingBtn.jsx @@ -31,7 +31,7 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import { useScanStore } from '@features/scanner/store' -import { I } from '@components/general/I' +import { I } from '@components/I' import { setModeBtn, useWebhookStore } from '@features/webhooks/store' /** @typedef {keyof ReturnType | keyof ReturnType} Keys */ diff --git a/src/pages/map/components/QueryData.jsx b/src/pages/map/components/QueryData.jsx index b366dc7b8..966b40936 100644 --- a/src/pages/map/components/QueryData.jsx +++ b/src/pages/map/components/QueryData.jsx @@ -12,7 +12,7 @@ import RobustTimeout from '@services/apollo/RobustTimeout' import Utility from '@services/Utility' import { FILTER_SKIP_LIST } from '@assets/constants' import * as index from '@components/tiles/index' -import Notification from '@components/general/Notification' +import Notification from '@components/Notification' import { GenerateCells } from '@components/tiles/S2Cell' import Clustering from './Clustering' From 14bcb1e447e9391a62ae36fae8b0217c8eff44f8 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:02:54 -0500 Subject: [PATCH 030/177] refactor: pokemon feature --- src/components/tiles/index.js | 2 +- .../pokemon/PokemonPopup.jsx} | 12 ++++++------ .../Pokemon.jsx => features/pokemon/PokemonTile.jsx} | 10 +++++----- src/features/pokemon/index.js | 5 +++++ .../pokemon.js => features/pokemon/pokemonMarker.js} | 4 ++-- src/features/tutorial/Popups.jsx | 2 +- 6 files changed, 20 insertions(+), 15 deletions(-) rename src/{components/popups/Pokemon.jsx => features/pokemon/PokemonPopup.jsx} (97%) rename src/{components/tiles/Pokemon.jsx => features/pokemon/PokemonTile.jsx} (96%) create mode 100644 src/features/pokemon/index.js rename src/{components/markers/pokemon.js => features/pokemon/pokemonMarker.js} (97%) diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index 850e8fd93..ab277f7f4 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -1,7 +1,7 @@ +import { PokemonTile as pokemon } from '@features/pokemon' import devices from './Device' import gyms from './Gym' import nests from './Nest' -import pokemon from './Pokemon' import pokestops from './Pokestop' import portals from './Portal' import scanCells from './ScanCell' diff --git a/src/components/popups/Pokemon.jsx b/src/features/pokemon/PokemonPopup.jsx similarity index 97% rename from src/components/popups/Pokemon.jsx rename to src/features/pokemon/PokemonPopup.jsx index d0d95be1d..d4a655a1d 100644 --- a/src/components/popups/Pokemon.jsx +++ b/src/features/pokemon/PokemonPopup.jsx @@ -24,12 +24,12 @@ import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' import { TextWithIcon } from '@components/Img' -import NameTT from './common/NameTT' -import GenderIcon from './common/GenderIcon' -import Navigation from './common/Navigation' -import Coords from './common/Coords' -import { TimeStamp } from './common/TimeStamps' -import { ExtraInfo } from './common/ExtraInfo' +import NameTT from '../../components/popups/common/NameTT' +import GenderIcon from '../../components/popups/common/GenderIcon' +import Navigation from '../../components/popups/common/Navigation' +import Coords from '../../components/popups/common/Coords' +import { TimeStamp } from '../../components/popups/common/TimeStamps' +import { ExtraInfo } from '../../components/popups/common/ExtraInfo' const rowClass = { width: 30, fontWeight: 'bold' } diff --git a/src/components/tiles/Pokemon.jsx b/src/features/pokemon/PokemonTile.jsx similarity index 96% rename from src/components/tiles/Pokemon.jsx rename to src/features/pokemon/PokemonTile.jsx index f728f2008..0c19c2d08 100644 --- a/src/components/tiles/Pokemon.jsx +++ b/src/features/pokemon/PokemonTile.jsx @@ -14,10 +14,10 @@ import useForcePopup from '@hooks/useForcePopup' import Utility from '@services/Utility' import { sendNotification } from '@services/desktopNotification' import { useMapStore } from '@hooks/useMapStore' +import ToolTipWrapper from '@components/tiles/Timer' -import PopupContent from '../popups/Pokemon' -import { basicMarker, fancyMarker } from '../markers/pokemon' -import ToolTipWrapper from './Timer' +import PopupContent from './PokemonPopup' +import { basicPokemonMarker, fancyPokemonMarker } from './pokemonMarker' /** * @@ -176,7 +176,7 @@ const PokemonTile = (pkmn) => { showWeather || opacity < 1 || pkmn.seen_type === 'nearby_cell' - ? fancyMarker({ + ? fancyPokemonMarker({ pkmn, iconUrl, iconSize, @@ -186,7 +186,7 @@ const PokemonTile = (pkmn) => { opacity, timeOfDay, }) - : basicMarker({ iconUrl, iconSize }) + : basicPokemonMarker({ iconUrl, iconSize }) } > diff --git a/src/features/pokemon/index.js b/src/features/pokemon/index.js new file mode 100644 index 000000000..6a2eb31e1 --- /dev/null +++ b/src/features/pokemon/index.js @@ -0,0 +1,5 @@ +import PokemonPopup from './PokemonPopup' +import PokemonTile from './PokemonTile' + +export * from './pokemonMarker' +export { PokemonPopup, PokemonTile } diff --git a/src/components/markers/pokemon.js b/src/features/pokemon/pokemonMarker.js similarity index 97% rename from src/components/markers/pokemon.js rename to src/features/pokemon/pokemonMarker.js index 2540948ad..211012efe 100644 --- a/src/components/markers/pokemon.js +++ b/src/features/pokemon/pokemonMarker.js @@ -6,7 +6,7 @@ import { useMemory } from '@hooks/useMemory' * @param {{ iconUrl: string, iconSize: number }} props * @returns */ -export const basicMarker = ({ iconUrl, iconSize }) => +export const basicPokemonMarker = ({ iconUrl, iconSize }) => new Icon({ iconUrl, iconSize: [iconSize, iconSize], @@ -15,7 +15,7 @@ export const basicMarker = ({ iconUrl, iconSize }) => className: 'marker', }) -export const fancyMarker = ({ +export const fancyPokemonMarker = ({ pkmn, iconUrl, iconSize, diff --git a/src/features/tutorial/Popups.jsx b/src/features/tutorial/Popups.jsx index fe8b85b4f..7c66b1106 100644 --- a/src/features/tutorial/Popups.jsx +++ b/src/features/tutorial/Popups.jsx @@ -3,7 +3,7 @@ import { Grid, DialogContent, Typography, Divider } from '@mui/material' import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' -import PokemonPopup from '@components/popups/Pokemon' +import PokemonPopup from '@features/pokemon/PokemonPopup' import data from './data' export default function TutPopup({ isMobile }) { From 91ee86c7ee214242cd25e052ee2ce69a152e8034 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:06:45 -0500 Subject: [PATCH 031/177] refactor: pokestop feature --- src/components/tiles/index.js | 2 +- .../pokestop/PokestopPopup.jsx} | 23 ++++++++++--------- .../pokestop/PokestopTile.jsx} | 16 ++++++------- src/features/pokestop/index.js | 3 +++ .../pokestop}/usePokestopMarker.js | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) rename src/{components/popups/Pokestop.jsx => features/pokestop/PokestopPopup.jsx} (97%) rename src/{components/tiles/Pokestop.jsx => features/pokestop/PokestopTile.jsx} (94%) create mode 100644 src/features/pokestop/index.js rename src/{components/markers => features/pokestop}/usePokestopMarker.js (99%) diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index ab277f7f4..2ad08ecbb 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -1,8 +1,8 @@ import { PokemonTile as pokemon } from '@features/pokemon' +import { PokestopTile as pokestops } from '@features/pokestop/PokestopTile' import devices from './Device' import gyms from './Gym' import nests from './Nest' -import pokestops from './Pokestop' import portals from './Portal' import scanCells from './ScanCell' import scanAreas from './ScanArea' diff --git a/src/components/popups/Pokestop.jsx b/src/features/pokestop/PokestopPopup.jsx similarity index 97% rename from src/components/popups/Pokestop.jsx rename to src/features/pokestop/PokestopPopup.jsx index 1185db282..61de51f59 100644 --- a/src/components/popups/Pokestop.jsx +++ b/src/features/pokestop/PokestopPopup.jsx @@ -26,16 +26,16 @@ import { getBadge } from '@utils/getBadge' import getRewardInfo from '@utils/getRewardInfo' import { getGruntReward } from '@utils/getGruntReward' -import Dropdown from './common/Dropdown' -import TimeTile from './common/TimeTile' -import Navigation from './common/Navigation' -import Coords from './common/Coords' -import Title from './common/Title' -import HeaderImage from './common/HeaderImage' -import Timer from './common/Timer' -import PowerUp from './common/PowerUp' -import NameTT from './common/NameTT' -import { TimeStamp } from './common/TimeStamps' +import Dropdown from '../../components/popups/common/Dropdown' +import TimeTile from '../../components/popups/common/TimeTile' +import Navigation from '../../components/popups/common/Navigation' +import Coords from '../../components/popups/common/Coords' +import Title from '../../components/popups/common/Title' +import HeaderImage from '../../components/popups/common/HeaderImage' +import Timer from '../../components/popups/common/Timer' +import PowerUp from '../../components/popups/common/PowerUp' +import NameTT from '../../components/popups/common/NameTT' +import { TimeStamp } from '../../components/popups/common/TimeStamps' /** * @@ -47,7 +47,7 @@ import { TimeStamp } from './common/TimeStamps' * }} props * @returns */ -export default function PokestopPopup({ +export function PokestopPopup({ hasLure, hasInvasion, hasQuest, @@ -329,6 +329,7 @@ const MenuActions = ({ useMemory.setState((prev) => ({ hideList: new Set(prev.hideList).add(id) })) } + /** @param {string} key */ const setState = (key) => setDeepStore(`filters.pokestops.filter.${key}.enabled`, false) diff --git a/src/components/tiles/Pokestop.jsx b/src/features/pokestop/PokestopTile.jsx similarity index 94% rename from src/components/tiles/Pokestop.jsx rename to src/features/pokestop/PokestopTile.jsx index 0dc6137ba..ea29f7dea 100644 --- a/src/components/tiles/Pokestop.jsx +++ b/src/features/pokestop/PokestopTile.jsx @@ -7,17 +7,17 @@ import useMarkerTimer from '@hooks/useMarkerTimer' import { basicEqualFn, useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import useForcePopup from '@hooks/useForcePopup' +import ToolTipWrapper from '@components/tiles/Timer' -import PopupContent from '../popups/Pokestop' -import ToolTipWrapper from './Timer' -import usePokestopMarker from '../markers/usePokestopMarker' +import { PokestopPopup } from './PokestopPopup' +import { usePokestopMarker } from './usePokestopMarker' /** * * @param {import('@rm/types').Pokestop} pokestop * @returns */ -const PokestopTile = (pokestop) => { +const BasePokestopTile = (pokestop) => { const [stateChange, setStateChange] = React.useState(false) const [markerRef, setMarkerRef] = React.useState(null) @@ -126,7 +126,7 @@ const PokestopTile = (pokestop) => { icon={icon} > - { ) : null } -const MemoPokestopTile = React.memo( - PokestopTile, +export const PokestopTile = React.memo( + BasePokestopTile, (prev, next) => prev.id === next.id && prev.lure_expire_timestamp === next.lure_expire_timestamp && @@ -182,5 +182,3 @@ const MemoPokestopTile = React.memo( : true) && prev.events?.length === next.events?.length, ) - -export default MemoPokestopTile diff --git a/src/features/pokestop/index.js b/src/features/pokestop/index.js new file mode 100644 index 000000000..ac0a3777e --- /dev/null +++ b/src/features/pokestop/index.js @@ -0,0 +1,3 @@ +export * from './PokestopPopup' +export * from './PokestopTile' +export * from './usePokestopMarker' diff --git a/src/components/markers/usePokestopMarker.js b/src/features/pokestop/usePokestopMarker.js similarity index 99% rename from src/components/markers/usePokestopMarker.js rename to src/features/pokestop/usePokestopMarker.js index 27ad01448..4154f5acf 100644 --- a/src/components/markers/usePokestopMarker.js +++ b/src/features/pokestop/usePokestopMarker.js @@ -15,7 +15,7 @@ import useOpacity from '@hooks/useOpacity' * } & import('@rm/types').Pokestop} param0 * @returns */ -export default function usePokestopMarker({ +export function usePokestopMarker({ hasQuest, hasLure, hasInvasion, From e8bf8dca154e1c81d53d2d19e4fbf319d6d40cef Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:09:40 -0500 Subject: [PATCH 032/177] refactor: gym feature --- src/components/tiles/index.js | 2 +- .../popups/Gym.jsx => features/gym/GymPopup.jsx} | 16 ++++++++-------- .../tiles/Gym.jsx => features/gym/GymTile.jsx} | 16 +++++++--------- .../markers/gym.js => features/gym/gymMarker.js} | 2 +- src/features/gym/index.js | 3 +++ 5 files changed, 20 insertions(+), 19 deletions(-) rename src/{components/popups/Gym.jsx => features/gym/GymPopup.jsx} (97%) rename src/{components/tiles/Gym.jsx => features/gym/GymTile.jsx} (96%) rename src/{components/markers/gym.js => features/gym/gymMarker.js} (99%) create mode 100644 src/features/gym/index.js diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index 2ad08ecbb..89dc29c57 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -1,7 +1,7 @@ import { PokemonTile as pokemon } from '@features/pokemon' import { PokestopTile as pokestops } from '@features/pokestop/PokestopTile' import devices from './Device' -import gyms from './Gym' +import gyms from '../../features/gym/GymTile' import nests from './Nest' import portals from './Portal' import scanCells from './ScanCell' diff --git a/src/components/popups/Gym.jsx b/src/features/gym/GymPopup.jsx similarity index 97% rename from src/components/popups/Gym.jsx rename to src/features/gym/GymPopup.jsx index 5826330d0..7eee136d2 100644 --- a/src/components/popups/Gym.jsx +++ b/src/features/gym/GymPopup.jsx @@ -23,13 +23,13 @@ import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' import { TextWithIcon } from '@components/Img' -import Title from './common/Title' -import PowerUp from './common/PowerUp' -import GenderIcon from './common/GenderIcon' -import Navigation from './common/Navigation' -import Coords from './common/Coords' -import { TimeStamp } from './common/TimeStamps' -import { ExtraInfo } from './common/ExtraInfo' +import Title from '../../components/popups/common/Title' +import PowerUp from '../../components/popups/common/PowerUp' +import GenderIcon from '../../components/popups/common/GenderIcon' +import Navigation from '../../components/popups/common/Navigation' +import Coords from '../../components/popups/common/Coords' +import { TimeStamp } from '../../components/popups/common/TimeStamps' +import { ExtraInfo } from '../../components/popups/common/ExtraInfo' /** * @@ -40,7 +40,7 @@ import { ExtraInfo } from './common/ExtraInfo' * } & import('@rm/types').Gym} props * @returns */ -export default function GymPopup({ hasRaid, hasHatched, raidIconUrl, ...gym }) { +export function GymPopup({ hasRaid, hasHatched, raidIconUrl, ...gym }) { const { t } = useTranslation() const { perms } = useMemory((state) => state.auth) const popups = useStorage((state) => state.popups) diff --git a/src/components/tiles/Gym.jsx b/src/features/gym/GymTile.jsx similarity index 96% rename from src/components/tiles/Gym.jsx rename to src/features/gym/GymTile.jsx index f7d19b264..ca2f44469 100644 --- a/src/components/tiles/Gym.jsx +++ b/src/features/gym/GymTile.jsx @@ -12,9 +12,9 @@ import useForcePopup from '@hooks/useForcePopup' import { sendNotification } from '@services/desktopNotification' import Utility from '@services/Utility' -import gymMarker from '../markers/gym' -import PopupContent from '../popups/Gym' -import ToolTipWrapper from './Timer' +import { gymMarker } from './gymMarker' +import { GymPopup } from './GymPopup' +import ToolTipWrapper from '../../components/tiles/Timer' /** @param {number} team */ const getColor = (team) => { @@ -35,7 +35,7 @@ const getColor = (team) => { * @param {import('@rm/types').Gym} gym * @returns */ -const GymTile = (gym) => { +const BaseGymTile = (gym) => { const [markerRef, setMarkerRef] = React.useState(null) const [stateChange, setStateChange] = React.useState(false) @@ -183,7 +183,7 @@ const GymTile = (gym) => { })} > - { ) } -const MemoGym = React.memo( - GymTile, +export const GymTile = React.memo( + BaseGymTile, (prev, next) => prev.raid_pokemon_id === next.raid_pokemon_id && prev.raid_level === next.raid_level && @@ -232,5 +232,3 @@ const MemoGym = React.memo( prev.available_slots === next.available_slots && prev.updated === next.updated, ) - -export default MemoGym diff --git a/src/components/markers/gym.js b/src/features/gym/gymMarker.js similarity index 99% rename from src/components/markers/gym.js rename to src/features/gym/gymMarker.js index b8e98a6c2..e1c39342e 100644 --- a/src/components/markers/gym.js +++ b/src/features/gym/gymMarker.js @@ -34,7 +34,7 @@ const getBadgeColor = (raidLevel) => { * } & import('@rm/types').Gym} params * @returns */ -export default function gymMarker({ +export function gymMarker({ gymIconUrl, gymIconSize, raidIconUrl, diff --git a/src/features/gym/index.js b/src/features/gym/index.js new file mode 100644 index 000000000..dfd7d966f --- /dev/null +++ b/src/features/gym/index.js @@ -0,0 +1,3 @@ +export * from './GymPopup' +export * from './GymTile' +export * from './gymMarker' From 59072b360d8dd7a4c33b0ba72a149906f656f788 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:14:34 -0500 Subject: [PATCH 033/177] refactor: device feature --- src/components/tiles/index.js | 4 ++-- .../device/DevicePath.jsx} | 8 +++----- .../device/DevicePopup.jsx} | 2 +- .../device/DeviceTile.jsx} | 18 ++++++++---------- .../device/deviceMarker.js} | 2 +- src/features/device/index.js | 4 ++++ 6 files changed, 19 insertions(+), 19 deletions(-) rename src/{components/popups/DevicePoly.jsx => features/device/DevicePath.jsx} (92%) rename src/{components/popups/Device.jsx => features/device/DevicePopup.jsx} (95%) rename src/{components/tiles/Device.jsx => features/device/DeviceTile.jsx} (80%) rename src/{components/markers/device.js => features/device/deviceMarker.js} (82%) create mode 100644 src/features/device/index.js diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index 89dc29c57..76f86189f 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -1,7 +1,7 @@ import { PokemonTile as pokemon } from '@features/pokemon' import { PokestopTile as pokestops } from '@features/pokestop/PokestopTile' -import devices from './Device' -import gyms from '../../features/gym/GymTile' +import { GymTile as gyms } from '@features/gym/GymTile' +import { DeviceTile as devices } from '../../features/device/DeviceTile' import nests from './Nest' import portals from './Portal' import scanCells from './ScanCell' diff --git a/src/components/popups/DevicePoly.jsx b/src/features/device/DevicePath.jsx similarity index 92% rename from src/components/popups/DevicePoly.jsx rename to src/features/device/DevicePath.jsx index b1e249a5a..fe7e822a2 100644 --- a/src/components/popups/DevicePoly.jsx +++ b/src/features/device/DevicePath.jsx @@ -10,7 +10,7 @@ import { useStorage } from '@hooks/useStorage' * @param {import('@rm/types').Device} props * @returns */ -const DevicePoly = ({ route, type, radius }) => { +const BaseDevicePath = ({ route, type, radius }) => { const color = useStorage((s) => s.userSettings.admin.devicePathColor) const safeRoute = React.useMemo(() => { @@ -59,9 +59,7 @@ const DevicePoly = ({ route, type, radius }) => { )) } -const MemoDevicePoly = React.memo( - DevicePoly, +export const DevicePath = React.memo( + BaseDevicePath, (prev, next) => prev.type === next.type, ) - -export default MemoDevicePoly diff --git a/src/components/popups/Device.jsx b/src/features/device/DevicePopup.jsx similarity index 95% rename from src/components/popups/Device.jsx rename to src/features/device/DevicePopup.jsx index dff1f48e9..8dd38c09a 100644 --- a/src/components/popups/Device.jsx +++ b/src/features/device/DevicePopup.jsx @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' -export default function DevicePopup({ isOnline, ts, ...device }) { +export function DevicePopup({ isOnline, ts, ...device }) { const { t } = useTranslation() React.useEffect(() => { diff --git a/src/components/tiles/Device.jsx b/src/features/device/DeviceTile.jsx similarity index 80% rename from src/components/tiles/Device.jsx rename to src/features/device/DeviceTile.jsx index d4a8e7a00..213d5c5b9 100644 --- a/src/components/tiles/Device.jsx +++ b/src/features/device/DeviceTile.jsx @@ -6,16 +6,16 @@ import { Marker, Popup } from 'react-leaflet' import { basicEqualFn, useMemory } from '@hooks/useMemory' -import deviceMarker from '../markers/device' -import PopupContent from '../popups/Device' -import DevicePoly from '../popups/DevicePoly' +import { deviceMarker } from './deviceMarker' +import { DevicePath } from './DevicePath' +import { DevicePopup } from './DevicePopup' /** * * @param {import('@rm/types').Device} device * @returns */ -const DeviceTile = (device) => { +const BaseDeviceTile = (device) => { const ts = Math.floor(Date.now() / 1000) const [poly, setPoly] = React.useState(false) const markerRef = React.useRef(null) @@ -51,20 +51,18 @@ const DeviceTile = (device) => { }} > - + {poly && !device.isMad && ( - + )} ) } -const MemoDevice = React.memo( - DeviceTile, +export const DeviceTile = React.memo( + BaseDeviceTile, (prev, next) => prev.updated === next.updated, ) - -export default MemoDevice diff --git a/src/components/markers/device.js b/src/features/device/deviceMarker.js similarity index 82% rename from src/components/markers/device.js rename to src/features/device/deviceMarker.js index 8caca3604..180da1b70 100644 --- a/src/components/markers/device.js +++ b/src/features/device/deviceMarker.js @@ -1,6 +1,6 @@ import { Icon } from 'leaflet' -export default function getDeviceMarkers(iconUrl, iconSize, modifiers) { +export function deviceMarker(iconUrl, iconSize, modifiers) { const { sizeMultiplier, offsetX, offsetY, popupX, popupY } = modifiers return new Icon({ iconUrl, diff --git a/src/features/device/index.js b/src/features/device/index.js new file mode 100644 index 000000000..271026bec --- /dev/null +++ b/src/features/device/index.js @@ -0,0 +1,4 @@ +export * from './DevicePath' +export * from './DevicePopup' +export * from './deviceMarker' +export * from './DeviceTile' From f4e175050dd351fc604075219dced3654bcb45fc Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:17:32 -0500 Subject: [PATCH 034/177] refactor: nest feature --- src/components/tiles/index.js | 4 ++-- .../Nest.jsx => features/nest/NestPopup.jsx} | 2 +- .../tiles/Nest.jsx => features/nest/NestTile.jsx} | 14 ++++++-------- src/features/nest/index.js | 3 +++ .../nest.js => features/nest/nestMarker.js} | 8 +------- 5 files changed, 13 insertions(+), 18 deletions(-) rename src/{components/popups/Nest.jsx => features/nest/NestPopup.jsx} (99%) rename src/{components/tiles/Nest.jsx => features/nest/NestTile.jsx} (90%) create mode 100644 src/features/nest/index.js rename src/{components/markers/nest.js => features/nest/nestMarker.js} (95%) diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index 76f86189f..00d78ed7d 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -1,8 +1,8 @@ import { PokemonTile as pokemon } from '@features/pokemon' import { PokestopTile as pokestops } from '@features/pokestop/PokestopTile' import { GymTile as gyms } from '@features/gym/GymTile' -import { DeviceTile as devices } from '../../features/device/DeviceTile' -import nests from './Nest' +import { DeviceTile as devices } from '@features/device/DeviceTile' +import { NestTile as nests } from '@features/nest/NestTile' import portals from './Portal' import scanCells from './ScanCell' import scanAreas from './ScanArea' diff --git a/src/components/popups/Nest.jsx b/src/features/nest/NestPopup.jsx similarity index 99% rename from src/components/popups/Nest.jsx rename to src/features/nest/NestPopup.jsx index f9aac66e4..97fd5def8 100644 --- a/src/components/popups/Nest.jsx +++ b/src/features/nest/NestPopup.jsx @@ -39,7 +39,7 @@ const getColor = (timeSince) => { * }} props * @returns */ -export default function NestPopup({ +export function NestPopup({ recent, iconUrl, pokemon_id, diff --git a/src/components/tiles/Nest.jsx b/src/features/nest/NestTile.jsx similarity index 90% rename from src/components/tiles/Nest.jsx rename to src/features/nest/NestTile.jsx index 87231c578..aa22dadd0 100644 --- a/src/components/tiles/Nest.jsx +++ b/src/features/nest/NestTile.jsx @@ -7,15 +7,15 @@ import { basicEqualFn, useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import useForcePopup from '@hooks/useForcePopup' -import nestMarker from '../markers/nest' -import PopupContent from '../popups/Nest' +import { nestMarker } from './nestMarker' +import { NestPopup } from './NestPopup' /** * * @param {import('@rm/types').Nest} nest * @returns */ -const NestTile = (nest) => { +const BaseNestTile = (nest) => { const recent = Date.now() / 1000 - nest.updated < 172800000 const internalId = `${nest.pokemon_id}-${nest.pokemon_form}` @@ -46,7 +46,7 @@ const NestTile = (nest) => { <> - + @@ -104,9 +104,7 @@ const NestGeoJSON = ({ polygon_path }) => { return } -const MemoNestTile = React.memo( - NestTile, +export const NestTile = React.memo( + BaseNestTile, (prev, next) => prev.updated === next.updated && prev.name === next.name, ) - -export default MemoNestTile diff --git a/src/features/nest/index.js b/src/features/nest/index.js new file mode 100644 index 000000000..5bfa3ffd5 --- /dev/null +++ b/src/features/nest/index.js @@ -0,0 +1,3 @@ +export * from './NestPopup' +export * from './NestTile' +export * from './nestMarker' diff --git a/src/components/markers/nest.js b/src/features/nest/nestMarker.js similarity index 95% rename from src/components/markers/nest.js rename to src/features/nest/nestMarker.js index b10f08617..0d22b223c 100644 --- a/src/components/markers/nest.js +++ b/src/features/nest/nestMarker.js @@ -13,13 +13,7 @@ import { useMemory } from '@hooks/useMemory' * }} props * @returns */ -export default function nestMarker({ - iconUrl, - pokemonId, - formId, - iconSize, - recent, -}) { +export function nestMarker({ iconUrl, pokemonId, formId, iconSize, recent }) { const { Icons, masterfile } = useMemory.getState() const { types } = masterfile.pokemon[pokemonId]?.forms?.[formId]?.types ? masterfile.pokemon[pokemonId].forms[formId] From 0cf2188fd0a01974590013fbe3f2bea3413a8e45 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:19:21 -0500 Subject: [PATCH 035/177] refactor: portal feature --- src/components/tiles/index.js | 2 +- .../Portal.jsx => features/portal/PortalPopup.jsx} | 13 +++---------- .../Portal.jsx => features/portal/PortalTile.jsx} | 12 +++++------- src/features/portal/index.js | 2 ++ 4 files changed, 11 insertions(+), 18 deletions(-) rename src/{components/popups/Portal.jsx => features/portal/PortalPopup.jsx} (93%) rename src/{components/tiles/Portal.jsx => features/portal/PortalTile.jsx} (82%) create mode 100644 src/features/portal/index.js diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index 00d78ed7d..39eae4df1 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -3,7 +3,7 @@ import { PokestopTile as pokestops } from '@features/pokestop/PokestopTile' import { GymTile as gyms } from '@features/gym/GymTile' import { DeviceTile as devices } from '@features/device/DeviceTile' import { NestTile as nests } from '@features/nest/NestTile' -import portals from './Portal' +import { PortalTile as portals } from '../../features/portal/PortalTile' import scanCells from './ScanCell' import scanAreas from './ScanArea' import spawnpoints from './Spawnpoint' diff --git a/src/components/popups/Portal.jsx b/src/features/portal/PortalPopup.jsx similarity index 93% rename from src/components/popups/Portal.jsx rename to src/features/portal/PortalPopup.jsx index be050f9ac..b393929d4 100644 --- a/src/components/popups/Portal.jsx +++ b/src/features/portal/PortalPopup.jsx @@ -9,22 +9,15 @@ import ErrorBoundary from '@components/ErrorBoundary' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import Navigation from './common/Navigation' -import Coords from './common/Coords' +import Navigation from '../../components/popups/common/Navigation' +import Coords from '../../components/popups/common/Coords' /** * * @param {import('@rm/types').Portal} props * @returns */ -export default function PortalPopup({ - url, - name, - lat, - lon, - updated, - imported, -}) { +export function PortalPopup({ url, name, lat, lon, updated, imported }) { const { t } = useTranslation() const Icons = useMemory((s) => s.Icons) const enablePortalPopupCoords = useStorage( diff --git a/src/components/tiles/Portal.jsx b/src/features/portal/PortalTile.jsx similarity index 82% rename from src/components/tiles/Portal.jsx rename to src/features/portal/PortalTile.jsx index 95f4b229c..68fd37e1b 100644 --- a/src/components/tiles/Portal.jsx +++ b/src/features/portal/PortalTile.jsx @@ -6,14 +6,14 @@ import { Circle, Popup } from 'react-leaflet' import { useStorage } from '@hooks/useStorage' import useForcePopup from '@hooks/useForcePopup' -import PopupContent from '../popups/Portal' +import { PortalPopup } from './PortalPopup' /** * * @param {{ force?: boolean } & import('@rm/types').Portal} portal * @returns */ -const PortalTile = (portal) => { +const BasePortalTile = (portal) => { const [markerRef, setMarkerRef] = React.useState(null) const color = useStorage((s) => Date.now() / 1000 - portal.imported > 86400 @@ -34,15 +34,13 @@ const PortalTile = (portal) => { fillColor={color} > - + ) } -const MemoPortalTile = React.memo( - PortalTile, +export const PortalTile = React.memo( + BasePortalTile, (prev, next) => prev.updated === next.updated, ) - -export default MemoPortalTile diff --git a/src/features/portal/index.js b/src/features/portal/index.js new file mode 100644 index 000000000..5f0ff2f40 --- /dev/null +++ b/src/features/portal/index.js @@ -0,0 +1,2 @@ +export * from './PortalPopup' +export * from './PortalTile' From f84c7135d7f21550d45d6214beb7caad88fb06d2 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:22:05 -0500 Subject: [PATCH 036/177] refactor: route feature --- src/components/tiles/index.js | 4 ++-- .../Route.jsx => features/route/RoutePopup.jsx} | 8 ++++---- .../tiles/Route.jsx => features/route/RouteTile.jsx} | 12 +++++------- src/features/route/index.js | 3 +++ .../route.js => features/route/routeMarker.js} | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) rename src/{components/popups/Route.jsx => features/route/RoutePopup.jsx} (97%) rename src/{components/tiles/Route.jsx => features/route/RouteTile.jsx} (94%) create mode 100644 src/features/route/index.js rename src/{components/markers/route.js => features/route/routeMarker.js} (88%) diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index 39eae4df1..46538d8d1 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -3,14 +3,14 @@ import { PokestopTile as pokestops } from '@features/pokestop/PokestopTile' import { GymTile as gyms } from '@features/gym/GymTile' import { DeviceTile as devices } from '@features/device/DeviceTile' import { NestTile as nests } from '@features/nest/NestTile' -import { PortalTile as portals } from '../../features/portal/PortalTile' +import { PortalTile as portals } from '@features/portal/PortalTile' +import { RouteTile as routes } from '@features/route/RouteTile' import scanCells from './ScanCell' import scanAreas from './ScanArea' import spawnpoints from './Spawnpoint' import submissionCells from './submissionCells/SubmissionCell' import weather from './Weather' import s2cells from './S2Cell' -import routes from './Route' export { devices, diff --git a/src/components/popups/Route.jsx b/src/features/route/RoutePopup.jsx similarity index 97% rename from src/components/popups/Route.jsx rename to src/features/route/RoutePopup.jsx index 0b7c229ec..9222c4d10 100644 --- a/src/components/popups/Route.jsx +++ b/src/features/route/RoutePopup.jsx @@ -27,9 +27,9 @@ import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { useFormatDistance } from '@hooks/useFormatDistance' -import Title from './common/Title' -import TimeSince from './common/Timer' -import Navigation from './common/Navigation' +import Title from '../../components/popups/common/Title' +import TimeSince from '../../components/popups/common/Timer' +import Navigation from '../../components/popups/common/Navigation' const IMAGE_SIZE = 80 @@ -130,7 +130,7 @@ function ExpandableWrapper({ disabled = false, children, expandKey, primary }) { * @param {import("@rm/types").Route & { end?: boolean }} props * @returns */ -export default function RoutePopup({ end, ...props }) { +export function RoutePopup({ end, ...props }) { const [route, setRoute] = React.useState({ ...props, tags: [] }) const { config } = useMemory.getState() const formatDistance = useFormatDistance() diff --git a/src/components/tiles/Route.jsx b/src/features/route/RouteTile.jsx similarity index 94% rename from src/components/tiles/Route.jsx rename to src/features/route/RouteTile.jsx index f26cb9043..12dacf0d1 100644 --- a/src/components/tiles/Route.jsx +++ b/src/features/route/RouteTile.jsx @@ -5,10 +5,10 @@ import * as React from 'react' import { Marker, Polyline, useMapEvents } from 'react-leaflet' import { darken } from '@mui/material' -import RoutePopup from '@components/popups/Route' import useForcePopup from '@hooks/useForcePopup' -import routeMarker from '../markers/route' +import { routeMarker } from './routeMarker' +import { RoutePopup } from './RoutePopup' const POSITIONS = /** @type {const} */ (['start', 'end']) @@ -20,7 +20,7 @@ const MARKER_OPACITY = LINE_OPACITY * 2 * @param {import("@rm/types").Route} route * @returns */ -const RouteTile = (route) => { +const BaseRouteTile = (route) => { const [clicked, setClicked] = React.useState(false) const [hover, setHover] = React.useState('') @@ -131,9 +131,7 @@ const RouteTile = (route) => { ) } -const MemoRouteTile = React.memo( - RouteTile, +export const RouteTile = React.memo( + BaseRouteTile, (prev, next) => prev.updated === next.updated, ) - -export default MemoRouteTile diff --git a/src/features/route/index.js b/src/features/route/index.js new file mode 100644 index 000000000..4fdc571cb --- /dev/null +++ b/src/features/route/index.js @@ -0,0 +1,3 @@ +export * from './routeMarker' +export * from './RoutePopup' +export * from './RouteTile' diff --git a/src/components/markers/route.js b/src/features/route/routeMarker.js similarity index 88% rename from src/components/markers/route.js rename to src/features/route/routeMarker.js index 5199fb4a0..a03e5d610 100644 --- a/src/components/markers/route.js +++ b/src/features/route/routeMarker.js @@ -7,7 +7,7 @@ import { useMemory } from '@hooks/useMemory' * @param {'start' | 'end'} position * @returns */ -export default function getRouteMarker(position) { +export function routeMarker(position) { const iconUrl = useMemory.getState().Icons.getMisc(`route-${position}`) return new Icon({ iconUrl, From 765404a9fc342f879823c19462ad5056a7d84c6d Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:25:04 -0500 Subject: [PATCH 037/177] refactor: weather feature --- src/components/tiles/index.js | 2 +- .../weather/WeatherPopup.jsx} | 4 ++-- .../weather/WeatherTile.jsx} | 14 ++++++-------- src/features/weather/index.js | 3 +++ .../weather/weatherMarker.js} | 4 ++-- src/pages/map/components/ActiveWeather.jsx | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) rename src/{components/popups/Weather.jsx => features/weather/WeatherPopup.jsx} (96%) rename src/{components/tiles/Weather.jsx => features/weather/WeatherTile.jsx} (86%) create mode 100644 src/features/weather/index.js rename src/{components/markers/weather.js => features/weather/weatherMarker.js} (93%) diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index 46538d8d1..59aa66367 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -5,11 +5,11 @@ import { DeviceTile as devices } from '@features/device/DeviceTile' import { NestTile as nests } from '@features/nest/NestTile' import { PortalTile as portals } from '@features/portal/PortalTile' import { RouteTile as routes } from '@features/route/RouteTile' +import { WeatherTile as weather } from '@features/weather/WeatherTile' import scanCells from './ScanCell' import scanAreas from './ScanArea' import spawnpoints from './Spawnpoint' import submissionCells from './submissionCells/SubmissionCell' -import weather from './Weather' import s2cells from './S2Cell' export { diff --git a/src/components/popups/Weather.jsx b/src/features/weather/WeatherPopup.jsx similarity index 96% rename from src/components/popups/Weather.jsx rename to src/features/weather/WeatherPopup.jsx index 4139b8b2a..4b5196479 100644 --- a/src/components/popups/Weather.jsx +++ b/src/features/weather/WeatherPopup.jsx @@ -12,7 +12,7 @@ import ErrorBoundary from '@components/ErrorBoundary' * @param {import('@rm/types').Weather} props * @returns */ -export default function WeatherPopup({ gameplay_condition, updated }) { +export function WeatherPopup({ gameplay_condition, updated }) { const { t } = useTranslation() const weatherTypes = useMemory( (state) => state.masterfile.weather[gameplay_condition]?.types || [], @@ -57,7 +57,7 @@ export default function WeatherPopup({ gameplay_condition, updated }) { {t(`poke_type_${type}`)} {type} { +const BaseWeatherTile = (weather) => { const [popup, setPopup] = React.useState(false) const markerRef = React.useRef(null) @@ -60,18 +60,16 @@ const WeatherTile = (weather) => { eventHandlers={eventHandlers} > - + ) } -const MemoWeatherTile = React.memo( - WeatherTile, +export const WeatherTile = React.memo( + BaseWeatherTile, (prev, next) => prev.gameplay_condition === next.gameplay_condition && prev.updated === next.updated, ) - -export default MemoWeatherTile diff --git a/src/features/weather/index.js b/src/features/weather/index.js new file mode 100644 index 000000000..e7c7c1b3f --- /dev/null +++ b/src/features/weather/index.js @@ -0,0 +1,3 @@ +export * from './WeatherPopup' +export * from './WeatherTile' +export * from './weatherMarker' diff --git a/src/components/markers/weather.js b/src/features/weather/weatherMarker.js similarity index 93% rename from src/components/markers/weather.js rename to src/features/weather/weatherMarker.js index e96f9d9b5..6603e7df0 100644 --- a/src/components/markers/weather.js +++ b/src/features/weather/weatherMarker.js @@ -1,7 +1,7 @@ -import { useMemory } from '@hooks/useMemory' import { divIcon } from 'leaflet' +import { useMemory } from '@hooks/useMemory' -export default function weatherMarker(iconUrl) { +export function weatherMarker(iconUrl) { const [ { offsetX, diff --git a/src/pages/map/components/ActiveWeather.jsx b/src/pages/map/components/ActiveWeather.jsx index 1b8a3e7a6..c25ee5446 100644 --- a/src/pages/map/components/ActiveWeather.jsx +++ b/src/pages/map/components/ActiveWeather.jsx @@ -8,7 +8,7 @@ import booleanPointInPolygon from '@turf/boolean-point-in-polygon' import { point, polygon } from '@turf/helpers' import { useTranslation } from 'react-i18next' -import WeatherPopup from '@components/popups/Weather' +import WeatherPopup from '@features/weather/WeatherPopup' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { apolloClient } from '@services/apollo' From 80a840c42e2d2e6cbdec8be8d40b6e5a041e842b Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:28:37 -0500 Subject: [PATCH 038/177] refactor: scanCell feature --- src/components/tiles/index.js | 2 +- .../scanCell/ScanCellPopup.jsx} | 4 +--- .../scanCell/ScanCellTile.jsx} | 19 +++++++------------ src/features/scanCell/index.js | 3 +++ .../scanCell/scanCellMarker.js} | 8 +++++++- 5 files changed, 19 insertions(+), 17 deletions(-) rename src/{components/popups/ScanCell.jsx => features/scanCell/ScanCellPopup.jsx} (94%) rename src/{components/tiles/ScanCell.jsx => features/scanCell/ScanCellTile.jsx} (50%) create mode 100644 src/features/scanCell/index.js rename src/{components/markers/scanCell.js => features/scanCell/scanCellMarker.js} (70%) diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index 59aa66367..92e7b1559 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -6,7 +6,7 @@ import { NestTile as nests } from '@features/nest/NestTile' import { PortalTile as portals } from '@features/portal/PortalTile' import { RouteTile as routes } from '@features/route/RouteTile' import { WeatherTile as weather } from '@features/weather/WeatherTile' -import scanCells from './ScanCell' +import { ScanCellTile as scanCells } from '../../features/scanCell/ScanCellTile' import scanAreas from './ScanArea' import spawnpoints from './Spawnpoint' import submissionCells from './submissionCells/SubmissionCell' diff --git a/src/components/popups/ScanCell.jsx b/src/features/scanCell/ScanCellPopup.jsx similarity index 94% rename from src/components/popups/ScanCell.jsx rename to src/features/scanCell/ScanCellPopup.jsx index 242913d81..29412c232 100644 --- a/src/components/popups/ScanCell.jsx +++ b/src/features/scanCell/ScanCellPopup.jsx @@ -11,7 +11,7 @@ import ErrorBoundary from '@components/ErrorBoundary' * @param {import('@rm/types').ScanCell} props * @returns */ -function ScanCellPopup({ id, updated }) { +export function ScanCellPopup({ id, updated }) { const { t } = useTranslation() const lastUpdated = new Date(updated * 1000) const [timer, setTimer] = React.useState(Utility.getTimeUntil(lastUpdated)) @@ -43,5 +43,3 @@ function ScanCellPopup({ id, updated }) { ) } - -export default ScanCellPopup diff --git a/src/components/tiles/ScanCell.jsx b/src/features/scanCell/ScanCellTile.jsx similarity index 50% rename from src/components/tiles/ScanCell.jsx rename to src/features/scanCell/ScanCellTile.jsx index 67f8e0cd5..dd9a4dc1e 100644 --- a/src/components/tiles/ScanCell.jsx +++ b/src/features/scanCell/ScanCellTile.jsx @@ -3,28 +3,23 @@ import * as React from 'react' import { Polygon, Popup } from 'react-leaflet' -import PopupContent from '../popups/ScanCell' -import marker from '../markers/scanCell' +import { ScanCellPopup } from './ScanCellPopup' +import { scanCellMarker } from './scanCellMarker' /** * * @param {import('@rm/types').ScanCell} scanCell * @returns */ -const ScanCellTile = (scanCell) => ( - +const BaseScanCellTile = (scanCell) => ( + - + ) -const ScanCellMemo = React.memo( - ScanCellTile, +export const ScanCellTile = React.memo( + BaseScanCellTile, (prev, next) => prev.updated === next.updated, ) - -export default ScanCellMemo diff --git a/src/features/scanCell/index.js b/src/features/scanCell/index.js new file mode 100644 index 000000000..309e8a3e9 --- /dev/null +++ b/src/features/scanCell/index.js @@ -0,0 +1,3 @@ +export * from './ScanCellTile' +export * from './ScanCellPopup' +export * from './scanCellMarker' diff --git a/src/components/markers/scanCell.js b/src/features/scanCell/scanCellMarker.js similarity index 70% rename from src/components/markers/scanCell.js rename to src/features/scanCell/scanCellMarker.js index 97456d0d7..7ad7abbcb 100644 --- a/src/components/markers/scanCell.js +++ b/src/features/scanCell/scanCellMarker.js @@ -1,4 +1,10 @@ -export default function scanCellMarker(ago) { +// @ts-check + +/** + * @param {number} ago + * @returns {L.PathOptions} + */ +export function scanCellMarker(ago) { const value = ago <= 1050 ? 0 : Math.min((ago - 1050) / 750, 1) const hue = ((1 - value) * 120).toString(10) From 3bb93b36ae6c45ecdade6f34fa68a8c355fe2916 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:31:51 -0500 Subject: [PATCH 039/177] refactor: spawnpoint feature --- src/components/tiles/index.js | 4 ++-- .../spawnpoint/SpawnpointPopup.jsx} | 4 +--- .../spawnpoint/SpawnpointTile.jsx} | 17 ++++++++--------- src/features/spawnpoint/index.js | 3 +++ .../spawnpoint/spawnpointMarker.js} | 10 +++++++++- 5 files changed, 23 insertions(+), 15 deletions(-) rename src/{components/popups/Spawnpoint.jsx => features/spawnpoint/SpawnpointPopup.jsx} (92%) rename src/{components/tiles/Spawnpoint.jsx => features/spawnpoint/SpawnpointTile.jsx} (77%) create mode 100644 src/features/spawnpoint/index.js rename src/{components/markers/spawnpoints.js => features/spawnpoint/spawnpointMarker.js} (53%) diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index 92e7b1559..b04d7dde8 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -6,9 +6,9 @@ import { NestTile as nests } from '@features/nest/NestTile' import { PortalTile as portals } from '@features/portal/PortalTile' import { RouteTile as routes } from '@features/route/RouteTile' import { WeatherTile as weather } from '@features/weather/WeatherTile' -import { ScanCellTile as scanCells } from '../../features/scanCell/ScanCellTile' +import { SpawnpointTile as spawnpoints } from '@features/spawnpoint/SpawnpointTile' +import { ScanCellTile as scanCells } from '@features/scanCell/ScanCellTile' import scanAreas from './ScanArea' -import spawnpoints from './Spawnpoint' import submissionCells from './submissionCells/SubmissionCell' import s2cells from './S2Cell' diff --git a/src/components/popups/Spawnpoint.jsx b/src/features/spawnpoint/SpawnpointPopup.jsx similarity index 92% rename from src/components/popups/Spawnpoint.jsx rename to src/features/spawnpoint/SpawnpointPopup.jsx index 865824dc7..63b101f9d 100644 --- a/src/components/popups/Spawnpoint.jsx +++ b/src/features/spawnpoint/SpawnpointPopup.jsx @@ -11,7 +11,7 @@ import ErrorBoundary from '@components/ErrorBoundary' * @param {import('@rm/types').Spawnpoint} props * @returns */ -function SpawnpointPopup({ despawn_sec, lat, lon, updated }) { +export function SpawnpointPopup({ despawn_sec, lat, lon, updated }) { const { t } = useTranslation() const minute = despawn_sec > 60 ? Math.round(despawn_sec / 60) : despawn_sec @@ -42,5 +42,3 @@ function SpawnpointPopup({ despawn_sec, lat, lon, updated }) { ) } - -export default SpawnpointPopup diff --git a/src/components/tiles/Spawnpoint.jsx b/src/features/spawnpoint/SpawnpointTile.jsx similarity index 77% rename from src/components/tiles/Spawnpoint.jsx rename to src/features/spawnpoint/SpawnpointTile.jsx index 8067d29a4..a1976c06d 100644 --- a/src/components/tiles/Spawnpoint.jsx +++ b/src/features/spawnpoint/SpawnpointTile.jsx @@ -1,18 +1,19 @@ // @ts-check /* eslint-disable react/destructuring-assignment */ import * as React from 'react' -import spawnpointMarker from '@components/markers/spawnpoints' import { Marker, Circle, Popup } from 'react-leaflet' import { useMemory } from '@hooks/useMemory' -import PopupContent from '../popups/Spawnpoint' + +import { SpawnpointPopup } from './SpawnpointPopup' +import { spawnpointMarker } from './spawnpointMarker' /** * * @param {import('@rm/types').Spawnpoint} item * @returns */ -const SpawnpointTile = (item) => { +const BaseSpawnpointTile = (item) => { const Icons = useMemory((state) => state.Icons) const [modifiers] = Icons.getModifiers('spawnpoint') const size = Icons.getSize('spawnpoint') * modifiers.sizeMultiplier @@ -27,7 +28,7 @@ const SpawnpointTile = (item) => { )} > - + ) : ( @@ -37,15 +38,13 @@ const SpawnpointTile = (item) => { color={item.despawn_sec ? 'green' : 'red'} > - + ) } -const MemoSpawnpoint = React.memo( - SpawnpointTile, +export const SpawnpointTile = React.memo( + BaseSpawnpointTile, (prev, next) => prev.despawn_sec === next.despawn_sec && prev.updated === next.updated, ) - -export default MemoSpawnpoint diff --git a/src/features/spawnpoint/index.js b/src/features/spawnpoint/index.js new file mode 100644 index 000000000..99cfa9933 --- /dev/null +++ b/src/features/spawnpoint/index.js @@ -0,0 +1,3 @@ +export * from './spawnpointMarker' +export * from './SpawnpointPopup' +export * from './SpawnpointTile' diff --git a/src/components/markers/spawnpoints.js b/src/features/spawnpoint/spawnpointMarker.js similarity index 53% rename from src/components/markers/spawnpoints.js rename to src/features/spawnpoint/spawnpointMarker.js index 951a333ce..b7249ed33 100644 --- a/src/components/markers/spawnpoints.js +++ b/src/features/spawnpoint/spawnpointMarker.js @@ -1,6 +1,14 @@ +// @ts-check import { Icon } from 'leaflet' -export default function spawnpointMarker(iconUrl, size, modifiers) { +/** + * + * @param {string} iconUrl + * @param {number} size + * @param {{ offsetX: number, offsetY: number, popupX: number, popupY: number }} modifiers + * @returns + */ +export function spawnpointMarker(iconUrl, size, modifiers) { return new Icon({ iconUrl, iconSize: [size, size], From c6a69a979b58148b562701381643c1c88e4ef04a Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:36:24 -0500 Subject: [PATCH 040/177] refactor: wayfarer feature --- src/components/tiles/index.js | 2 +- .../wayfarer}/PoI.jsx | 9 +++++---- .../wayfarer}/S14Cell.jsx | 10 ++++------ .../wayfarer}/S17Cell.jsx | 4 +--- .../wayfarer/WayfarerPopup.jsx} | 6 +----- .../wayfarer/WayfarerTile.jsx} | 16 +++++++--------- src/features/wayfarer/index.js | 1 + 7 files changed, 20 insertions(+), 28 deletions(-) rename src/{components/tiles/submissionCells => features/wayfarer}/PoI.jsx (67%) rename src/{components/tiles/submissionCells => features/wayfarer}/S14Cell.jsx (84%) rename src/{components/tiles/submissionCells => features/wayfarer}/S17Cell.jsx (91%) rename src/{components/popups/SubmissionCell.jsx => features/wayfarer/WayfarerPopup.jsx} (93%) rename src/{components/tiles/submissionCells/SubmissionCell.jsx => features/wayfarer/WayfarerTile.jsx} (85%) create mode 100644 src/features/wayfarer/index.js diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index b04d7dde8..ad5b0bbbe 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -8,8 +8,8 @@ import { RouteTile as routes } from '@features/route/RouteTile' import { WeatherTile as weather } from '@features/weather/WeatherTile' import { SpawnpointTile as spawnpoints } from '@features/spawnpoint/SpawnpointTile' import { ScanCellTile as scanCells } from '@features/scanCell/ScanCellTile' +import { WayfarerTile as submissionCells } from '@features/wayfarer/WayfarerTile' import scanAreas from './ScanArea' -import submissionCells from './submissionCells/SubmissionCell' import s2cells from './S2Cell' export { diff --git a/src/components/tiles/submissionCells/PoI.jsx b/src/features/wayfarer/PoI.jsx similarity index 67% rename from src/components/tiles/submissionCells/PoI.jsx rename to src/features/wayfarer/PoI.jsx index 1e5cc812e..b0a8c2f20 100644 --- a/src/components/tiles/submissionCells/PoI.jsx +++ b/src/features/wayfarer/PoI.jsx @@ -7,7 +7,7 @@ import { Circle } from 'react-leaflet' * @param {import('@rm/types').PoI & { color: string }} param0 * @returns */ -const PoITile = ({ lat, lon, color }) => ( +const PoI = ({ lat, lon, color }) => ( ( /> ) -const MemoPoI = React.memo(PoITile, (prev, next) => prev.color === next.color) - -export default MemoPoI +export const PoITile = React.memo( + PoI, + (prev, next) => prev.color === next.color, +) diff --git a/src/components/tiles/submissionCells/S14Cell.jsx b/src/features/wayfarer/S14Cell.jsx similarity index 84% rename from src/components/tiles/submissionCells/S14Cell.jsx rename to src/features/wayfarer/S14Cell.jsx index d1daf638b..21fe35030 100644 --- a/src/components/tiles/submissionCells/S14Cell.jsx +++ b/src/features/wayfarer/S14Cell.jsx @@ -2,8 +2,8 @@ import * as React from 'react' import { Polygon, Popup, Tooltip } from 'react-leaflet' -import PopupContent from '../../popups/SubmissionCell' -import typeStyle from '../../markers/typeCell' +import { WayfarerPopup } from './WayfarerPopup' +import typeStyle from '../../components/markers/typeCell' /** * @@ -27,7 +27,7 @@ const S14Cell = ({ {...typeStyle(cell, total, oneStopTillNext, twoStopsTillNext, noMoreGyms)} > - + {total || '0'} @@ -36,7 +36,7 @@ const S14Cell = ({ ) } -const MemoS14Cell = React.memo( +export const S14CellTile = React.memo( S14Cell, (prev, next) => prev.cellColor === next.cellColor && @@ -46,5 +46,3 @@ const MemoS14Cell = React.memo( prev.count_gyms === next.count_gyms && prev.count_pokestops === next.count_pokestops, ) - -export default MemoS14Cell diff --git a/src/components/tiles/submissionCells/S17Cell.jsx b/src/features/wayfarer/S17Cell.jsx similarity index 91% rename from src/components/tiles/submissionCells/S17Cell.jsx rename to src/features/wayfarer/S17Cell.jsx index 4dad46be7..796e12aa8 100644 --- a/src/components/tiles/submissionCells/S17Cell.jsx +++ b/src/features/wayfarer/S17Cell.jsx @@ -22,12 +22,10 @@ const S17Cell = ({ cellColor, blockedColor, polygon, blocked }) => ( /> ) -const MemoS17Cell = React.memo( +export const S17CellTile = React.memo( S17Cell, (prev, next) => prev.blocked === next.blocked && prev.blockedColor === next.blockedColor && prev.cellColor === next.cellColor, ) - -export default MemoS17Cell diff --git a/src/components/popups/SubmissionCell.jsx b/src/features/wayfarer/WayfarerPopup.jsx similarity index 93% rename from src/components/popups/SubmissionCell.jsx rename to src/features/wayfarer/WayfarerPopup.jsx index afbbb94f4..a008d516f 100644 --- a/src/components/popups/SubmissionCell.jsx +++ b/src/features/wayfarer/WayfarerPopup.jsx @@ -13,11 +13,7 @@ const GYM_THRESHOLD = [2, 6, 20] * @param {import('@rm/types/lib').Level14Cell & { total: number }} props * @returns */ -export default function SubmissionCellPopup({ - count_gyms, - count_pokestops, - total, -}) { +export function WayfarerPopup({ count_gyms, count_pokestops, total }) { const { t } = useTranslation() let untilNextGym = count_gyms < 3 diff --git a/src/components/tiles/submissionCells/SubmissionCell.jsx b/src/features/wayfarer/WayfarerTile.jsx similarity index 85% rename from src/components/tiles/submissionCells/SubmissionCell.jsx rename to src/features/wayfarer/WayfarerTile.jsx index df0438cf5..d8a0ab265 100644 --- a/src/components/tiles/submissionCells/SubmissionCell.jsx +++ b/src/features/wayfarer/WayfarerTile.jsx @@ -4,16 +4,16 @@ import * as React from 'react' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import Level14Tile from './S14Cell' -import Level17Tile from './S17Cell' -import PoITile from './PoI' +import { S14CellTile } from './S14Cell' +import { S17CellTile } from './S17Cell' +import { PoITile } from './PoI' /** * * @param {import('@rm/types').SubmissionCell} props * @returns */ -const SubmissionCellTile = ({ level14Cells, level17Cells, pois }) => { +const Wayfarer = ({ level14Cells, level17Cells, pois }) => { const poiColor = useStorage((s) => s.userSettings.wayfarer.poiColor) const showcaseColor = useStorage((s) => s.userSettings.wayfarer.showcaseColor) const partnerColor = useStorage((s) => s.userSettings.wayfarer.partnerColor) @@ -47,7 +47,7 @@ const SubmissionCellTile = ({ level14Cells, level17Cells, pois }) => { /> ))} {level17Cells?.map((cell) => ( - { /> ))} {level14Cells?.map((cell) => ( - { ) } -const MemoSubmissionCell = React.memo(SubmissionCellTile) - -export default MemoSubmissionCell +export const WayfarerTile = React.memo(Wayfarer) diff --git a/src/features/wayfarer/index.js b/src/features/wayfarer/index.js new file mode 100644 index 000000000..06155455a --- /dev/null +++ b/src/features/wayfarer/index.js @@ -0,0 +1 @@ +export * from './WayfarerTile' From 7e7170dacdff3f8aef35f1118fec79d133a20d9a Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:37:17 -0500 Subject: [PATCH 041/177] refactor: move typeCell.js --- src/features/wayfarer/S14Cell.jsx | 10 ++++++++-- .../markers => features/wayfarer}/typeCell.js | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) rename src/{components/markers => features/wayfarer}/typeCell.js (96%) diff --git a/src/features/wayfarer/S14Cell.jsx b/src/features/wayfarer/S14Cell.jsx index 21fe35030..da63aef47 100644 --- a/src/features/wayfarer/S14Cell.jsx +++ b/src/features/wayfarer/S14Cell.jsx @@ -3,7 +3,7 @@ import * as React from 'react' import { Polygon, Popup, Tooltip } from 'react-leaflet' import { WayfarerPopup } from './WayfarerPopup' -import typeStyle from '../../components/markers/typeCell' +import { getPathOptions } from './typeCell' /** * @@ -24,7 +24,13 @@ const S14Cell = ({ positions={cell.polygon} color={cellColor} weight={4} - {...typeStyle(cell, total, oneStopTillNext, twoStopsTillNext, noMoreGyms)} + {...getPathOptions( + cell, + total, + oneStopTillNext, + twoStopsTillNext, + noMoreGyms, + )} > diff --git a/src/components/markers/typeCell.js b/src/features/wayfarer/typeCell.js similarity index 96% rename from src/components/markers/typeCell.js rename to src/features/wayfarer/typeCell.js index 9faf19f19..d0bcbfce5 100644 --- a/src/components/markers/typeCell.js +++ b/src/features/wayfarer/typeCell.js @@ -9,7 +9,7 @@ * @param {string} noMoreGyms * @returns {L.PathOptions} */ -export default function typeStyle( +export function getPathOptions( cell, total, oneStopTillNext, From 12c73cd478c916bc1c67742b559ba1c6f9a4f186 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:39:56 -0500 Subject: [PATCH 042/177] refactor: scanArea feature --- src/components/tiles/index.js | 2 +- .../ScanArea.jsx => features/scanArea/ScanAreaTile.jsx} | 6 ++---- src/features/scanArea/index.js | 1 + src/features/webhooks/human/area/AreaSelection.jsx | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) rename src/{components/tiles/ScanArea.jsx => features/scanArea/ScanAreaTile.jsx} (96%) create mode 100644 src/features/scanArea/index.js diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index ad5b0bbbe..d3f77600b 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -9,7 +9,7 @@ import { WeatherTile as weather } from '@features/weather/WeatherTile' import { SpawnpointTile as spawnpoints } from '@features/spawnpoint/SpawnpointTile' import { ScanCellTile as scanCells } from '@features/scanCell/ScanCellTile' import { WayfarerTile as submissionCells } from '@features/wayfarer/WayfarerTile' -import scanAreas from './ScanArea' +import { ScanAreaTile as scanAreas } from '../../features/scanArea/ScanAreaTile' import s2cells from './S2Cell' export { diff --git a/src/components/tiles/ScanArea.jsx b/src/features/scanArea/ScanAreaTile.jsx similarity index 96% rename from src/components/tiles/ScanArea.jsx rename to src/features/scanArea/ScanAreaTile.jsx index 19e480810..fca20cb47 100644 --- a/src/components/tiles/ScanArea.jsx +++ b/src/features/scanArea/ScanAreaTile.jsx @@ -14,7 +14,7 @@ import { Polygon } from 'leaflet' * @param {import('@rm/types').RMGeoJSON} featureCollection * @returns */ -export function ScanAreaTile(featureCollection) { +function ScanArea(featureCollection) { const search = useStorage((s) => s.filters.scanAreas?.filter?.search) const tapToToggle = useStorage((s) => s.userSettings.scanAreas.tapToToggle) const alwaysShowLabels = useStorage( @@ -106,10 +106,8 @@ export function ScanAreaTile(featureCollection) { ) } -const MemoScanAreaTile = React.memo(ScanAreaTile, (prev, next) => +export const ScanAreaTile = React.memo(ScanArea, (prev, next) => prev.features.every( (feat, i) => feat.properties.key === next.features[i].properties.key, ), ) - -export default MemoScanAreaTile diff --git a/src/features/scanArea/index.js b/src/features/scanArea/index.js new file mode 100644 index 000000000..f6843c23c --- /dev/null +++ b/src/features/scanArea/index.js @@ -0,0 +1 @@ +export * from './ScanAreaTile' diff --git a/src/features/webhooks/human/area/AreaSelection.jsx b/src/features/webhooks/human/area/AreaSelection.jsx index 818c14877..a9cd8bffc 100644 --- a/src/features/webhooks/human/area/AreaSelection.jsx +++ b/src/features/webhooks/human/area/AreaSelection.jsx @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next' import { WEBHOOK_GEOJSON } from '@services/queries/webhook' import { Loading } from '@components/Loading' -import MemoScanArea from '@components/tiles/ScanArea' +import MemoScanArea from '@features/scanArea/ScanAreaTile' import { useWebhookStore } from '../../store' From 42b3917ac9972d2c5a7658fa24e1585ec07dcc81 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:43:40 -0500 Subject: [PATCH 043/177] refactor: s2cell feature --- src/components/tiles/index.js | 24 ++++++++--------- src/features/s2cell/BaseCell.jsx | 24 +++++++++++++++++ .../s2cell/GenerateCells.jsx} | 27 ++----------------- src/features/s2cell/index.js | 2 ++ src/pages/map/components/QueryData.jsx | 2 +- 5 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 src/features/s2cell/BaseCell.jsx rename src/{components/tiles/S2Cell.jsx => features/s2cell/GenerateCells.jsx} (81%) create mode 100644 src/features/s2cell/index.js diff --git a/src/components/tiles/index.js b/src/components/tiles/index.js index d3f77600b..f38c47e73 100644 --- a/src/components/tiles/index.js +++ b/src/components/tiles/index.js @@ -1,16 +1,16 @@ import { PokemonTile as pokemon } from '@features/pokemon' -import { PokestopTile as pokestops } from '@features/pokestop/PokestopTile' -import { GymTile as gyms } from '@features/gym/GymTile' -import { DeviceTile as devices } from '@features/device/DeviceTile' -import { NestTile as nests } from '@features/nest/NestTile' -import { PortalTile as portals } from '@features/portal/PortalTile' -import { RouteTile as routes } from '@features/route/RouteTile' -import { WeatherTile as weather } from '@features/weather/WeatherTile' -import { SpawnpointTile as spawnpoints } from '@features/spawnpoint/SpawnpointTile' -import { ScanCellTile as scanCells } from '@features/scanCell/ScanCellTile' -import { WayfarerTile as submissionCells } from '@features/wayfarer/WayfarerTile' -import { ScanAreaTile as scanAreas } from '../../features/scanArea/ScanAreaTile' -import s2cells from './S2Cell' +import { PokestopTile as pokestops } from '@features/pokestop' +import { GymTile as gyms } from '@features/gym' +import { DeviceTile as devices } from '@features/device' +import { NestTile as nests } from '@features/nest' +import { PortalTile as portals } from '@features/portal' +import { RouteTile as routes } from '@features/route' +import { WeatherTile as weather } from '@features/weather' +import { SpawnpointTile as spawnpoints } from '@features/spawnpoint' +import { ScanCellTile as scanCells } from '@features/scanCell' +import { WayfarerTile as submissionCells } from '@features/wayfarer' +import { ScanAreaTile as scanAreas } from '@features/scanArea' +import { BaseCell as s2cells } from '@features/s2cell' export { devices, diff --git a/src/features/s2cell/BaseCell.jsx b/src/features/s2cell/BaseCell.jsx new file mode 100644 index 000000000..3cb0cee54 --- /dev/null +++ b/src/features/s2cell/BaseCell.jsx @@ -0,0 +1,24 @@ +// @ts-check +import * as React from 'react' +import { Polyline } from 'react-leaflet' + +/** + * + * @param {{ coords: import('@rm/types').S2Polygon, color: string }} props + * @returns + */ +function Cell({ coords, color }) { + return ( + + ) +} + +export const BaseCell = React.memo( + Cell, + (prev, next) => prev.color === next.color, +) diff --git a/src/components/tiles/S2Cell.jsx b/src/features/s2cell/GenerateCells.jsx similarity index 81% rename from src/components/tiles/S2Cell.jsx rename to src/features/s2cell/GenerateCells.jsx index 6df6bb599..eb75f50ca 100644 --- a/src/components/tiles/S2Cell.jsx +++ b/src/features/s2cell/GenerateCells.jsx @@ -1,6 +1,5 @@ // @ts-check import * as React from 'react' -import { Polyline } from 'react-leaflet' import { S2LatLng, S2RegionCoverer, @@ -14,29 +13,7 @@ import { useStorage } from '@hooks/useStorage' import Notification from '@components/Notification' import { getQueryArgs } from '@utils/getQueryArgs' - -/** - * - * @param {{ coords: import('@rm/types').S2Polygon, color: string }} props - * @returns - */ -function BaseCell({ coords, color }) { - return ( - - ) -} - -const MemoBaseCell = React.memo( - BaseCell, - (prev, next) => prev.color === next.color, -) - -export default MemoBaseCell +import { BaseCell } from './BaseCell' export function GenerateCells() { const darkTiles = useMemory((s) => s.tileStyle === 'dark') @@ -83,7 +60,7 @@ export function GenerateCells() { {cells .filter((_, i) => i < 20_000) .map((cell) => ( - + ))} 20_000} diff --git a/src/features/s2cell/index.js b/src/features/s2cell/index.js new file mode 100644 index 000000000..1eb0283ce --- /dev/null +++ b/src/features/s2cell/index.js @@ -0,0 +1,2 @@ +export * from './GenerateCells' +export * from './BaseCell' diff --git a/src/pages/map/components/QueryData.jsx b/src/pages/map/components/QueryData.jsx index 966b40936..deaab4a3a 100644 --- a/src/pages/map/components/QueryData.jsx +++ b/src/pages/map/components/QueryData.jsx @@ -13,7 +13,7 @@ import Utility from '@services/Utility' import { FILTER_SKIP_LIST } from '@assets/constants' import * as index from '@components/tiles/index' import Notification from '@components/Notification' -import { GenerateCells } from '@components/tiles/S2Cell' +import { GenerateCells } from '@features/s2cell/GenerateCells' import Clustering from './Clustering' From ac4f2385284b50ab91626a1bec6c0e54c030278c Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:46:16 -0500 Subject: [PATCH 044/177] refactor: move remaining tile components --- src/components/{tiles/Timer.jsx => ToolTipWrapper.jsx} | 0 src/features/gym/GymTile.jsx | 2 +- src/features/pokemon/PokemonTile.jsx | 2 +- src/features/pokestop/PokestopTile.jsx | 2 +- src/pages/map/components/QueryData.jsx | 4 ++-- src/{components/tiles/index.js => pages/map/tileObject.js} | 4 +++- 6 files changed, 8 insertions(+), 6 deletions(-) rename src/components/{tiles/Timer.jsx => ToolTipWrapper.jsx} (100%) rename src/{components/tiles/index.js => pages/map/tileObject.js} (95%) diff --git a/src/components/tiles/Timer.jsx b/src/components/ToolTipWrapper.jsx similarity index 100% rename from src/components/tiles/Timer.jsx rename to src/components/ToolTipWrapper.jsx diff --git a/src/features/gym/GymTile.jsx b/src/features/gym/GymTile.jsx index ca2f44469..7e77203c5 100644 --- a/src/features/gym/GymTile.jsx +++ b/src/features/gym/GymTile.jsx @@ -11,10 +11,10 @@ import useOpacity from '@hooks/useOpacity' import useForcePopup from '@hooks/useForcePopup' import { sendNotification } from '@services/desktopNotification' import Utility from '@services/Utility' +import ToolTipWrapper from '@components/ToolTipWrapper' import { gymMarker } from './gymMarker' import { GymPopup } from './GymPopup' -import ToolTipWrapper from '../../components/tiles/Timer' /** @param {number} team */ const getColor = (team) => { diff --git a/src/features/pokemon/PokemonTile.jsx b/src/features/pokemon/PokemonTile.jsx index 0c19c2d08..08af6dd9e 100644 --- a/src/features/pokemon/PokemonTile.jsx +++ b/src/features/pokemon/PokemonTile.jsx @@ -14,7 +14,7 @@ import useForcePopup from '@hooks/useForcePopup' import Utility from '@services/Utility' import { sendNotification } from '@services/desktopNotification' import { useMapStore } from '@hooks/useMapStore' -import ToolTipWrapper from '@components/tiles/Timer' +import ToolTipWrapper from '@components/ToolTipWrapper' import PopupContent from './PokemonPopup' import { basicPokemonMarker, fancyPokemonMarker } from './pokemonMarker' diff --git a/src/features/pokestop/PokestopTile.jsx b/src/features/pokestop/PokestopTile.jsx index ea29f7dea..76c5660d7 100644 --- a/src/features/pokestop/PokestopTile.jsx +++ b/src/features/pokestop/PokestopTile.jsx @@ -7,7 +7,7 @@ import useMarkerTimer from '@hooks/useMarkerTimer' import { basicEqualFn, useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import useForcePopup from '@hooks/useForcePopup' -import ToolTipWrapper from '@components/tiles/Timer' +import ToolTipWrapper from '@components/ToolTipWrapper' import { PokestopPopup } from './PokestopPopup' import { usePokestopMarker } from './usePokestopMarker' diff --git a/src/pages/map/components/QueryData.jsx b/src/pages/map/components/QueryData.jsx index deaab4a3a..2fe63c130 100644 --- a/src/pages/map/components/QueryData.jsx +++ b/src/pages/map/components/QueryData.jsx @@ -11,11 +11,11 @@ import { getQueryArgs } from '@utils/getQueryArgs' import RobustTimeout from '@services/apollo/RobustTimeout' import Utility from '@services/Utility' import { FILTER_SKIP_LIST } from '@assets/constants' -import * as index from '@components/tiles/index' import Notification from '@components/Notification' import { GenerateCells } from '@features/s2cell/GenerateCells' import Clustering from './Clustering' +import tileObject from '../tileObject' /** @param {string} category */ const userSettingsCategory = (category) => { @@ -97,7 +97,7 @@ function QueryWrapper({ category }) { } function QueryData({ category, timeout }) { - const Component = React.useMemo(() => index[category], []) + const Component = React.useMemo(() => tileObject[category], []) const map = useMap() diff --git a/src/components/tiles/index.js b/src/pages/map/tileObject.js similarity index 95% rename from src/components/tiles/index.js rename to src/pages/map/tileObject.js index f38c47e73..6b3e539b9 100644 --- a/src/components/tiles/index.js +++ b/src/pages/map/tileObject.js @@ -12,7 +12,7 @@ import { WayfarerTile as submissionCells } from '@features/wayfarer' import { ScanAreaTile as scanAreas } from '@features/scanArea' import { BaseCell as s2cells } from '@features/s2cell' -export { +const tileObject = { devices, gyms, nests, @@ -27,3 +27,5 @@ export { s2cells, routes, } + +export default tileObject From 8ca8fc56e75257426b9fad834c8cf0b60732dcbb Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:48:13 -0500 Subject: [PATCH 045/177] refactor: remove `popups/common` folder --- src/components/popups/{common => }/Coords.jsx | 0 .../popups/{common => }/Dropdown.jsx | 0 .../popups/{common => }/ExtraInfo.jsx | 0 .../popups/{common => }/GenderIcon.jsx | 0 .../popups/{common => }/HeaderImage.jsx | 0 src/components/popups/{common => }/NameTT.jsx | 0 .../popups/{common => }/Navigation.jsx | 0 .../popups/{common => }/PowerUp.jsx | 0 .../popups/{common => }/TimeStamps.jsx | 0 .../popups/{common => }/TimeTile.jsx | 0 src/components/popups/{common => }/Timer.jsx | 0 src/components/popups/{common => }/Title.jsx | 0 src/features/gym/GymPopup.jsx | 15 +++++++------ src/features/pokemon/PokemonPopup.jsx | 12 +++++------ src/features/pokestop/PokestopPopup.jsx | 21 +++++++++---------- src/features/portal/PortalPopup.jsx | 4 ++-- src/features/route/RoutePopup.jsx | 7 +++---- src/features/search/OptionImage.jsx | 2 +- src/features/search/renderOption.jsx | 2 +- 19 files changed, 30 insertions(+), 33 deletions(-) rename src/components/popups/{common => }/Coords.jsx (100%) rename src/components/popups/{common => }/Dropdown.jsx (100%) rename src/components/popups/{common => }/ExtraInfo.jsx (100%) rename src/components/popups/{common => }/GenderIcon.jsx (100%) rename src/components/popups/{common => }/HeaderImage.jsx (100%) rename src/components/popups/{common => }/NameTT.jsx (100%) rename src/components/popups/{common => }/Navigation.jsx (100%) rename src/components/popups/{common => }/PowerUp.jsx (100%) rename src/components/popups/{common => }/TimeStamps.jsx (100%) rename src/components/popups/{common => }/TimeTile.jsx (100%) rename src/components/popups/{common => }/Timer.jsx (100%) rename src/components/popups/{common => }/Title.jsx (100%) diff --git a/src/components/popups/common/Coords.jsx b/src/components/popups/Coords.jsx similarity index 100% rename from src/components/popups/common/Coords.jsx rename to src/components/popups/Coords.jsx diff --git a/src/components/popups/common/Dropdown.jsx b/src/components/popups/Dropdown.jsx similarity index 100% rename from src/components/popups/common/Dropdown.jsx rename to src/components/popups/Dropdown.jsx diff --git a/src/components/popups/common/ExtraInfo.jsx b/src/components/popups/ExtraInfo.jsx similarity index 100% rename from src/components/popups/common/ExtraInfo.jsx rename to src/components/popups/ExtraInfo.jsx diff --git a/src/components/popups/common/GenderIcon.jsx b/src/components/popups/GenderIcon.jsx similarity index 100% rename from src/components/popups/common/GenderIcon.jsx rename to src/components/popups/GenderIcon.jsx diff --git a/src/components/popups/common/HeaderImage.jsx b/src/components/popups/HeaderImage.jsx similarity index 100% rename from src/components/popups/common/HeaderImage.jsx rename to src/components/popups/HeaderImage.jsx diff --git a/src/components/popups/common/NameTT.jsx b/src/components/popups/NameTT.jsx similarity index 100% rename from src/components/popups/common/NameTT.jsx rename to src/components/popups/NameTT.jsx diff --git a/src/components/popups/common/Navigation.jsx b/src/components/popups/Navigation.jsx similarity index 100% rename from src/components/popups/common/Navigation.jsx rename to src/components/popups/Navigation.jsx diff --git a/src/components/popups/common/PowerUp.jsx b/src/components/popups/PowerUp.jsx similarity index 100% rename from src/components/popups/common/PowerUp.jsx rename to src/components/popups/PowerUp.jsx diff --git a/src/components/popups/common/TimeStamps.jsx b/src/components/popups/TimeStamps.jsx similarity index 100% rename from src/components/popups/common/TimeStamps.jsx rename to src/components/popups/TimeStamps.jsx diff --git a/src/components/popups/common/TimeTile.jsx b/src/components/popups/TimeTile.jsx similarity index 100% rename from src/components/popups/common/TimeTile.jsx rename to src/components/popups/TimeTile.jsx diff --git a/src/components/popups/common/Timer.jsx b/src/components/popups/Timer.jsx similarity index 100% rename from src/components/popups/common/Timer.jsx rename to src/components/popups/Timer.jsx diff --git a/src/components/popups/common/Title.jsx b/src/components/popups/Title.jsx similarity index 100% rename from src/components/popups/common/Title.jsx rename to src/components/popups/Title.jsx diff --git a/src/features/gym/GymPopup.jsx b/src/features/gym/GymPopup.jsx index 7eee136d2..db3dfed95 100644 --- a/src/features/gym/GymPopup.jsx +++ b/src/features/gym/GymPopup.jsx @@ -22,14 +22,13 @@ import useWebhook from '@hooks/useWebhook' import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' import { TextWithIcon } from '@components/Img' - -import Title from '../../components/popups/common/Title' -import PowerUp from '../../components/popups/common/PowerUp' -import GenderIcon from '../../components/popups/common/GenderIcon' -import Navigation from '../../components/popups/common/Navigation' -import Coords from '../../components/popups/common/Coords' -import { TimeStamp } from '../../components/popups/common/TimeStamps' -import { ExtraInfo } from '../../components/popups/common/ExtraInfo' +import Title from '@components/popups/Title' +import PowerUp from '@components/popups/PowerUp' +import GenderIcon from '@components/popups/GenderIcon' +import Navigation from '@components/popups/Navigation' +import Coords from '@components/popups/Coords' +import { TimeStamp } from '@components/popups/TimeStamps' +import { ExtraInfo } from '@components/popups/ExtraInfo' /** * diff --git a/src/features/pokemon/PokemonPopup.jsx b/src/features/pokemon/PokemonPopup.jsx index d4a655a1d..eed2ab8e1 100644 --- a/src/features/pokemon/PokemonPopup.jsx +++ b/src/features/pokemon/PokemonPopup.jsx @@ -24,12 +24,12 @@ import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' import { TextWithIcon } from '@components/Img' -import NameTT from '../../components/popups/common/NameTT' -import GenderIcon from '../../components/popups/common/GenderIcon' -import Navigation from '../../components/popups/common/Navigation' -import Coords from '../../components/popups/common/Coords' -import { TimeStamp } from '../../components/popups/common/TimeStamps' -import { ExtraInfo } from '../../components/popups/common/ExtraInfo' +import NameTT from '@components/popups/NameTT' +import GenderIcon from '@components/popups/GenderIcon' +import Navigation from '@components/popups/Navigation' +import Coords from '@components/popups/Coords' +import { TimeStamp } from '@components/popups/TimeStamps' +import { ExtraInfo } from '@components/popups/ExtraInfo' const rowClass = { width: 30, fontWeight: 'bold' } diff --git a/src/features/pokestop/PokestopPopup.jsx b/src/features/pokestop/PokestopPopup.jsx index 61de51f59..b2f0c1c10 100644 --- a/src/features/pokestop/PokestopPopup.jsx +++ b/src/features/pokestop/PokestopPopup.jsx @@ -25,17 +25,16 @@ import Utility from '@services/Utility' import { getBadge } from '@utils/getBadge' import getRewardInfo from '@utils/getRewardInfo' import { getGruntReward } from '@utils/getGruntReward' - -import Dropdown from '../../components/popups/common/Dropdown' -import TimeTile from '../../components/popups/common/TimeTile' -import Navigation from '../../components/popups/common/Navigation' -import Coords from '../../components/popups/common/Coords' -import Title from '../../components/popups/common/Title' -import HeaderImage from '../../components/popups/common/HeaderImage' -import Timer from '../../components/popups/common/Timer' -import PowerUp from '../../components/popups/common/PowerUp' -import NameTT from '../../components/popups/common/NameTT' -import { TimeStamp } from '../../components/popups/common/TimeStamps' +import Dropdown from '@components/popups/Dropdown' +import TimeTile from '@components/popups/TimeTile' +import Navigation from '@components/popups/Navigation' +import Coords from '@components/popups/Coords' +import Title from '@components/popups/Title' +import HeaderImage from '@components/popups/HeaderImage' +import Timer from '@components/popups/Timer' +import PowerUp from '@components/popups/PowerUp' +import NameTT from '@components/popups/NameTT' +import { TimeStamp } from '@components/popups/TimeStamps' /** * diff --git a/src/features/portal/PortalPopup.jsx b/src/features/portal/PortalPopup.jsx index b393929d4..d043157e4 100644 --- a/src/features/portal/PortalPopup.jsx +++ b/src/features/portal/PortalPopup.jsx @@ -9,8 +9,8 @@ import ErrorBoundary from '@components/ErrorBoundary' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' -import Navigation from '../../components/popups/common/Navigation' -import Coords from '../../components/popups/common/Coords' +import Navigation from '@components/popups/Navigation' +import Coords from '@components/popups/Coords' /** * diff --git a/src/features/route/RoutePopup.jsx b/src/features/route/RoutePopup.jsx index 9222c4d10..59f1bf942 100644 --- a/src/features/route/RoutePopup.jsx +++ b/src/features/route/RoutePopup.jsx @@ -26,10 +26,9 @@ import formatInterval from '@utils/formatInterval' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { useFormatDistance } from '@hooks/useFormatDistance' - -import Title from '../../components/popups/common/Title' -import TimeSince from '../../components/popups/common/Timer' -import Navigation from '../../components/popups/common/Navigation' +import Title from '@components/popups/Title' +import TimeSince from '@components/popups/Timer' +import Navigation from '@components/popups/Navigation' const IMAGE_SIZE = 80 diff --git a/src/features/search/OptionImage.jsx b/src/features/search/OptionImage.jsx index de880e4fd..0d6d5160c 100644 --- a/src/features/search/OptionImage.jsx +++ b/src/features/search/OptionImage.jsx @@ -3,7 +3,7 @@ import * as React from 'react' import Box from '@mui/material/Box' -import NameTT from '@components/popups/common/NameTT' +import NameTT from '@components/popups/NameTT' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import getRewardInfo from '@utils/getRewardInfo' diff --git a/src/features/search/renderOption.jsx b/src/features/search/renderOption.jsx index 7fd8df12d..65f1b242d 100644 --- a/src/features/search/renderOption.jsx +++ b/src/features/search/renderOption.jsx @@ -13,7 +13,7 @@ import { RawQuestTitle } from '@components/QuestTitle' import { Divider, Typography } from '@mui/material' import Utility from '@services/Utility' -import { RawTimeSince } from '@components/popups/common/Timer' +import { RawTimeSince } from '@components/popups/Timer' import { getGruntReward } from '@utils/getGruntReward' import { formatDistance } from '@utils/formatDistance' From 16e20db06c8b721f15dd879d4d64bb90878645d9 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:49:12 -0500 Subject: [PATCH 046/177] refactor: move fallback.js --- .../markers/fallback.js => assets/fallbackMarker.js} | 0 src/features/scanner/Marker.jsx | 2 +- src/features/webhooks/human/Draggable.jsx | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/{components/markers/fallback.js => assets/fallbackMarker.js} (100%) diff --git a/src/components/markers/fallback.js b/src/assets/fallbackMarker.js similarity index 100% rename from src/components/markers/fallback.js rename to src/assets/fallbackMarker.js diff --git a/src/features/scanner/Marker.jsx b/src/features/scanner/Marker.jsx index c2d231acd..31a460a71 100644 --- a/src/features/scanner/Marker.jsx +++ b/src/features/scanner/Marker.jsx @@ -2,7 +2,7 @@ import * as React from 'react' import { Marker, useMap } from 'react-leaflet' -import fallbackIcon from '@components/markers/fallback' +import fallbackIcon from '@assets/fallbackMarker' import { useScanStore } from './store' /** diff --git a/src/features/webhooks/human/Draggable.jsx b/src/features/webhooks/human/Draggable.jsx index b9e706113..2426918c5 100644 --- a/src/features/webhooks/human/Draggable.jsx +++ b/src/features/webhooks/human/Draggable.jsx @@ -10,7 +10,7 @@ import { } from '@mui/material' import { Circle, Marker, Popup, useMap } from 'react-leaflet' import { useTranslation } from 'react-i18next' -import fallbackIcon from '@components/markers/fallback' +import fallbackIcon from '@assets/fallbackMarker' import { useWebhookStore } from '../store' export default function DraggableMarker() { From 8768548ce294a539ea16e43ad7aecda0defdf164 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:50:59 -0500 Subject: [PATCH 047/177] refactor: remove unused --- src/components/dialogs/filters/MenuTile.jsx | 166 -------------------- 1 file changed, 166 deletions(-) delete mode 100644 src/components/dialogs/filters/MenuTile.jsx diff --git a/src/components/dialogs/filters/MenuTile.jsx b/src/components/dialogs/filters/MenuTile.jsx deleted file mode 100644 index c203c4fa7..000000000 --- a/src/components/dialogs/filters/MenuTile.jsx +++ /dev/null @@ -1,166 +0,0 @@ -import React, { useState } from 'react' -import Check from '@mui/icons-material/Check' -import Clear from '@mui/icons-material/Clear' -import Tune from '@mui/icons-material/Tune' -import FormatSize from '@mui/icons-material/FormatSize' -import Settings from '@mui/icons-material/Settings' -import { Grid, IconButton, Typography } from '@mui/material' -import Utility from '@services/Utility' -import { useLayoutStore } from '@hooks/useLayoutStore' - -export default function MenuTile({ data, rowIndex, columnIndex, style }) { - const [name, setName] = useState(true) - const { - tileItem, - columnCount, - tempFilters, - setTempFilters, - isMobile, - type, - toggleSlotsMenu, - standard, - Icons, - } = data - - const item = tileItem[rowIndex * columnCount + columnIndex] - - if (!item) { - return '' - } - - const handleFilterChange = () => { - const newFilter = tempFilters[item.id] - ? { ...tempFilters[item.id], enabled: !tempFilters[item.id].enabled } - : { ...standard, enabled: true } - setTempFilters({ - ...tempFilters, - [item.id]: newFilter, - }) - Utility.analytics( - 'Filtering', - `${item.name} Status: ${!tempFilters[item.id]?.enabled}`, - type, - ) - } - - const image = - item.id.startsWith('a') || item.id.startsWith('f') ? ( -
- {item.url} - shadow -
- ) : ( - {item.url} - ) - const selection = ( - - {tempFilters[item.id]?.enabled ? ( - - ) : ( - - )} - - ) - - const getAdvMenuIcon = () => { - if (type === 'pokemon') { - return - } - if ( - (type === 'pokestops' && - !item.id.startsWith('l') && - !item.id.startsWith('i')) || - (item.id.startsWith('t') && parseInt(item.id.charAt(1)) > 0) - ) { - return - } - return - } - const advMenu = ( - 0 - ? toggleSlotsMenu(true, item.id.charAt(1)) - : () => - useLayoutStore.setState({ - advancedFilter: { - id: item.id, - open: true, - category: type, - selectedIds: [], - }, - }) - } - size="large" - > - {getAdvMenuIcon()} - - ) - - const nameTitle = ( - setName(!name)} - > - {item.name} - - ) - - return ( - - - {image} - - - {isMobile ? nameTitle : selection} - {!isMobile && advMenu} - - - {isMobile ? advMenu : nameTitle} - - {isMobile && ( - - {selection} - - )} - - ) -} From 99d8e3b1a66d2fb84ab27cc776729f4c3715a8b9 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 17:16:27 -0500 Subject: [PATCH 048/177] refactor: move `ActiveWeather.jsx` --- .../map/components => features/weather}/ActiveWeather.jsx | 7 ++++--- src/features/weather/index.js | 1 + src/pages/map/components/Container.jsx | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) rename src/{pages/map/components => features/weather}/ActiveWeather.jsx (94%) diff --git a/src/pages/map/components/ActiveWeather.jsx b/src/features/weather/ActiveWeather.jsx similarity index 94% rename from src/pages/map/components/ActiveWeather.jsx rename to src/features/weather/ActiveWeather.jsx index c25ee5446..7284c73f8 100644 --- a/src/pages/map/components/ActiveWeather.jsx +++ b/src/features/weather/ActiveWeather.jsx @@ -8,7 +8,6 @@ import booleanPointInPolygon from '@turf/boolean-point-in-polygon' import { point, polygon } from '@turf/helpers' import { useTranslation } from 'react-i18next' -import WeatherPopup from '@features/weather/WeatherPopup' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { apolloClient } from '@services/apollo' @@ -16,6 +15,8 @@ import Header from '@components/Header' import Footer from '@components/Footer' import { Img } from '@components/Img' +import { WeatherPopup } from './WeatherPopup' + const StyledBox = styled(Box)(({ theme }) => ({ zIndex: 1000, position: 'absolute', @@ -35,7 +36,7 @@ const ImgSx = { height: { xs: 24, sm: 36 }, } -export default function ActiveWeather() { +export function ActiveWeather() { const weatherEnabled = useStorage((s) => s.filters?.weather?.enabled ?? false) const location = useStorage((state) => state.location) const Icons = useMemory((state) => state.Icons) @@ -67,7 +68,7 @@ export default function ActiveWeather() { const footerOptions = React.useMemo( () => - /** @type {import('../../../components/Footer').FooterButton[]} */ ([ + /** @type {import('../../components/Footer').FooterButton[]} */ ([ { name: 'close', action: () => setOpen(false), diff --git a/src/features/weather/index.js b/src/features/weather/index.js index e7c7c1b3f..d1f9b8f0b 100644 --- a/src/features/weather/index.js +++ b/src/features/weather/index.js @@ -1,3 +1,4 @@ export * from './WeatherPopup' export * from './WeatherTile' export * from './weatherMarker' +export * from './ActiveWeather' diff --git a/src/pages/map/components/Container.jsx b/src/pages/map/components/Container.jsx index 11894c4c2..c2fa2c264 100644 --- a/src/pages/map/components/Container.jsx +++ b/src/pages/map/components/Container.jsx @@ -10,11 +10,11 @@ import Utility from '@services/Utility' import ScanOnDemand from '@features/scanner' import DraggableMarker from '@features/webhooks/human/Draggable' import WebhookAreaSelection from '@features/webhooks/human/area/AreaSelection' -import { Effects } from './Effects' +import { ActiveWeather } from '@features/weather' +import { Effects } from './Effects' import DataView from './Data' import { Nav } from './Nav' -import ActiveWeather from './ActiveWeather' import { ControlledLocate, ControlledTileLayer, From 85231802f8af478177c5d20cc2a3ed2676b040b8 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:03:10 -0500 Subject: [PATCH 049/177] refactor: `QuestConditions` imports --- src/components/dialogs/filters/QuestConditions.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/dialogs/filters/QuestConditions.jsx b/src/components/dialogs/filters/QuestConditions.jsx index 7382395bc..68eaf03b4 100644 --- a/src/components/dialogs/filters/QuestConditions.jsx +++ b/src/components/dialogs/filters/QuestConditions.jsx @@ -1,11 +1,15 @@ // @ts-check import * as React from 'react' import ListItem from '@mui/material/ListItem' +import Typography from '@mui/material/Typography' +import FormControl from '@mui/material/FormControl' +import InputLabel from '@mui/material/InputLabel' +import Select from '@mui/material/Select' +import MenuItem from '@mui/material/MenuItem' import { useTranslation } from 'react-i18next' + import { useMemory } from '@hooks/useMemory' import { useDeepStore, useStorage } from '@hooks/useStorage' -import { FormControl, InputLabel, Select, MenuItem } from '@mui/material' -import Typography from '@mui/material/Typography' import QuestTitle from '@components/QuestTitle' /** From 4b78846a7b8636031e015902007f9e5f2212821b Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 19:14:14 -0500 Subject: [PATCH 050/177] fix: types --- src/hooks/useStorage.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hooks/useStorage.js b/src/hooks/useStorage.js index 8810a8e13..94ada3d06 100644 --- a/src/hooks/useStorage.js +++ b/src/hooks/useStorage.js @@ -22,7 +22,7 @@ import { persist, createJSONStorage } from 'zustand/middleware' * }, * searches: Record, * tabs: Record, - * menus: ReturnType + * menus: ReturnType * holidayEffects: Record, * motdIndex: number * tutorial: boolean, @@ -31,7 +31,7 @@ import { persist, createJSONStorage } from 'zustand/middleware' * filters: import('@rm/types').AllFilters, * icons: Record * audio: Record - * userSettings: ReturnType['clientValues'] + * userSettings: ReturnType['clientValues'] * profiling: boolean * stateTraceLog: boolean * desktopNotifications: boolean From 8ff33f5477d08d3f933c78f3b405e08097a88c6d Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 22:22:21 -0500 Subject: [PATCH 051/177] refactor: normalize mui imports --- packages/types/lib/augmentations.d.ts | 5 ++- packages/types/lib/client.d.ts | 7 ++-- packages/types/lib/config.d.ts | 3 +- packages/types/lib/general.d.ts | 5 +-- src/components/Footer.jsx | 5 ++- src/components/Header.jsx | 3 +- src/components/Notification.jsx | 2 +- src/components/QuestTitle.jsx | 2 +- src/components/dialogs/UserOptions.jsx | 14 +++---- src/components/dialogs/filters/Advanced.jsx | 5 ++- .../dialogs/filters/PkmnFilterHelp.jsx | 4 +- .../dialogs/filters/StringFilter.jsx | 3 +- src/components/popups/Coords.jsx | 10 ++++- src/components/popups/Dropdown.jsx | 6 ++- src/components/popups/GenderIcon.jsx | 5 ++- src/components/popups/HeaderImage.jsx | 4 +- src/components/popups/NameTT.jsx | 8 +++- src/components/popups/Navigation.jsx | 9 ++++- src/components/popups/PowerUp.jsx | 12 +++++- src/components/popups/TimeTile.jsx | 5 ++- src/components/popups/Timer.jsx | 2 +- src/components/popups/Title.jsx | 3 +- src/features/device/DevicePopup.jsx | 7 +++- src/features/drawer/MultiSelector.jsx | 4 +- src/features/drawer/Pokemon.jsx | 29 +++++++------- src/features/drawer/areas/AreaTable.jsx | 12 +++--- src/features/drawer/areas/Parent.jsx | 6 ++- src/features/gym/GymPopup.jsx | 17 ++++----- src/features/nest/NestPopup.jsx | 17 ++++----- src/features/pokemon/PokemonPopup.jsx | 22 +++++------ src/features/pokestop/PokestopPopup.jsx | 23 +++++------ src/features/profile/Backups.jsx | 2 +- src/features/profile/GymBadges.jsx | 6 ++- src/features/route/RouteTile.jsx | 3 +- src/features/scanCell/ScanCellPopup.jsx | 2 +- src/features/scanner/ScanDialog.jsx | 4 +- .../scanner/scanNext/PopupContent.jsx | 4 +- .../scanner/scanZone/PopupContent.jsx | 6 ++- src/features/search/renderOption.jsx | 3 +- src/features/spawnpoint/SpawnpointPopup.jsx | 2 +- src/features/tutorial/Advanced.jsx | 15 +++----- src/features/tutorial/Closing.jsx | 7 +++- src/features/tutorial/Popups.jsx | 9 +++-- src/features/tutorial/Sidebar.jsx | 26 ++++++------- src/features/tutorial/Sliders.jsx | 5 ++- src/features/tutorial/Welcome.jsx | 6 ++- src/features/tutorial/index.jsx | 4 +- src/features/weather/WeatherPopup.jsx | 3 +- src/features/webhooks/Error.jsx | 5 ++- src/features/webhooks/Selecting.jsx | 6 ++- src/features/webhooks/WebhookAdv.jsx | 38 +++++++++---------- src/features/webhooks/human/Draggable.jsx | 16 ++++---- src/features/webhooks/human/Location.jsx | 16 ++++---- .../webhooks/human/profile/DeleteVIew.jsx | 3 +- src/hooks/useGetAvailable.js | 2 +- src/utils/fromSnakeCase.js | 2 +- 56 files changed, 256 insertions(+), 198 deletions(-) diff --git a/packages/types/lib/augmentations.d.ts b/packages/types/lib/augmentations.d.ts index 1ea6c14ed..4615a932c 100644 --- a/packages/types/lib/augmentations.d.ts +++ b/packages/types/lib/augmentations.d.ts @@ -1,7 +1,8 @@ -import { ButtonProps } from '@mui/material' +import { Request } from 'express' +import type { ButtonProps } from '@mui/material' + import { Config, GetSafeConfig } from './config' import { ExpressUser, Permissions } from './server' -import { Request } from 'express' declare module 'config' { interface IConfig extends Config { diff --git a/packages/types/lib/client.d.ts b/packages/types/lib/client.d.ts index 260af49c7..0b9936f00 100644 --- a/packages/types/lib/client.d.ts +++ b/packages/types/lib/client.d.ts @@ -1,9 +1,10 @@ import * as React from 'react' -import { Config } from './config' -import UAssets from '@services/Assets' -import { ButtonProps, SxProps, Theme } from '@mui/material' +import type { ButtonProps, SxProps, Theme } from '@mui/material' import { SystemStyleObject } from '@mui/system' +import UAssets from '@services/Assets' +import { Config } from './config' + declare global { declare const CONFIG: Config diff --git a/packages/types/lib/config.d.ts b/packages/types/lib/config.d.ts index ceff80824..212b0257c 100644 --- a/packages/types/lib/config.d.ts +++ b/packages/types/lib/config.d.ts @@ -1,9 +1,10 @@ import type { LogLevelNames } from 'loglevel' +import type { DialogProps } from '@mui/material' + import config = require('server/src/configs/default.json') import example = require('server/src/configs/local.example.json') import type { Schema } from './server' -import type { DialogProps } from '@mui/material' type BaseConfig = typeof config type ExampleConfig = typeof example diff --git a/packages/types/lib/general.d.ts b/packages/types/lib/general.d.ts index 779808f1f..9511fd8d2 100644 --- a/packages/types/lib/general.d.ts +++ b/packages/types/lib/general.d.ts @@ -1,4 +1,6 @@ +import type { SliderProps } from '@mui/material' import type { Feature, Polygon, MultiPolygon } from '@turf/helpers' +import { Config } from './config' export type HttpMethod = 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE' @@ -27,9 +29,6 @@ export type RMGeoJSON = { features: RMFeature[] } -import { Config } from './config' -import { SliderProps } from '@mui/material' - export type Strategy = 'discord' | 'telegram' | 'local' export type S2Polygon = [number, number][] diff --git a/src/components/Footer.jsx b/src/components/Footer.jsx index b4a0638f1..561ac0f40 100644 --- a/src/components/Footer.jsx +++ b/src/components/Footer.jsx @@ -1,6 +1,9 @@ // @ts-check import * as React from 'react' -import { IconButton, Button, Typography, Grid } from '@mui/material' +import IconButton from '@mui/material/IconButton' +import Button from '@mui/material/Button' +import Typography from '@mui/material/Typography' +import Grid from '@mui/material/Grid' import { useTranslation } from 'react-i18next' import * as MuiIcons from './Icons' diff --git a/src/components/Header.jsx b/src/components/Header.jsx index dfc7ea91f..bba429769 100644 --- a/src/components/Header.jsx +++ b/src/components/Header.jsx @@ -1,7 +1,8 @@ // @ts-check import * as React from 'react' import Clear from '@mui/icons-material/Clear' -import { IconButton, DialogTitle } from '@mui/material' +import DialogTitle from '@mui/material/DialogTitle' +import IconButton from '@mui/material/IconButton' import { Trans, useTranslation } from 'react-i18next' diff --git a/src/components/Notification.jsx b/src/components/Notification.jsx index 04048f2f7..20a37ca74 100644 --- a/src/components/Notification.jsx +++ b/src/components/Notification.jsx @@ -3,8 +3,8 @@ import * as React from 'react' import Alert from '@mui/material/Alert' import Snackbar from '@mui/material/Snackbar' import Slide from '@mui/material/Slide' +import AlertTitle from '@mui/material/AlertTitle' import { useTranslation, Trans } from 'react-i18next' -import { AlertTitle } from '@mui/material' function SlideTransition(props) { // eslint-disable-next-line react/jsx-props-no-spreading diff --git a/src/components/QuestTitle.jsx b/src/components/QuestTitle.jsx index fcce57693..387559782 100644 --- a/src/components/QuestTitle.jsx +++ b/src/components/QuestTitle.jsx @@ -1,6 +1,6 @@ // @ts-check import * as React from 'react' -import { Typography } from '@mui/material' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' /** diff --git a/src/components/dialogs/UserOptions.jsx b/src/components/dialogs/UserOptions.jsx index dc3a9ce33..12d7830dd 100644 --- a/src/components/dialogs/UserOptions.jsx +++ b/src/components/dialogs/UserOptions.jsx @@ -1,12 +1,10 @@ import * as React from 'react' -import { - Switch, - Input, - DialogContent, - List, - ListItem, - ListItemText, -} from '@mui/material' +import DialogContent from '@mui/material/DialogContent' +import Input from '@mui/material/Input' +import List from '@mui/material/List' +import ListItem from '@mui/material/ListItem' +import ListItemText from '@mui/material/ListItemText' +import Switch from '@mui/material/Switch' import { useTranslation, Trans } from 'react-i18next' import Utility from '@services/Utility' diff --git a/src/components/dialogs/filters/Advanced.jsx b/src/components/dialogs/filters/Advanced.jsx index 0296e34de..86b4f5c8b 100644 --- a/src/components/dialogs/filters/Advanced.jsx +++ b/src/components/dialogs/filters/Advanced.jsx @@ -1,7 +1,10 @@ // @ts-check import * as React from 'react' -import { DialogContent, List, ListItem, Dialog } from '@mui/material' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' +import Dialog from '@mui/material/Dialog' +import DialogContent from '@mui/material/DialogContent' +import List from '@mui/material/List' +import ListItem from '@mui/material/ListItem' import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' diff --git a/src/components/dialogs/filters/PkmnFilterHelp.jsx b/src/components/dialogs/filters/PkmnFilterHelp.jsx index d4e5b6d05..84c94f28b 100644 --- a/src/components/dialogs/filters/PkmnFilterHelp.jsx +++ b/src/components/dialogs/filters/PkmnFilterHelp.jsx @@ -5,7 +5,9 @@ import Box from '@mui/material/Box' import Typography from '@mui/material/Typography' import Grid2 from '@mui/material/Unstable_Grid2' import { useTranslation } from 'react-i18next' -import { Chip, Divider, useMediaQuery } from '@mui/material' +import useMediaQuery from '@mui/material/useMediaQuery' +import Divider from '@mui/material/Divider' +import Chip from '@mui/material/Chip' import Header from '@components/Header' import Footer from '@components/Footer' diff --git a/src/components/dialogs/filters/StringFilter.jsx b/src/components/dialogs/filters/StringFilter.jsx index a855b5700..58dedc3a6 100644 --- a/src/components/dialogs/filters/StringFilter.jsx +++ b/src/components/dialogs/filters/StringFilter.jsx @@ -1,6 +1,7 @@ // @ts-check import * as React from 'react' -import { ListItem, TextField } from '@mui/material' +import ListItem from '@mui/material/ListItem' +import TextField from '@mui/material/TextField' import { useTranslation } from 'react-i18next' import dlv from 'dlv' diff --git a/src/components/popups/Coords.jsx b/src/components/popups/Coords.jsx index ad85149f4..7cae1a1fd 100644 --- a/src/components/popups/Coords.jsx +++ b/src/components/popups/Coords.jsx @@ -1,6 +1,12 @@ -import React from 'react' -import { Typography } from '@mui/material' +// @ts-check +import * as React from 'react' +import Typography from '@mui/material/Typography' +/** + * + * @param {{ lat: number, lon: number }} props + * @returns + */ export default function Coords({ lat, lon }) { return ( diff --git a/src/components/popups/Dropdown.jsx b/src/components/popups/Dropdown.jsx index 9381eaeab..dea1bc489 100644 --- a/src/components/popups/Dropdown.jsx +++ b/src/components/popups/Dropdown.jsx @@ -1,5 +1,7 @@ -import React from 'react' -import { Menu, MenuItem } from '@mui/material' +// @ts-check +import * as React from 'react' +import Menu from '@mui/material/Menu' +import MenuItem from '@mui/material/MenuItem' import { useTranslation } from 'react-i18next' export default function Dropdown({ options, anchorEl, handleClose }) { diff --git a/src/components/popups/GenderIcon.jsx b/src/components/popups/GenderIcon.jsx index 76d4377a4..3427e5738 100644 --- a/src/components/popups/GenderIcon.jsx +++ b/src/components/popups/GenderIcon.jsx @@ -1,7 +1,7 @@ +// @ts-check import * as React from 'react' import SvgIcon from '@mui/material/SvgIcon' - -import { useTheme } from '@mui/material' +import useTheme from '@mui/material/styles/useTheme' const PATH = { 0: '', @@ -10,6 +10,7 @@ const PATH = { 3: 'M12 8c1.93 0 3.5 1.57 3.5 3.5S13.93 15 12 15s-3.5-1.57-3.5-3.5S10.07 8 12 8zm4.53.38 3.97-3.96V7h2V1h-6v2h2.58l-3.97 3.97C14.23 6.36 13.16 6 12 6s-2.23.36-3.11.97l-.65-.65 1.41-1.41-1.41-1.42L6.82 4.9 4.92 3H7.5V1h-6v6h2V4.42l1.91 1.9-1.42 1.42L5.4 9.15l1.41-1.41.65.65c-.6.88-.96 1.95-.96 3.11 0 2.7 1.94 4.94 4.5 5.41V19H9v2h2v2h2v-2h2v-2h-2v-2.09c2.56-.47 4.5-2.71 4.5-5.41 0-1.16-.36-2.23-.97-3.12z', } +/** @param {{ gender: keyof typeof PATH }} props */ export default function GenderIcon({ gender }) { const theme = useTheme() diff --git a/src/components/popups/HeaderImage.jsx b/src/components/popups/HeaderImage.jsx index c32e1c256..cb3451ccc 100644 --- a/src/components/popups/HeaderImage.jsx +++ b/src/components/popups/HeaderImage.jsx @@ -1,6 +1,8 @@ // @ts-check import * as React from 'react' -import { Avatar, Link } from '@mui/material' +import Avatar from '@mui/material/Avatar' +import Link from '@mui/material/Link' + import { useMemory } from '@hooks/useMemory' export default function HeaderImage({ diff --git a/src/components/popups/NameTT.jsx b/src/components/popups/NameTT.jsx index db5d10f77..f661f34ca 100644 --- a/src/components/popups/NameTT.jsx +++ b/src/components/popups/NameTT.jsx @@ -1,7 +1,13 @@ +// @ts-check import * as React from 'react' -import { Tooltip } from '@mui/material' +import Tooltip from '@mui/material/Tooltip' import { useTranslation } from 'react-i18next' +/** + * + * @param {{ id: string | string[], children: React.ReactElement }} props + * @returns + */ export default function NameTT({ id, children }) { const { t } = useTranslation() diff --git a/src/components/popups/Navigation.jsx b/src/components/popups/Navigation.jsx index a9c962329..1ef16eedb 100644 --- a/src/components/popups/Navigation.jsx +++ b/src/components/popups/Navigation.jsx @@ -1,10 +1,15 @@ -import React from 'react' +// @ts-check +import * as React from 'react' import Map from '@mui/icons-material/Map' -import { IconButton } from '@mui/material' +import IconButton from '@mui/material/IconButton' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' +/** + * @param {{ lat: number, lon: number, size?: import('@mui/material').IconButtonProps['size'] }} props + * @returns + */ export default function Navigation({ lat, lon, size = 'large' }) { const nav = useStorage((s) => s.settings.navigation) const url = useMemory((s) => s.settings.navigation[nav]?.url) diff --git a/src/components/popups/PowerUp.jsx b/src/components/popups/PowerUp.jsx index dea9412d7..554b0579c 100644 --- a/src/components/popups/PowerUp.jsx +++ b/src/components/popups/PowerUp.jsx @@ -1,11 +1,19 @@ -import React from 'react' -import { Grid, Typography, Divider } from '@mui/material' +// @ts-check +import * as React from 'react' +import Divider from '@mui/material/Divider' +import Grid from '@mui/material/Grid' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' import TimeTile from './TimeTile' +/** + * + * @param {{ power_up_level: number, power_up_points: number, power_up_end_timestamp: number, divider?: boolean }} props + * @returns + */ export default function PowerUp({ power_up_level, power_up_points, diff --git a/src/components/popups/TimeTile.jsx b/src/components/popups/TimeTile.jsx index aaf224e36..e80707c48 100644 --- a/src/components/popups/TimeTile.jsx +++ b/src/components/popups/TimeTile.jsx @@ -1,6 +1,9 @@ // @ts-check import * as React from 'react' -import { Collapse, Grid, IconButton, Typography } from '@mui/material' +import Collapse from '@mui/material/Collapse' +import Grid from '@mui/material/Grid' +import IconButton from '@mui/material/IconButton' +import Typography from '@mui/material/Typography' import ExpandMore from '@mui/icons-material/ExpandMore' import { useStorage } from '@hooks/useStorage' diff --git a/src/components/popups/Timer.jsx b/src/components/popups/Timer.jsx index cffb82242..d0a12e1d4 100644 --- a/src/components/popups/Timer.jsx +++ b/src/components/popups/Timer.jsx @@ -1,6 +1,6 @@ // @ts-check import * as React from 'react' -import { Typography } from '@mui/material' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' diff --git a/src/components/popups/Title.jsx b/src/components/popups/Title.jsx index c1a149abc..78ada2a2c 100644 --- a/src/components/popups/Title.jsx +++ b/src/components/popups/Title.jsx @@ -1,5 +1,6 @@ +// @ts-check import * as React from 'react' -import { Typography } from '@mui/material' +import Typography from '@mui/material/Typography' import { useStorage } from '@hooks/useStorage' diff --git a/src/features/device/DevicePopup.jsx b/src/features/device/DevicePopup.jsx index 8dd38c09a..2de2ebc99 100644 --- a/src/features/device/DevicePopup.jsx +++ b/src/features/device/DevicePopup.jsx @@ -1,11 +1,16 @@ // @ts-check import * as React from 'react' -import { Typography } from '@mui/material' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' import ErrorBoundary from '@components/ErrorBoundary' +/** + * + * @param {{ isOnline: boolean, ts: number } & import('@rm/types').Device} props + * @returns + */ export function DevicePopup({ isOnline, ts, ...device }) { const { t } = useTranslation() diff --git a/src/features/drawer/MultiSelector.jsx b/src/features/drawer/MultiSelector.jsx index f80c59146..b45016410 100644 --- a/src/features/drawer/MultiSelector.jsx +++ b/src/features/drawer/MultiSelector.jsx @@ -1,7 +1,9 @@ // @ts-check import * as React from 'react' -import { ButtonGroup, Button } from '@mui/material' +import Button from '@mui/material/Button' +import ButtonGroup from '@mui/material/ButtonGroup' import { useTranslation } from 'react-i18next' + import { useDeepStore } from '@hooks/useStorage' const SX = /** @type {import('@mui/material').SxProps} */ ({ mx: 'auto' }) diff --git a/src/features/drawer/Pokemon.jsx b/src/features/drawer/Pokemon.jsx index 11d23395f..3ec960a14 100644 --- a/src/features/drawer/Pokemon.jsx +++ b/src/features/drawer/Pokemon.jsx @@ -1,21 +1,19 @@ // @ts-check /* eslint-disable react/no-unstable-nested-components */ import * as React from 'react' -import { - Typography, - AppBar, - Tab, - Tabs, - List, - ListItem, - Collapse, - Divider, - ListSubheader, - Select, - MenuItem, - FormControl, - InputLabel, -} from '@mui/material' +import AppBar from '@mui/material/AppBar' +import Divider from '@mui/material/Divider' +import FormControl from '@mui/material/FormControl' +import InputLabel from '@mui/material/InputLabel' +import List from '@mui/material/List' +import ListItem from '@mui/material/ListItem' +import ListSubheader from '@mui/material/ListSubheader' +import MenuItem from '@mui/material/MenuItem' +import Select from '@mui/material/Select' +import Tab from '@mui/material/Tab' +import Tabs from '@mui/material/Tabs' +import Typography from '@mui/material/Typography' +import Collapse from '@mui/material/Collapse' import { useTranslation } from 'react-i18next' import Help from '@mui/icons-material/HelpOutline' @@ -24,7 +22,6 @@ import { useStorage, useDeepStore } from '@hooks/useStorage' import Utility from '@services/Utility' import { XXS_XXL, NUNDO_HUNDO } from '@assets/constants' import { useLayoutStore } from '@hooks/useLayoutStore' - import { StringFilterMemo } from '@components/dialogs/filters/StringFilter' import SliderTile from '@components/dialogs/filters/SliderTile' import TabPanel from '@components/TabPanel' diff --git a/src/features/drawer/areas/AreaTable.jsx b/src/features/drawer/areas/AreaTable.jsx index b68e08a0c..7b9a10de0 100644 --- a/src/features/drawer/areas/AreaTable.jsx +++ b/src/features/drawer/areas/AreaTable.jsx @@ -1,13 +1,11 @@ // @ts-check import * as React from 'react' import { useQuery } from '@apollo/client' -import { - TableContainer, - Table, - TableBody, - TableRow, - Paper, -} from '@mui/material' +import Paper from '@mui/material/Paper' +import Table from '@mui/material/Table' +import TableBody from '@mui/material/TableBody' +import TableRow from '@mui/material/TableRow' +import TableContainer from '@mui/material/TableContainer' import Query from '@services/Query' import { useMemory } from '@hooks/useMemory' diff --git a/src/features/drawer/areas/Parent.jsx b/src/features/drawer/areas/Parent.jsx index d22545501..9550a03e2 100644 --- a/src/features/drawer/areas/Parent.jsx +++ b/src/features/drawer/areas/Parent.jsx @@ -1,6 +1,10 @@ // @ts-check import * as React from 'react' -import { Table, TableBody, Collapse, TableCell } from '@mui/material' +import TableCell from '@mui/material/TableCell' +import Collapse from '@mui/material/Collapse' +import Table from '@mui/material/Table' +import TableBody from '@mui/material/TableBody' + import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' diff --git a/src/features/gym/GymPopup.jsx b/src/features/gym/GymPopup.jsx index db3dfed95..bd0e6e265 100644 --- a/src/features/gym/GymPopup.jsx +++ b/src/features/gym/GymPopup.jsx @@ -2,16 +2,13 @@ import * as React from 'react' import ExpandMore from '@mui/icons-material/ExpandMore' import MoreVert from '@mui/icons-material/MoreVert' -import { - Grid, - Typography, - Collapse, - IconButton, - Divider, - MenuItem, - Menu, -} from '@mui/material' - +import Grid from '@mui/material/Grid' +import IconButton from '@mui/material/IconButton' +import Menu from '@mui/material/Menu' +import MenuItem from '@mui/material/MenuItem' +import Divider from '@mui/material/Divider' +import Collapse from '@mui/material/Collapse' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' import { useSyncData } from '@features/webhooks/hooks' diff --git a/src/features/nest/NestPopup.jsx b/src/features/nest/NestPopup.jsx index 97fd5def8..349c2941c 100644 --- a/src/features/nest/NestPopup.jsx +++ b/src/features/nest/NestPopup.jsx @@ -1,16 +1,13 @@ // @ts-check import React, { useState, useEffect } from 'react' import MoreVert from '@mui/icons-material/MoreVert' -import { - Grid, - Typography, - IconButton, - Divider, - Menu, - MenuItem, - Button, -} from '@mui/material' - +import Grid from '@mui/material/Grid' +import Typography from '@mui/material/Typography' +import IconButton from '@mui/material/IconButton' +import Menu from '@mui/material/Menu' +import MenuItem from '@mui/material/MenuItem' +import Divider from '@mui/material/Divider' +import Button from '@mui/material/Button' import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' diff --git a/src/features/pokemon/PokemonPopup.jsx b/src/features/pokemon/PokemonPopup.jsx index eed2ab8e1..c9fd76a71 100644 --- a/src/features/pokemon/PokemonPopup.jsx +++ b/src/features/pokemon/PokemonPopup.jsx @@ -1,21 +1,17 @@ -/* eslint-disable no-nested-ternary */ import React, { useState, useEffect } from 'react' import Check from '@mui/icons-material/Check' import Clear from '@mui/icons-material/Clear' import ExpandMore from '@mui/icons-material/ExpandMore' import MoreVert from '@mui/icons-material/MoreVert' -import { - Grid, - Avatar, - Typography, - Collapse, - IconButton, - Divider, - Menu, - MenuItem, - Tooltip, -} from '@mui/material' - +import Grid from '@mui/material/Grid' +import Typography from '@mui/material/Typography' +import IconButton from '@mui/material/IconButton' +import Menu from '@mui/material/Menu' +import MenuItem from '@mui/material/MenuItem' +import Divider from '@mui/material/Divider' +import Avatar from '@mui/material/Avatar' +import Tooltip from '@mui/material/Tooltip' +import Collapse from '@mui/material/Collapse' import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' diff --git a/src/features/pokestop/PokestopPopup.jsx b/src/features/pokestop/PokestopPopup.jsx index b2f0c1c10..b7b9a1b19 100644 --- a/src/features/pokestop/PokestopPopup.jsx +++ b/src/features/pokestop/PokestopPopup.jsx @@ -2,19 +2,16 @@ import * as React from 'react' import ExpandMore from '@mui/icons-material/ExpandMore' import MoreVert from '@mui/icons-material/MoreVert' -import { - Grid, - Typography, - Collapse, - IconButton, - Divider, - TableRow, - TableCell, - Table, - TableBody, - styled, -} from '@mui/material' - +import Divider from '@mui/material/Divider' +import Grid from '@mui/material/Grid' +import IconButton from '@mui/material/IconButton' +import Collapse from '@mui/material/Collapse' +import Typography from '@mui/material/Typography' +import TableCell from '@mui/material/TableCell' +import TableRow from '@mui/material/TableRow' +import Table from '@mui/material/Table' +import TableBody from '@mui/material/TableBody' +import styled from '@mui/material/styles/styled' import { useTranslation, Trans } from 'react-i18next' import ErrorBoundary from '@components/ErrorBoundary' diff --git a/src/features/profile/Backups.jsx b/src/features/profile/Backups.jsx index e39f3a0f4..d4b6c45d3 100644 --- a/src/features/profile/Backups.jsx +++ b/src/features/profile/Backups.jsx @@ -11,11 +11,11 @@ import Button from '@mui/material/Button' import ButtonGroup from '@mui/material/ButtonGroup' import Typography from '@mui/material/Typography' import Divider from '@mui/material/Divider' +import Box from '@mui/material/Box' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import Query from '@services/Query' -import { Box } from '@mui/material' export function UserBackups() { const { t } = useTranslation() diff --git a/src/features/profile/GymBadges.jsx b/src/features/profile/GymBadges.jsx index 9f063d7ec..44834f77e 100644 --- a/src/features/profile/GymBadges.jsx +++ b/src/features/profile/GymBadges.jsx @@ -1,6 +1,10 @@ // @ts-check import * as React from 'react' -import { Grid, Typography, IconButton, Button, Box } from '@mui/material' +import Grid from '@mui/material/Grid' +import Box from '@mui/material/Box' +import Typography from '@mui/material/Typography' +import IconButton from '@mui/material/IconButton' +import Button from '@mui/material/Button' import Edit from '@mui/icons-material/Edit' import { useTranslation } from 'react-i18next' import { useQuery } from '@apollo/client' diff --git a/src/features/route/RouteTile.jsx b/src/features/route/RouteTile.jsx index 12dacf0d1..f19114d5c 100644 --- a/src/features/route/RouteTile.jsx +++ b/src/features/route/RouteTile.jsx @@ -1,9 +1,8 @@ /* eslint-disable react/destructuring-assignment */ -/* eslint-disable no-nested-ternary */ // @ts-check import * as React from 'react' import { Marker, Polyline, useMapEvents } from 'react-leaflet' -import { darken } from '@mui/material' +import { darken } from '@mui/material/styles' import useForcePopup from '@hooks/useForcePopup' diff --git a/src/features/scanCell/ScanCellPopup.jsx b/src/features/scanCell/ScanCellPopup.jsx index 29412c232..2a7b7468b 100644 --- a/src/features/scanCell/ScanCellPopup.jsx +++ b/src/features/scanCell/ScanCellPopup.jsx @@ -1,6 +1,6 @@ // @ts-check import * as React from 'react' -import { Typography } from '@mui/material' +import Typography from '@mui/material/Typography' import { Trans, useTranslation } from 'react-i18next' import Utility from '@services/Utility' diff --git a/src/features/scanner/ScanDialog.jsx b/src/features/scanner/ScanDialog.jsx index 15e69995a..67b58c69f 100644 --- a/src/features/scanner/ScanDialog.jsx +++ b/src/features/scanner/ScanDialog.jsx @@ -1,6 +1,8 @@ // @ts-check import * as React from 'react' -import { Dialog, DialogContent, Typography } from '@mui/material' +import Dialog from '@mui/material/Dialog' +import DialogContent from '@mui/material/DialogContent' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' import Header from '@components/Header' diff --git a/src/features/scanner/scanNext/PopupContent.jsx b/src/features/scanner/scanNext/PopupContent.jsx index cb68e69d1..22a3ab12a 100644 --- a/src/features/scanner/scanNext/PopupContent.jsx +++ b/src/features/scanner/scanNext/PopupContent.jsx @@ -1,6 +1,8 @@ // @ts-check import * as React from 'react' -import { Button, ButtonGroup, ListItem } from '@mui/material' +import Button from '@mui/material/Button' +import ButtonGroup from '@mui/material/ButtonGroup' +import ListItem from '@mui/material/ListItem' import { useTranslation } from 'react-i18next' import { SCAN_SIZES } from '@assets/constants' diff --git a/src/features/scanner/scanZone/PopupContent.jsx b/src/features/scanner/scanZone/PopupContent.jsx index 0f98bf055..af91a5ab7 100644 --- a/src/features/scanner/scanZone/PopupContent.jsx +++ b/src/features/scanner/scanZone/PopupContent.jsx @@ -1,6 +1,10 @@ // @ts-check import * as React from 'react' -import { Button, ButtonGroup, Slider, List, ListItem } from '@mui/material' +import Button from '@mui/material/Button' +import ButtonGroup from '@mui/material/ButtonGroup' +import List from '@mui/material/List' +import ListItem from '@mui/material/ListItem' +import Slider from '@mui/material/Slider' import { useTranslation } from 'react-i18next' import { debounce } from 'lodash' diff --git a/src/features/search/renderOption.jsx b/src/features/search/renderOption.jsx index 65f1b242d..0ae2fa47a 100644 --- a/src/features/search/renderOption.jsx +++ b/src/features/search/renderOption.jsx @@ -5,13 +5,14 @@ import ListItem from '@mui/material/ListItem' import ListItemIcon from '@mui/material/ListItemIcon' import ListItemText from '@mui/material/ListItemText' import Grid2 from '@mui/material/Unstable_Grid2/Grid2' +import Divider from '@mui/material/Divider' +import Typography from '@mui/material/Typography' import { Img } from '@components/Img' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' import { RawQuestTitle } from '@components/QuestTitle' -import { Divider, Typography } from '@mui/material' import Utility from '@services/Utility' import { RawTimeSince } from '@components/popups/Timer' import { getGruntReward } from '@utils/getGruntReward' diff --git a/src/features/spawnpoint/SpawnpointPopup.jsx b/src/features/spawnpoint/SpawnpointPopup.jsx index 63b101f9d..c77d9baee 100644 --- a/src/features/spawnpoint/SpawnpointPopup.jsx +++ b/src/features/spawnpoint/SpawnpointPopup.jsx @@ -1,6 +1,6 @@ // @ts-check import * as React from 'react' -import { Typography } from '@mui/material' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' diff --git a/src/features/tutorial/Advanced.jsx b/src/features/tutorial/Advanced.jsx index c1c619e69..872f4c961 100644 --- a/src/features/tutorial/Advanced.jsx +++ b/src/features/tutorial/Advanced.jsx @@ -6,15 +6,12 @@ import Clear from '@mui/icons-material/Clear' import Save from '@mui/icons-material/Save' import HelpOutline from '@mui/icons-material/HelpOutline' import FormatSize from '@mui/icons-material/FormatSize' - -import { - Grid, - DialogContent, - Typography, - Divider, - Button, - Box, -} from '@mui/material' +import DialogContent from '@mui/material/DialogContent' +import Typography from '@mui/material/Typography' +import Divider from '@mui/material/Divider' +import Button from '@mui/material/Button' +import Grid from '@mui/material/Grid' +import Box from '@mui/material/Box' import { useTranslation } from 'react-i18next' diff --git a/src/features/tutorial/Closing.jsx b/src/features/tutorial/Closing.jsx index f28051dc2..544130e1a 100644 --- a/src/features/tutorial/Closing.jsx +++ b/src/features/tutorial/Closing.jsx @@ -1,5 +1,8 @@ -import React from 'react' -import { DialogContent, Typography, Divider } from '@mui/material' +// @ts-check +import * as React from 'react' +import DialogContent from '@mui/material/DialogContent' +import Divider from '@mui/material/Divider' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' export default function TutClosing() { diff --git a/src/features/tutorial/Popups.jsx b/src/features/tutorial/Popups.jsx index 7c66b1106..209ca2f39 100644 --- a/src/features/tutorial/Popups.jsx +++ b/src/features/tutorial/Popups.jsx @@ -1,5 +1,9 @@ +// @ts-check import React from 'react' -import { Grid, DialogContent, Typography, Divider } from '@mui/material' +import DialogContent from '@mui/material/DialogContent' +import Divider from '@mui/material/Divider' +import Typography from '@mui/material/Typography' +import Grid from '@mui/material/Grid' import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' @@ -8,7 +12,6 @@ import data from './data' export default function TutPopup({ isMobile }) { const { t } = useTranslation() - const Icons = useMemory((state) => state.Icons) const { startLat, startLon } = useMemory((state) => state.config.general) const ts = Math.floor(new Date().getTime() / 1000) const size = isMobile ? 'subtitle2' : 'subtitle1' @@ -54,9 +57,7 @@ export default function TutPopup({ isMobile }) { lon: startLon, }} iconUrl="https://raw.githubusercontent.com/WatWowMap/wwm-uicons-webp/main/pokemon/16.webp" - userSettings={{ prioritizePvpInfo: false }} isTutorial - Icons={Icons} /> diff --git a/src/features/tutorial/Sidebar.jsx b/src/features/tutorial/Sidebar.jsx index 335ac18de..3e6bd1b48 100644 --- a/src/features/tutorial/Sidebar.jsx +++ b/src/features/tutorial/Sidebar.jsx @@ -2,21 +2,17 @@ import * as React from 'react' import Menu from '@mui/icons-material/Menu' import Settings from '@mui/icons-material/Settings' import TuneIcon from '@mui/icons-material/Tune' - -import { - Grid, - DialogContent, - Typography, - Fab, - Divider, - List, - ListItemButton, - ListItemIcon, - ListItemText, - ListItem, - Switch, -} from '@mui/material' - +import Grid from '@mui/material/Grid' +import Fab from '@mui/material/Fab' +import Divider from '@mui/material/Divider' +import List from '@mui/material/List' +import ListItem from '@mui/material/ListItem' +import ListItemIcon from '@mui/material/ListItemIcon' +import ListItemText from '@mui/material/ListItemText' +import ListItemButton from '@mui/material/ListItemButton' +import Switch from '@mui/material/Switch' +import DialogContent from '@mui/material/DialogContent' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' diff --git a/src/features/tutorial/Sliders.jsx b/src/features/tutorial/Sliders.jsx index 77b6690bf..6242d1e64 100644 --- a/src/features/tutorial/Sliders.jsx +++ b/src/features/tutorial/Sliders.jsx @@ -1,5 +1,8 @@ import React, { useState } from 'react' -import { Grid, DialogContent, Typography, Divider } from '@mui/material' +import DialogContent from '@mui/material/DialogContent' +import Typography from '@mui/material/Typography' +import Grid from '@mui/material/Grid' +import Divider from '@mui/material/Divider' import { useTranslation, Trans } from 'react-i18next' import SliderTile from '@components/dialogs/filters/SliderTile' diff --git a/src/features/tutorial/Welcome.jsx b/src/features/tutorial/Welcome.jsx index 34c1dec6b..83e1c91f8 100644 --- a/src/features/tutorial/Welcome.jsx +++ b/src/features/tutorial/Welcome.jsx @@ -1,8 +1,10 @@ import React from 'react' import Person from '@mui/icons-material/Person' import LockOpen from '@mui/icons-material/LockOpen' -import { DialogContent, Grid, Typography, Fab } from '@mui/material' - +import Grid from '@mui/material/Grid' +import Fab from '@mui/material/Fab' +import Typography from '@mui/material/Typography' +import DialogContent from '@mui/material/DialogContent' import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' diff --git a/src/features/tutorial/index.jsx b/src/features/tutorial/index.jsx index 071da5722..247780c19 100644 --- a/src/features/tutorial/index.jsx +++ b/src/features/tutorial/index.jsx @@ -1,7 +1,9 @@ import React, { useState } from 'react' import KeyboardArrowLeft from '@mui/icons-material/KeyboardArrowLeft' import KeyboardArrowRight from '@mui/icons-material/KeyboardArrowRight' -import { Box, Dialog, useMediaQuery } from '@mui/material' +import Box from '@mui/material/Box' +import Dialog from '@mui/material/Dialog' +import useMediaQuery from '@mui/material/useMediaQuery' import DialogActions from '@mui/material/DialogActions' import Button from '@mui/material/Button' import MobileStepper from '@mui/material/MobileStepper' diff --git a/src/features/weather/WeatherPopup.jsx b/src/features/weather/WeatherPopup.jsx index 4b5196479..1075636cf 100644 --- a/src/features/weather/WeatherPopup.jsx +++ b/src/features/weather/WeatherPopup.jsx @@ -1,6 +1,7 @@ // @ts-check import * as React from 'react' -import { Grid, Typography } from '@mui/material' +import Grid from '@mui/material/Grid' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' diff --git a/src/features/webhooks/Error.jsx b/src/features/webhooks/Error.jsx index 70b3c376b..26d1cf33f 100644 --- a/src/features/webhooks/Error.jsx +++ b/src/features/webhooks/Error.jsx @@ -1,6 +1,9 @@ +// @ts-check import React from 'react' +import Typography from '@mui/material/Typography' +import Grid from '@mui/material/Grid' import { useTranslation, Trans } from 'react-i18next' -import { Grid, Typography } from '@mui/material' + import { useWebhookStore } from './store' export default function WebhookError({ children }) { diff --git a/src/features/webhooks/Selecting.jsx b/src/features/webhooks/Selecting.jsx index 654cc1efb..218b9fc45 100644 --- a/src/features/webhooks/Selecting.jsx +++ b/src/features/webhooks/Selecting.jsx @@ -1,8 +1,12 @@ // @ts-check import * as React from 'react' -import { Grid, Fab, Typography, Slide } from '@mui/material' +import Grid from '@mui/material/Grid' +import Fab from '@mui/material/Fab' +import Slide from '@mui/material/Slide' +import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' import { useMutation } from '@apollo/client' + import { setProfile, allProfiles } from '@services/queries/webhook' import { useWebhookStore, setSelected } from './store' diff --git a/src/features/webhooks/WebhookAdv.jsx b/src/features/webhooks/WebhookAdv.jsx index 40e1bb470..ef5a062d6 100644 --- a/src/features/webhooks/WebhookAdv.jsx +++ b/src/features/webhooks/WebhookAdv.jsx @@ -1,26 +1,24 @@ /* eslint-disable react/jsx-no-duplicate-props */ import * as React from 'react' import ExpandMore from '@mui/icons-material/ExpandMore' -import { - Grid, - Dialog, - DialogContent, - Switch, - Typography, - Select, - MenuItem, - TextField, - FormControl, - InputLabel, - InputAdornment, - Paper, - Accordion, - AccordionSummary, - AccordionDetails, - Divider, - CircularProgress, - Autocomplete, -} from '@mui/material' +import Accordion from '@mui/material/Accordion' +import AccordionDetails from '@mui/material/AccordionDetails' +import AccordionSummary from '@mui/material/AccordionSummary' +import CircularProgress from '@mui/material/CircularProgress' +import Divider from '@mui/material/Divider' +import FormControl from '@mui/material/FormControl' +import Grid from '@mui/material/Grid' +import InputAdornment from '@mui/material/InputAdornment' +import InputLabel from '@mui/material/InputLabel' +import MenuItem from '@mui/material/MenuItem' +import Paper from '@mui/material/Paper' +import Select from '@mui/material/Select' +import Switch from '@mui/material/Switch' +import TextField from '@mui/material/TextField' +import Typography from '@mui/material/Typography' +import Autocomplete from '@mui/material/Autocomplete' +import Dialog from '@mui/material/Dialog' +import DialogContent from '@mui/material/DialogContent' import { Trans, useTranslation } from 'react-i18next' import { useLazyQuery } from '@apollo/client' diff --git a/src/features/webhooks/human/Draggable.jsx b/src/features/webhooks/human/Draggable.jsx index 2426918c5..eecf89f3f 100644 --- a/src/features/webhooks/human/Draggable.jsx +++ b/src/features/webhooks/human/Draggable.jsx @@ -1,16 +1,16 @@ // @ts-check import * as React from 'react' -import { - Grid, - Button, - Typography, - OutlinedInput, - InputAdornment, - FormControl, -} from '@mui/material' +import Button from '@mui/material/Button' +import FormControl from '@mui/material/FormControl' +import Grid from '@mui/material/Grid' +import InputAdornment from '@mui/material/InputAdornment' +import OutlinedInput from '@mui/material/OutlinedInput' +import Typography from '@mui/material/Typography' import { Circle, Marker, Popup, useMap } from 'react-leaflet' import { useTranslation } from 'react-i18next' + import fallbackIcon from '@assets/fallbackMarker' + import { useWebhookStore } from '../store' export default function DraggableMarker() { diff --git a/src/features/webhooks/human/Location.jsx b/src/features/webhooks/human/Location.jsx index f92d012f6..df023a47e 100644 --- a/src/features/webhooks/human/Location.jsx +++ b/src/features/webhooks/human/Location.jsx @@ -2,15 +2,13 @@ import * as React from 'react' import LocationOn from '@mui/icons-material/LocationOn' import MyLocation from '@mui/icons-material/MyLocation' -import { - Grid, - Button, - TextField, - Typography, - CircularProgress, - Autocomplete, - Box, -} from '@mui/material' +import Autocomplete from '@mui/material/Autocomplete' +import Box from '@mui/material/Box' +import Button from '@mui/material/Button' +import CircularProgress from '@mui/material/CircularProgress' +import Grid from '@mui/material/Grid' +import TextField from '@mui/material/TextField' +import Typography from '@mui/material/Typography' import { useLazyQuery, useMutation } from '@apollo/client' import { useTranslation } from 'react-i18next' import { useMapEvents } from 'react-leaflet' diff --git a/src/features/webhooks/human/profile/DeleteVIew.jsx b/src/features/webhooks/human/profile/DeleteVIew.jsx index 9e01a6880..6221d87cf 100644 --- a/src/features/webhooks/human/profile/DeleteVIew.jsx +++ b/src/features/webhooks/human/profile/DeleteVIew.jsx @@ -2,7 +2,8 @@ import * as React from 'react' import Clear from '@mui/icons-material/Clear' import Save from '@mui/icons-material/Save' -import { Typography, IconButton } from '@mui/material' +import Typography from '@mui/material/Typography' +import IconButton from '@mui/material/IconButton' import Grid from '@mui/material/Unstable_Grid2' import { useTranslation } from 'react-i18next' diff --git a/src/hooks/useGetAvailable.js b/src/hooks/useGetAvailable.js index be70d08f8..c00cf1f77 100644 --- a/src/hooks/useGetAvailable.js +++ b/src/hooks/useGetAvailable.js @@ -2,7 +2,7 @@ import { useEffect, useMemo } from 'react' import { useQuery } from '@apollo/client' import * as queries from '@services/queries/available' -import { capitalize } from '@mui/material' +import { capitalize } from '@mui/material/utils' import { useMemory } from './useMemory' diff --git a/src/utils/fromSnakeCase.js b/src/utils/fromSnakeCase.js index fd877f145..e43f8eecc 100644 --- a/src/utils/fromSnakeCase.js +++ b/src/utils/fromSnakeCase.js @@ -1,5 +1,5 @@ // @ts-check -import { capitalize } from '@mui/material' +import { capitalize } from '@mui/material/utils' /** * @param {string} str From 7667f0b87ad786208d0aab4ea8f2762d81f7fca8 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 23:19:43 -0500 Subject: [PATCH 052/177] refactor: move `AdvancedAccordion.jsx` --- .../scanner/scanZone/AdvAccordion.jsx} | 22 +++++-------------- .../scanner/scanZone/PopupContent.jsx | 6 ++--- 2 files changed, 8 insertions(+), 20 deletions(-) rename src/{components/custom/AdvancedAccordion.jsx => features/scanner/scanZone/AdvAccordion.jsx} (72%) diff --git a/src/components/custom/AdvancedAccordion.jsx b/src/features/scanner/scanZone/AdvAccordion.jsx similarity index 72% rename from src/components/custom/AdvancedAccordion.jsx rename to src/features/scanner/scanZone/AdvAccordion.jsx index b9ee147de..22edc4fd0 100644 --- a/src/components/custom/AdvancedAccordion.jsx +++ b/src/features/scanner/scanZone/AdvAccordion.jsx @@ -1,10 +1,10 @@ -import React from 'react' +// @ts-check +import * as React from 'react' import ExpandMore from '@mui/icons-material/ExpandMore' import Accordion from '@mui/material/Accordion' import AccordionSummary from '@mui/material/AccordionSummary' import AccordionDetails from '@mui/material/AccordionDetails' import Typography from '@mui/material/Typography' -import Grid from '@mui/material/Grid' import { styled } from '@mui/material/styles' import { useTranslation } from 'react-i18next' @@ -34,27 +34,15 @@ const StyledAccordionSummary = styled(AccordionSummary)((/* { theme } */) => ({ }, })) -export default function AdvancedAccordion({ block = null, children }) { +/** @param {{ children: React.ReactNode }} props */ +export function AdvAccordion({ children }) { const { t } = useTranslation() return ( }> {t('advanced')} - - {block ? ( - - {block} - - ) : ( - children - )} - + {children} ) } diff --git a/src/features/scanner/scanZone/PopupContent.jsx b/src/features/scanner/scanZone/PopupContent.jsx index af91a5ab7..04c6a23a8 100644 --- a/src/features/scanner/scanZone/PopupContent.jsx +++ b/src/features/scanner/scanZone/PopupContent.jsx @@ -8,12 +8,12 @@ import Slider from '@mui/material/Slider' import { useTranslation } from 'react-i18next' import { debounce } from 'lodash' -import AdvancedAccordion from '@components/custom/AdvancedAccordion' import { RADIUS_CHOICES } from '@assets/constants' import { StyledSubHeader } from '../Shared' import { ConfigContext } from '../ContextProvider' import { useScanStore } from '../store' +import { AdvAccordion } from './AdvAccordion' /** * @@ -35,7 +35,7 @@ export function ScanZonePopup() { {advancedOptions && ( - + {t('scan_zone_radius')} - + )} From 3dad1d361e0c111f795bf3f5b25cebdf69a20d52 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sat, 2 Mar 2024 23:54:57 -0500 Subject: [PATCH 053/177] refactor: page builder feature --- packages/types/lib/config.d.ts | 89 ++++++++++++++++++- packages/types/lib/utility.d.ts | 4 +- .../services/functions/filterComponents.js | 2 +- src/components/dialogs/DonorPage.jsx | 8 +- src/components/dialogs/Motd.jsx | 8 +- .../builder}/CustomButton.jsx | 4 +- .../builder/CustomDialog.jsx} | 6 +- .../builder}/CustomText.jsx | 9 +- .../builder}/CustomTile.jsx | 4 +- .../custom => features/builder}/Generator.jsx | 32 ++++--- .../builder}/LinkWrapper.jsx | 2 +- src/features/builder/index.js | 2 + src/pages/login/CustomPage.jsx | 2 +- src/pages/playground/components/Viewer.jsx | 8 +- src/services/Utility.js | 2 +- 15 files changed, 132 insertions(+), 50 deletions(-) rename src/{components/custom => features/builder}/CustomButton.jsx (92%) rename src/{components/custom/DialogWrapper.jsx => features/builder/CustomDialog.jsx} (95%) rename src/{components/custom => features/builder}/CustomText.jsx (77%) rename src/{components/custom => features/builder}/CustomTile.jsx (86%) rename src/{components/custom => features/builder}/Generator.jsx (77%) rename src/{components/custom => features/builder}/LinkWrapper.jsx (96%) create mode 100644 src/features/builder/index.js diff --git a/packages/types/lib/config.d.ts b/packages/types/lib/config.d.ts index 212b0257c..ef651214d 100644 --- a/packages/types/lib/config.d.ts +++ b/packages/types/lib/config.d.ts @@ -1,10 +1,19 @@ import type { LogLevelNames } from 'loglevel' -import type { DialogProps } from '@mui/material' +import type { + ButtonProps, + DialogProps, + DividerProps, + Grid2Props, + SxProps, +} from '@mui/material' import config = require('server/src/configs/default.json') import example = require('server/src/configs/local.example.json') import type { Schema } from './server' +import { TypographyProps } from '@mui/system' +import { OnlyType } from './utility' +import { Props as ImgProps } from '@components/Img' type BaseConfig = typeof config type ExampleConfig = typeof example @@ -155,15 +164,87 @@ export interface Webhook { local: [] } -export interface CustomComponent { - type?: string - components?: CustomComponent[] +export interface GridSizes { + xs?: number + sm?: number + md?: number + lg?: number + xl?: number +} + +export interface BaseBlock { + gridSizes?: GridSizes + gridStyle?: React.CSSProperties + gridSx?: SxProps donorOnly?: boolean freeloaderOnly?: boolean loggedInOnly?: boolean loggedOutOnly?: boolean + text?: string | null + content?: string | null + link?: string | null + href?: string | null +} +export interface CustomText + extends Omit>, + BaseBlock { + type: 'text' +} + +export interface CustomDivider + extends Omit>, + BaseBlock { + type: 'divider' +} + +export interface CustomButton + extends Omit>, + BaseBlock { + type: 'button' +} + +export interface CustomImg extends ImgProps, BaseBlock { + type: 'img' +} + +export interface CustomDiscord extends BaseBlock { + type: 'discord' + link: string +} + +export interface CustomTelegram extends BaseBlock { + type: 'telegram' + telegramBotName: string + telegramAuthUrl: string +} + +export interface CustomLocal extends BaseBlock { + type: 'localLogin' + localAuthUrl: string + link: string + style: React.CSSProperties } +export interface CustomLocale extends BaseBlock { + type: 'localeSelection' +} + +export interface ParentBlock extends BaseBlock, Grid2Props { + type: 'parent' + components: CustomComponent[] +} + +export type CustomComponent = + | CustomText + | CustomDivider + | CustomButton + | CustomImg + | CustomDiscord + | CustomTelegram + | CustomLocal + | CustomLocale + | ParentBlock + export type DeepKeys = { [K in keyof T]-?: K extends string ? P extends '' diff --git a/packages/types/lib/utility.d.ts b/packages/types/lib/utility.d.ts index 34bf628fd..5fabda50b 100644 --- a/packages/types/lib/utility.d.ts +++ b/packages/types/lib/utility.d.ts @@ -13,7 +13,9 @@ export type SpecificValueType = { /* * OnlyType - returns a type with only the keys of T that have a value of U */ -export type OnlyType = { [k in SpecificValueType]: U } +export type OnlyType = { + [K in SpecificValueType]: T[K] +} export type StoreNoFn = keyof OnlyType diff --git a/server/src/services/functions/filterComponents.js b/server/src/services/functions/filterComponents.js index 774449934..d98df1e15 100644 --- a/server/src/services/functions/filterComponents.js +++ b/server/src/services/functions/filterComponents.js @@ -8,7 +8,7 @@ */ function filterComponents(components, loggedIn, donor) { return (Array.isArray(components) ? components : []).filter((component) => { - if (component.components) { + if ('components' in component) { return filterComponents(component.components, loggedIn, donor).length > 0 } if ( diff --git a/src/components/dialogs/DonorPage.jsx b/src/components/dialogs/DonorPage.jsx index a5957d551..89de3eb4f 100644 --- a/src/components/dialogs/DonorPage.jsx +++ b/src/components/dialogs/DonorPage.jsx @@ -7,9 +7,9 @@ import Dialog from '@mui/material/Dialog' import { CUSTOM_COMPONENT } from '@services/queries/config' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' +import { CustomDialog } from '@features/builder/CustomDialog' +import { CustomTile } from '@features/builder/CustomTile' -import DialogWrapper from '../custom/DialogWrapper' -import CustomTile from '../custom/CustomTile' import { Loading } from '../Loading' const DEFAULT = { @@ -37,7 +37,7 @@ export default function DonorPage() { return ( - )) )} - + ) } diff --git a/src/components/dialogs/Motd.jsx b/src/components/dialogs/Motd.jsx index 0c6fc8c47..da9c0936b 100644 --- a/src/components/dialogs/Motd.jsx +++ b/src/components/dialogs/Motd.jsx @@ -10,9 +10,9 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import { CUSTOM_COMPONENT, MOTD_CHECK } from '@services/queries/config' import Utility from '@services/Utility' +import { CustomDialog } from '@features/builder/CustomDialog' +import { CustomTile } from '@features/builder/CustomTile' -import DialogWrapper from '../custom/DialogWrapper' -import CustomTile from '../custom/CustomTile' import { Loading } from '../Loading' const DEFAULT = @@ -62,7 +62,7 @@ export default function MessageOfTheDay() { maxWidth={motd.dialogMaxWidth || 'sm'} onClose={handleMotdClose} > - )) )} - + ) } diff --git a/src/components/custom/CustomButton.jsx b/src/features/builder/CustomButton.jsx similarity index 92% rename from src/components/custom/CustomButton.jsx rename to src/features/builder/CustomButton.jsx index cef4709c4..f9ecf7fa8 100644 --- a/src/components/custom/CustomButton.jsx +++ b/src/features/builder/CustomButton.jsx @@ -1,7 +1,7 @@ import * as React from 'react' import Button from '@mui/material/Button' -import { I } from '../I' +import { I } from '@components/I' const THEME_COLORS = new Set([ 'success', @@ -14,7 +14,7 @@ const THEME_COLORS = new Set([ ]) /** @param {import('@mui/material').ButtonProps & { icon?: string }} */ -export default function CustomButton({ +export function CustomButton({ size, color = 'inherit', variant = 'text', diff --git a/src/components/custom/DialogWrapper.jsx b/src/features/builder/CustomDialog.jsx similarity index 95% rename from src/components/custom/DialogWrapper.jsx rename to src/features/builder/CustomDialog.jsx index f57304e67..96f8a3193 100644 --- a/src/components/custom/DialogWrapper.jsx +++ b/src/features/builder/CustomDialog.jsx @@ -5,10 +5,10 @@ import { useTranslation } from 'react-i18next' import Utility from '@services/Utility' -import Header from '../Header' -import Footer from '../Footer' +import Header from '@components/Header' +import Footer from '@components/Footer' -export default function DialogWrapper({ +export function CustomDialog({ configObj, defaultTitle, handleClose, diff --git a/src/components/custom/CustomText.jsx b/src/features/builder/CustomText.jsx similarity index 77% rename from src/components/custom/CustomText.jsx rename to src/features/builder/CustomText.jsx index 353a0a35b..a2ded8a4c 100644 --- a/src/components/custom/CustomText.jsx +++ b/src/features/builder/CustomText.jsx @@ -7,14 +7,7 @@ import Typography from '@mui/material/Typography' * @param {import('@mui/material').TypographyProps} props * @returns */ -export default function CustomText({ - className, - variant, - sx, - color, - style, - children, -}) { +export function CustomText({ className, variant, sx, color, style, children }) { return ( ) : ( diff --git a/src/components/custom/Generator.jsx b/src/features/builder/Generator.jsx similarity index 77% rename from src/components/custom/Generator.jsx rename to src/features/builder/Generator.jsx index ff0697083..48b2dece5 100644 --- a/src/components/custom/Generator.jsx +++ b/src/features/builder/Generator.jsx @@ -1,24 +1,28 @@ /* eslint-disable react/no-array-index-key */ -/* eslint-disable react/jsx-props-no-spreading */ import React from 'react' import Divider from '@mui/material/Divider' import Grid from '@mui/material/Unstable_Grid2' + import Utility from '@services/Utility' +import DiscordButton from '@components/auth/Discord' +import LocalLogin from '@components/auth/Local' +import Telegram from '@components/auth/Telegram' +import { Img } from '@components/Img' +import LocaleSelection from '@components/LocaleSelection' -import DiscordButton from '../auth/Discord' -import LocalLogin from '../auth/Local' -import Telegram from '../auth/Telegram' -import CustomText from './CustomText' -import CustomButton from './CustomButton' -import { Img } from '../Img' -import LocaleSelection from '../LocaleSelection' -import LinkWrapper from './LinkWrapper' +import { LinkWrapper } from './LinkWrapper' +import { CustomText } from './CustomText' +import { CustomButton } from './CustomButton' -export default function Generator({ block = {}, defaultReturn = null }) { - // eslint-disable-next-line no-unused-vars - const { content = null, text = null, gridSizes, ...props } = block +/** + * + * @param {{ block: import('@rm/types').CustomComponent, defaultReturn: React.ReactNode }} props + * @returns + */ +export function Generator({ block, defaultReturn = null }) { + const { content = null, text = null, gridSizes, type, ...props } = block const children = Utility.getBlockContent(content || text) - switch (block.type) { + switch (type) { case 'img': return ( @@ -61,7 +65,7 @@ export default function Generator({ block = {}, defaultReturn = null }) { return ( ) : ( - ( ))} - + )} diff --git a/src/services/Utility.js b/src/services/Utility.js index 1fbcd1ed1..7b4d1ceb7 100644 --- a/src/services/Utility.js +++ b/src/services/Utility.js @@ -93,7 +93,7 @@ export default class Utility { } /** - * @param {Record} sizeObj + * @param {import('@rm/types').GridSizes} sizeObj */ static getSizes = (sizeObj) => ({ xs: sizeObj?.xs || 12, From 832af9664ff55d6bc302541ae61cf393691ded27 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sun, 3 Mar 2024 00:02:06 -0500 Subject: [PATCH 054/177] refactor: holiday effects --- src/features/holiday/HolidayEffect.jsx | 50 +++++++++++++++++++++++ src/features/holiday/index.jsx | 55 +------------------------- 2 files changed, 51 insertions(+), 54 deletions(-) create mode 100644 src/features/holiday/HolidayEffect.jsx diff --git a/src/features/holiday/HolidayEffect.jsx b/src/features/holiday/HolidayEffect.jsx new file mode 100644 index 000000000..49e59e05d --- /dev/null +++ b/src/features/holiday/HolidayEffect.jsx @@ -0,0 +1,50 @@ +// @ts-check +import * as React from 'react' + +import { useStorage } from '@hooks/useStorage' + +import HolidayAnimations from './HolidayAnimations' + +/** + * + * @param {import("@rm/types").Config['map']['holidayEffects'][number]} props + * @returns + */ +export function HolidayEffect({ images, name, css, imageScale }) { + const userDisabled = useStorage((s) => s.holidayEffects[name] === true) + + React.useLayoutEffect(() => { + if (images?.length && !userDisabled) { + const animation = new HolidayAnimations(images, imageScale) + animation.initialize() + return () => { + animation.stop() + } + } + }, [userDisabled]) + + if (userDisabled) return null + + switch (css) { + case 'snow': + return ( +
+
+
+
+
+
+
+
+ ) + case 'fireworks': + return ( +
+
+
+
+ ) + default: + return null + } +} diff --git a/src/features/holiday/index.jsx b/src/features/holiday/index.jsx index c8e5e3f46..c1dd24a4b 100644 --- a/src/features/holiday/index.jsx +++ b/src/features/holiday/index.jsx @@ -1,61 +1,8 @@ // @ts-check import * as React from 'react' import { useMemory } from '@hooks/useMemory' -import { useStorage } from '@hooks/useStorage' -import HolidayAnimations from './HolidayAnimations' - -/** - * - * @param {import("@rm/types").Config['map']['holidayEffects'][number]} props - * @returns - */ -export function HolidayEffect({ images, name, css, imageScale }) { - const [element, setElement] = React.useState( - /** @type {React.ReactNode} */ (null), - ) - const userDisabled = useStorage((s) => s.holidayEffects[name] === true) - - React.useLayoutEffect(() => { - if (userDisabled) { - setElement(null) - return () => {} - } - switch (css) { - case 'snow': - setElement( -
-
-
-
-
-
-
-
, - ) - return () => setElement(null) - case 'fireworks': - setElement( -
-
-
-
, - ) - return () => setElement(null) - default: { - if (images?.length) { - const animation = new HolidayAnimations(images, imageScale) - animation.initialize() - return () => { - animation.stop() - } - } - } - } - }, [userDisabled]) - - return element -} +import { HolidayEffect } from './HolidayEffect' export default function HolidayEffects() { const holidayEffects = useMemory((s) => s?.config?.holidayEffects) From b5e823fdf547575b35489c6a0bcb8d62c770efce Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sun, 3 Mar 2024 15:35:42 -0500 Subject: [PATCH 055/177] refactor: shuffle things around in builder feature --- .../dialogs => features/builder}/DonorPage.jsx | 8 ++++---- .../CustomPage.jsx => features/builder/LoginPage.jsx} | 2 +- src/{components/dialogs => features/builder}/Motd.jsx | 8 ++++---- src/features/builder/{ => components}/CustomButton.jsx | 0 src/features/builder/{ => components}/CustomDialog.jsx | 0 src/features/builder/{ => components}/CustomText.jsx | 0 src/features/builder/{ => components}/CustomTile.jsx | 0 src/features/builder/{ => components}/Generator.jsx | 0 src/features/builder/{ => components}/LinkWrapper.jsx | 0 src/features/builder/index.js | 7 +++++-- src/pages/login/index.jsx | 2 +- src/pages/map/components/Nav.jsx | 4 ++-- src/pages/playground/components/Viewer.jsx | 3 +-- 13 files changed, 18 insertions(+), 16 deletions(-) rename src/{components/dialogs => features/builder}/DonorPage.jsx (86%) rename src/{pages/login/CustomPage.jsx => features/builder/LoginPage.jsx} (94%) rename src/{components/dialogs => features/builder}/Motd.jsx (92%) rename src/features/builder/{ => components}/CustomButton.jsx (100%) rename src/features/builder/{ => components}/CustomDialog.jsx (100%) rename src/features/builder/{ => components}/CustomText.jsx (100%) rename src/features/builder/{ => components}/CustomTile.jsx (100%) rename src/features/builder/{ => components}/Generator.jsx (100%) rename src/features/builder/{ => components}/LinkWrapper.jsx (100%) diff --git a/src/components/dialogs/DonorPage.jsx b/src/features/builder/DonorPage.jsx similarity index 86% rename from src/components/dialogs/DonorPage.jsx rename to src/features/builder/DonorPage.jsx index 89de3eb4f..2baa7f52d 100644 --- a/src/components/dialogs/DonorPage.jsx +++ b/src/features/builder/DonorPage.jsx @@ -7,10 +7,10 @@ import Dialog from '@mui/material/Dialog' import { CUSTOM_COMPONENT } from '@services/queries/config' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' -import { CustomDialog } from '@features/builder/CustomDialog' -import { CustomTile } from '@features/builder/CustomTile' +import { Loading } from '@components/Loading' -import { Loading } from '../Loading' +import { CustomDialog } from './components/CustomDialog' +import { CustomTile } from './components/CustomTile' const DEFAULT = { settings: {}, @@ -21,7 +21,7 @@ const DEFAULT = { const handleClose = () => useLayoutStore.setState({ donorPage: false }) -export default function DonorPage() { +export function DonorPage() { const open = useLayoutStore((s) => s.donorPage) const isMobile = useMemory((s) => s.isMobile) diff --git a/src/pages/login/CustomPage.jsx b/src/features/builder/LoginPage.jsx similarity index 94% rename from src/pages/login/CustomPage.jsx rename to src/features/builder/LoginPage.jsx index f7ce8105b..366ae5ff0 100644 --- a/src/pages/login/CustomPage.jsx +++ b/src/features/builder/LoginPage.jsx @@ -6,7 +6,7 @@ import Grid from '@mui/material/Unstable_Grid2' import { useQuery } from '@apollo/client' import { CUSTOM_COMPONENT } from '@services/queries/config' -import { CustomTile } from '@features/builder/CustomTile' +import { CustomTile } from '@features/builder/components/CustomTile' import { Loading } from '@components/Loading' export function CustomLoginPage() { diff --git a/src/components/dialogs/Motd.jsx b/src/features/builder/Motd.jsx similarity index 92% rename from src/components/dialogs/Motd.jsx rename to src/features/builder/Motd.jsx index da9c0936b..b8b208718 100644 --- a/src/components/dialogs/Motd.jsx +++ b/src/features/builder/Motd.jsx @@ -10,10 +10,10 @@ import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' import { CUSTOM_COMPONENT, MOTD_CHECK } from '@services/queries/config' import Utility from '@services/Utility' -import { CustomDialog } from '@features/builder/CustomDialog' -import { CustomTile } from '@features/builder/CustomTile' +import { CustomDialog } from '@features/builder/components/CustomDialog' +import { CustomTile } from '@features/builder/components/CustomTile' -import { Loading } from '../Loading' +import { Loading } from '../../components/Loading' const DEFAULT = /** @type {import('@rm/types').Config['map']['messageOfTheDay']} */ ({ @@ -24,7 +24,7 @@ const DEFAULT = index: 0, }) -export default function MessageOfTheDay() { +export function MessageOfTheDay() { const clientIndex = useStorage((s) => s.motdIndex) const tutorial = useStorage((s) => s.tutorial) diff --git a/src/features/builder/CustomButton.jsx b/src/features/builder/components/CustomButton.jsx similarity index 100% rename from src/features/builder/CustomButton.jsx rename to src/features/builder/components/CustomButton.jsx diff --git a/src/features/builder/CustomDialog.jsx b/src/features/builder/components/CustomDialog.jsx similarity index 100% rename from src/features/builder/CustomDialog.jsx rename to src/features/builder/components/CustomDialog.jsx diff --git a/src/features/builder/CustomText.jsx b/src/features/builder/components/CustomText.jsx similarity index 100% rename from src/features/builder/CustomText.jsx rename to src/features/builder/components/CustomText.jsx diff --git a/src/features/builder/CustomTile.jsx b/src/features/builder/components/CustomTile.jsx similarity index 100% rename from src/features/builder/CustomTile.jsx rename to src/features/builder/components/CustomTile.jsx diff --git a/src/features/builder/Generator.jsx b/src/features/builder/components/Generator.jsx similarity index 100% rename from src/features/builder/Generator.jsx rename to src/features/builder/components/Generator.jsx diff --git a/src/features/builder/LinkWrapper.jsx b/src/features/builder/components/LinkWrapper.jsx similarity index 100% rename from src/features/builder/LinkWrapper.jsx rename to src/features/builder/components/LinkWrapper.jsx diff --git a/src/features/builder/index.js b/src/features/builder/index.js index f3d326f97..efd07a51f 100644 --- a/src/features/builder/index.js +++ b/src/features/builder/index.js @@ -1,2 +1,5 @@ -export * from './CustomTile' -export * from './CustomDialog' +export * from './DonorPage' +export * from './Motd' +export * from './LoginPage' +export * from './components/CustomTile' +export * from './components/CustomDialog' diff --git a/src/pages/login/index.jsx b/src/pages/login/index.jsx index d9a1f38b1..564af74bf 100644 --- a/src/pages/login/index.jsx +++ b/src/pages/login/index.jsx @@ -5,8 +5,8 @@ import Box from '@mui/material/Box' import { useMemory } from '@hooks/useMemory' import ThemeToggle from '@components/ThemeToggle' +import { CustomLoginPage } from '@features/builder/LoginPage' -import { CustomLoginPage } from './CustomPage' import { DefaultLoginPage } from './DefaultPage' export default function LoginPage() { diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index fe91f016f..49f6325f6 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -8,8 +8,8 @@ import UserOptions from '@components/dialogs/UserOptions' import Tutorial from '@features/tutorial' import UserProfile from '@features/profile' import Search from '@features/search' -import MessageOfTheDay from '@components/dialogs/Motd' -import DonorPage from '@components/dialogs/DonorPage' +import MessageOfTheDay from '@features/builder/Motd' +import DonorPage from '@features/builder/DonorPage' import Feedback from '@components/dialogs/Feedback' import ResetFilters from '@components/dialogs/ResetFilters' import ScanDialog from '@features/scanner/ScanDialog' diff --git a/src/pages/playground/components/Viewer.jsx b/src/pages/playground/components/Viewer.jsx index b83877d48..1b1a3f1f4 100644 --- a/src/pages/playground/components/Viewer.jsx +++ b/src/pages/playground/components/Viewer.jsx @@ -4,8 +4,7 @@ import * as React from 'react' import Grid from '@mui/material/Unstable_Grid2' import { useTranslation } from 'react-i18next' -import CustomTile from '@features/builder/CustomTile' -import CustomDialog from '@features/builder/CustomDialog' +import { CustomTile, CustomDialog } from '@features/builder' import ErrorBoundary from '@components/ErrorBoundary' import { useSafeParse } from '../hooks/useSafeParse' From ed65bc059e63c93afa31cf4d84edc9782230c4d8 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sun, 3 Mar 2024 15:45:53 -0500 Subject: [PATCH 056/177] fix: some clipped imports --- src/App.jsx | 2 +- src/components/ErrorBoundary.jsx | 3 +-- .../builder/components/CustomTile.jsx | 1 - src/features/drawer/Extras.jsx | 2 +- src/features/drawer/SelectorList.jsx | 1 - src/features/pokestop/usePokestopMarker.js | 3 +-- src/features/webhooks/Tracked.jsx | 2 +- .../webhooks/human/area/AreaSelection.jsx | 4 ++-- .../webhooks/{Webhook.jsx => index.jsx} | 0 src/pages/map/components/Nav.jsx | 20 +++++++++---------- 10 files changed, 17 insertions(+), 21 deletions(-) rename src/features/webhooks/{Webhook.jsx => index.jsx} (100%) diff --git a/src/App.jsx b/src/App.jsx index 2691adf86..faaff8db4 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -6,7 +6,7 @@ import 'leaflet/dist/leaflet.css' import * as React from 'react' import { BrowserRouter } from 'react-router-dom' import CssBaseline from '@mui/material/CssBaseline' -import { ThemeProvider } from '@mui/material/styles' +import ThemeProvider from '@mui/material/styles/ThemeProvider' import { ApolloProvider } from '@apollo/client' import useCustomTheme from '@assets/theme' diff --git a/src/components/ErrorBoundary.jsx b/src/components/ErrorBoundary.jsx index 11675262c..9a82cff88 100644 --- a/src/components/ErrorBoundary.jsx +++ b/src/components/ErrorBoundary.jsx @@ -1,6 +1,5 @@ -/* eslint-disable no-bitwise */ // @ts-check -/* eslint-disable no-console */ +/* eslint-disable no-bitwise */ /* eslint-disable react/destructuring-assignment */ import * as React from 'react' import Grid from '@mui/material/Grid' diff --git a/src/features/builder/components/CustomTile.jsx b/src/features/builder/components/CustomTile.jsx index 3c5d2cf94..99349c7bb 100644 --- a/src/features/builder/components/CustomTile.jsx +++ b/src/features/builder/components/CustomTile.jsx @@ -1,5 +1,4 @@ // @ts-check -/* eslint-disable react/jsx-props-no-spreading */ import * as React from 'react' import Grid from '@mui/material/Unstable_Grid2' diff --git a/src/features/drawer/Extras.jsx b/src/features/drawer/Extras.jsx index 0bb390866..022ba083d 100644 --- a/src/features/drawer/Extras.jsx +++ b/src/features/drawer/Extras.jsx @@ -1,6 +1,6 @@ +// @ts-check /* eslint-disable no-fallthrough */ /* eslint-disable default-case */ -// @ts-check import * as React from 'react' import Box from '@mui/material/Box' import ListItem from '@mui/material/ListItem' diff --git a/src/features/drawer/SelectorList.jsx b/src/features/drawer/SelectorList.jsx index 1de5252fa..708d73be2 100644 --- a/src/features/drawer/SelectorList.jsx +++ b/src/features/drawer/SelectorList.jsx @@ -1,4 +1,3 @@ -/* eslint-disable no-fallthrough */ // @ts-check import * as React from 'react' import TuneIcon from '@mui/icons-material/Tune' diff --git a/src/features/pokestop/usePokestopMarker.js b/src/features/pokestop/usePokestopMarker.js index 4154f5acf..e9ca643ce 100644 --- a/src/features/pokestop/usePokestopMarker.js +++ b/src/features/pokestop/usePokestopMarker.js @@ -1,5 +1,4 @@ // @ts-check -/* eslint-disable no-nested-ternary */ import { divIcon } from 'leaflet' import { basicEqualFn, useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' @@ -42,7 +41,7 @@ export function usePokestopMarker({ hasInvasion, hasQuest && userSettings.pokestops.hasQuestIndicator, ar_scan_eligible && - (userSettings.pokestops.showArBadge || power_up_level), + (userSettings.pokestops.showArBadge || !!power_up_level), power_up_level, hasEvent ? Math.max(...events.map((event) => event.display_type)).toString() diff --git a/src/features/webhooks/Tracked.jsx b/src/features/webhooks/Tracked.jsx index 983447222..09034f9d4 100644 --- a/src/features/webhooks/Tracked.jsx +++ b/src/features/webhooks/Tracked.jsx @@ -1,5 +1,5 @@ -/* eslint-disable react/no-unstable-nested-components */ // @ts-check +/* eslint-disable react/no-unstable-nested-components */ import * as React from 'react' import { useTranslation } from 'react-i18next' import { Virtuoso } from 'react-virtuoso' diff --git a/src/features/webhooks/human/area/AreaSelection.jsx b/src/features/webhooks/human/area/AreaSelection.jsx index a9cd8bffc..9fea47b8e 100644 --- a/src/features/webhooks/human/area/AreaSelection.jsx +++ b/src/features/webhooks/human/area/AreaSelection.jsx @@ -3,9 +3,9 @@ import * as React from 'react' import { useQuery } from '@apollo/client' import { useTranslation } from 'react-i18next' +import { ScanAreaTile } from '@features/scanArea' import { WEBHOOK_GEOJSON } from '@services/queries/webhook' import { Loading } from '@components/Loading' -import MemoScanArea from '@features/scanArea/ScanAreaTile' import { useWebhookStore } from '../../store' @@ -36,7 +36,7 @@ export default function WebhookAreaSelection() { return {t('loading', { category: t('areas') })} } if (webhookMode === 'areas' && data?.webhookGeojson) { - return + return } return null } diff --git a/src/features/webhooks/Webhook.jsx b/src/features/webhooks/index.jsx similarity index 100% rename from src/features/webhooks/Webhook.jsx rename to src/features/webhooks/index.jsx diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index 49f6325f6..12ffb2f8b 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -1,27 +1,27 @@ +// @ts-check import * as React from 'react' -import { useMemory } from '@hooks/useMemory' - -import Drawer from '@features/drawer' -import FilterMenu from '@components/dialogs/filters/FilterMenu' -import UserOptions from '@components/dialogs/UserOptions' import Tutorial from '@features/tutorial' import UserProfile from '@features/profile' +import Drawer from '@features/drawer' import Search from '@features/search' -import MessageOfTheDay from '@features/builder/Motd' -import DonorPage from '@features/builder/DonorPage' +import Webhook from '@features/webhooks' +import { DonorPage, MessageOfTheDay } from '@features/builder' +import ScanDialog from '@features/scanner/ScanDialog' +import { WebhookNotification } from '@features/webhooks/Notification' import Feedback from '@components/dialogs/Feedback' +import FilterMenu from '@components/dialogs/filters/FilterMenu' +import UserOptions from '@components/dialogs/UserOptions' import ResetFilters from '@components/dialogs/ResetFilters' -import ScanDialog from '@features/scanner/ScanDialog' -import Webhook from '@features/webhooks/Webhook' import ClientError from '@components/dialogs/ClientError' -import { WebhookNotification } from '@features/webhooks/Notification' import AdvancedFilter from '@components/dialogs/filters/Advanced' import BadgeSelection from '@components/dialogs/BadgeSelection' import WebhookAdvanced from '@features/webhooks/WebhookAdv' import SlotSelection from '@components/dialogs/filters/SlotSelection' import { HelpDialog } from '@components/dialogs/Help' import { PkmnFilterHelp } from '@components/dialogs/filters/PkmnFilterHelp' +import { useMemory } from '@hooks/useMemory' + import { FloatingButtonsMemo } from './FloatingBtn' export const Nav = React.memo( From 1fc124c4dc7eb241d4c9507e5cd97ee36996389e Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sun, 3 Mar 2024 15:48:45 -0500 Subject: [PATCH 057/177] refactor: all scanner feature imports --- src/components/Config.jsx | 2 +- src/features/scanner/ScanDialog.jsx | 2 +- src/features/scanner/{index.jsx => ScanOnDemand.jsx} | 8 +++----- src/features/scanner/index.js | 3 +++ src/pages/map/components/Container.jsx | 2 +- src/pages/map/components/FloatingBtn.jsx | 2 +- src/pages/map/components/Nav.jsx | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) rename src/features/scanner/{index.jsx => ScanOnDemand.jsx} (97%) create mode 100644 src/features/scanner/index.js diff --git a/src/components/Config.jsx b/src/components/Config.jsx index 95085790c..84267e403 100644 --- a/src/components/Config.jsx +++ b/src/components/Config.jsx @@ -12,7 +12,7 @@ import { deepMerge } from '@utils/deepMerge' import { checkHoliday } from '@utils/checkHoliday' import { useHideElement } from '@hooks/useHideElement' import { getGlowRules } from '@utils/getGlowRules' -import { useScannerSessionStorage } from '@features/scanner/store' +import { useScannerSessionStorage } from '@features/scanner' export default function Config({ children }) { const { t } = useTranslation() diff --git a/src/features/scanner/ScanDialog.jsx b/src/features/scanner/ScanDialog.jsx index 67b58c69f..d3c9cac31 100644 --- a/src/features/scanner/ScanDialog.jsx +++ b/src/features/scanner/ScanDialog.jsx @@ -13,7 +13,7 @@ import { useScanStore } from './store' const { setScanMode } = useScanStore.getState() -export default function ScanDialog() { +export function ScanDialog() { const { t } = useTranslation() const scanNext = useScanStore((s) => s.scanNextMode) const scanZone = useScanStore((s) => s.scanZoneMode) diff --git a/src/features/scanner/index.jsx b/src/features/scanner/ScanOnDemand.jsx similarity index 97% rename from src/features/scanner/index.jsx rename to src/features/scanner/ScanOnDemand.jsx index c3b401d79..ed2cc78fb 100644 --- a/src/features/scanner/index.jsx +++ b/src/features/scanner/ScanOnDemand.jsx @@ -21,7 +21,7 @@ const { setScanMode } = useScanStore.getState() * @param {{ mode: 'scanNext' | 'scanZone' }} props * @returns {JSX.Element} */ -function ScanOnDemand({ mode }) { +function BaseScanOnDemand({ mode }) { const scanMode = useScanStore((s) => s[`${mode}Mode`]) const location = useStorage((s) => s.location) const online = useMemory((s) => s.online) @@ -156,9 +156,7 @@ function ScanOnDemand({ mode }) { ) } -const MemoizedScanOnDemand = React.memo( - ScanOnDemand, +export const ScanOnDemand = React.memo( + BaseScanOnDemand, (prev, next) => prev.mode === next.mode, ) - -export default MemoizedScanOnDemand diff --git a/src/features/scanner/index.js b/src/features/scanner/index.js new file mode 100644 index 000000000..3c2f202f8 --- /dev/null +++ b/src/features/scanner/index.js @@ -0,0 +1,3 @@ +export * from './ScanDialog' +export * from './ScanOnDemand' +export * from './store' diff --git a/src/pages/map/components/Container.jsx b/src/pages/map/components/Container.jsx index c2fa2c264..f98ab9f61 100644 --- a/src/pages/map/components/Container.jsx +++ b/src/pages/map/components/Container.jsx @@ -7,7 +7,7 @@ import { useStorage } from '@hooks/useStorage' import { useMapStore } from '@hooks/useMapStore' import Utility from '@services/Utility' -import ScanOnDemand from '@features/scanner' +import { ScanOnDemand } from '@features/scanner' import DraggableMarker from '@features/webhooks/human/Draggable' import WebhookAreaSelection from '@features/webhooks/human/area/AreaSelection' import { ActiveWeather } from '@features/weather' diff --git a/src/pages/map/components/FloatingBtn.jsx b/src/pages/map/components/FloatingBtn.jsx index a097f9cbb..dca29068e 100644 --- a/src/pages/map/components/FloatingBtn.jsx +++ b/src/pages/map/components/FloatingBtn.jsx @@ -29,7 +29,7 @@ import useLocation from '@hooks/useLocation' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useStorage } from '@hooks/useStorage' -import { useScanStore } from '@features/scanner/store' +import { useScanStore } from '@features/scanner' import { I } from '@components/I' import { setModeBtn, useWebhookStore } from '@features/webhooks/store' diff --git a/src/pages/map/components/Nav.jsx b/src/pages/map/components/Nav.jsx index 12ffb2f8b..0e0191264 100644 --- a/src/pages/map/components/Nav.jsx +++ b/src/pages/map/components/Nav.jsx @@ -7,7 +7,7 @@ import Drawer from '@features/drawer' import Search from '@features/search' import Webhook from '@features/webhooks' import { DonorPage, MessageOfTheDay } from '@features/builder' -import ScanDialog from '@features/scanner/ScanDialog' +import { ScanDialog } from '@features/scanner' import { WebhookNotification } from '@features/webhooks/Notification' import Feedback from '@components/dialogs/Feedback' import FilterMenu from '@components/dialogs/filters/FilterMenu' From 6cd941d14f0ce7d9f955a5d8f901a84ce9d00a69 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Sun, 3 Mar 2024 22:44:09 -0500 Subject: [PATCH 058/177] refactor: normalize webhook feature imports --- src/components/Menu.jsx | 5 +- src/features/drawer/SelectorItem.jsx | 50 +---- src/features/gym/GymPopup.jsx | 2 +- src/features/scanArea/ScanAreaTile.jsx | 45 ++-- src/features/scanner/ContextProvider.jsx | 2 +- src/features/scanner/Marker.jsx | 2 +- src/features/scanner/Popup.jsx | 2 +- src/features/scanner/ScanDialog.jsx | 2 +- src/features/scanner/ScanOnDemand.jsx | 2 +- src/features/scanner/Shared.jsx | 6 +- src/features/scanner/{ => hooks}/store.js | 0 .../scanner/{ => hooks}/useCheckValid.js | 2 +- src/features/scanner/index.js | 3 +- .../scanner/scanNext/PopupContent.jsx | 2 +- src/features/scanner/scanNext/getCoords.js | 4 +- src/features/scanner/scanNext/index.jsx | 4 +- .../scanner/scanZone/PopupContent.jsx | 4 +- src/features/scanner/scanZone/getCoords.js | 2 +- src/features/scanner/scanZone/index.jsx | 2 +- src/features/webhooks/Error.jsx | 2 +- src/features/webhooks/Manage.jsx | 15 +- src/features/webhooks/Notification.jsx | 2 +- src/features/webhooks/Selecting.jsx | 2 +- src/features/webhooks/Tracked.jsx | 6 +- .../webhooks/{index.jsx => Webhook.jsx} | 4 +- src/features/webhooks/WebhookAdv.jsx | 9 +- src/features/webhooks/{ => hooks}/store.js | 0 .../{hooks.js => hooks/useGenFilters.js} | 201 +----------------- src/features/webhooks/hooks/useGetAreas.js | 15 ++ .../webhooks/hooks/useGetHookContext.js | 31 +++ .../webhooks/hooks/useGetWebhookData.js | 101 +++++++++ src/features/webhooks/hooks/useSyncData.js | 31 +++ src/features/webhooks/human/Draggable.jsx | 4 +- src/features/webhooks/human/Location.jsx | 4 +- src/features/webhooks/human/area/AreaChip.jsx | 2 +- .../webhooks/human/area/AreaGroup.jsx | 2 +- .../webhooks/human/area/AreaSelection.jsx | 13 +- src/features/webhooks/human/area/Selected.jsx | 2 +- src/features/webhooks/human/area/index.jsx | 2 +- .../webhooks/human/profile/ActiveHourChip.jsx | 2 +- .../webhooks/human/profile/CopyView.jsx | 2 +- .../webhooks/human/profile/DeleteVIew.jsx | 2 +- .../webhooks/human/profile/EditView.jsx | 2 +- .../webhooks/human/profile/NewProfile.jsx | 2 +- .../webhooks/human/profile/ProfileTile.jsx | 1 + .../webhooks/human/profile/ProfileView.jsx | 2 +- src/features/webhooks/human/profile/index.jsx | 2 +- .../webhooks/human/status/EnableSwitch.jsx | 2 +- .../webhooks/human/status/HookSelection.jsx | 4 +- .../webhooks/human/status/ProfileSelect.jsx | 2 +- src/features/webhooks/human/status/index.jsx | 2 +- src/features/webhooks/index.js | 9 + .../webhooks}/services/Poracle.js | 6 +- src/features/webhooks/tiles/TrackedTile.jsx | 4 +- src/features/webhooks/tiles/WebhookItem.jsx | 45 ++++ src/hooks/useWebhook.js | 2 +- src/pages/map/components/Container.jsx | 5 +- src/pages/map/components/FloatingBtn.jsx | 5 +- src/pages/map/components/Nav.jsx | 8 +- 59 files changed, 358 insertions(+), 340 deletions(-) rename src/features/scanner/{ => hooks}/store.js (100%) rename src/features/scanner/{ => hooks}/useCheckValid.js (95%) rename src/features/webhooks/{index.jsx => Webhook.jsx} (84%) rename src/features/webhooks/{ => hooks}/store.js (100%) rename src/features/webhooks/{hooks.js => hooks/useGenFilters.js} (55%) create mode 100644 src/features/webhooks/hooks/useGetAreas.js create mode 100644 src/features/webhooks/hooks/useGetHookContext.js create mode 100644 src/features/webhooks/hooks/useGetWebhookData.js create mode 100644 src/features/webhooks/hooks/useSyncData.js create mode 100644 src/features/webhooks/index.js rename src/{ => features/webhooks}/services/Poracle.js (98%) create mode 100644 src/features/webhooks/tiles/WebhookItem.jsx diff --git a/src/components/Menu.jsx b/src/components/Menu.jsx index 81766e76d..afea19cd4 100644 --- a/src/components/Menu.jsx +++ b/src/components/Menu.jsx @@ -19,7 +19,10 @@ import useGetAvailable from '@hooks/useGetAvailable' import OptionsContainer from './dialogs/filters/OptionsContainer' import { VirtualGrid } from './VirtualGrid' import { GenericSearch } from '../features/drawer/ItemSearch' -import { applyToAllWebhooks, useWebhookStore } from '../features/webhooks/store' +import { + applyToAllWebhooks, + useWebhookStore, +} from '../features/webhooks/hooks/store' /** * @template {import('@rm/types').AdvCategories} T diff --git a/src/features/drawer/SelectorItem.jsx b/src/features/drawer/SelectorItem.jsx index 96dd9e696..f9c337860 100644 --- a/src/features/drawer/SelectorItem.jsx +++ b/src/features/drawer/SelectorItem.jsx @@ -10,13 +10,10 @@ import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { useDeepStore, useStorage } from '@hooks/useStorage' import { checkIfHasAll } from '@utils/hasAll' -import Poracle from '@services/Poracle' import { ColoredTile } from '@components/ColoredTile' import { ToggleTypography } from '@components/ToggleTypography' import { SQUARE_ITEM } from '@components/VirtualGrid' -import { useWebhookStore } from '../webhooks/store' - /** * @template {string} T * @typedef {{ @@ -69,46 +66,15 @@ export function StandardItem({ id, category, ...props }) { ) } -/** @param {BaseProps} props */ -export function WebhookItem({ id, category, ...props }) { - const filter = useWebhookStore((s) => s.tempFilters[id]) - - const setFilter = (newFilter) => { - useWebhookStore.setState((prev) => ({ - tempFilters: { - ...prev.tempFilters, - [id]: newFilter - ? { - ...newFilter, - enabled: newFilter.enabled, - } - : { enabled: true, ...Poracle.getOtherData(id) }, - }, - })) - } - return ( - - useWebhookStore.setState({ - advanced: { - id, - uid: 0, - open: true, - category, - selectedIds: [], - }, - }) - } - /> - ) -} - /** @param {FullProps} props */ -function SelectorItem({ id, filter, setFilter, onClick, hasAll, easyMode }) { +export function SelectorItem({ + id, + filter, + setFilter, + onClick, + hasAll, + easyMode, +}) { const { t } = useTranslateById({ alt: true, newLine: true }) const title = t(id) const url = useMemory((s) => s.Icons.getIconById(id)) diff --git a/src/features/gym/GymPopup.jsx b/src/features/gym/GymPopup.jsx index bd0e6e265..490131c3c 100644 --- a/src/features/gym/GymPopup.jsx +++ b/src/features/gym/GymPopup.jsx @@ -11,7 +11,7 @@ import Collapse from '@mui/material/Collapse' import Typography from '@mui/material/Typography' import { useTranslation } from 'react-i18next' -import { useSyncData } from '@features/webhooks/hooks' +import { useSyncData } from '@features/webhooks' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' import { setDeepStore, useStorage } from '@hooks/useStorage' diff --git a/src/features/scanArea/ScanAreaTile.jsx b/src/features/scanArea/ScanAreaTile.jsx index fca20cb47..25af26f87 100644 --- a/src/features/scanArea/ScanAreaTile.jsx +++ b/src/features/scanArea/ScanAreaTile.jsx @@ -1,34 +1,35 @@ -/* eslint-disable react/destructuring-assignment */ // @ts-check +/* eslint-disable react/destructuring-assignment */ import * as React from 'react' import { GeoJSON } from 'react-leaflet' +import { Polygon } from 'leaflet' +import { useWebhookStore } from '@features/webhooks/hooks/store' import { useStorage } from '@hooks/useStorage' import Utility from '@services/Utility' -import { useWebhookStore } from '@features/webhooks/store' -import { handleClick } from '@features/webhooks/human/area/AreaChip' -import { Polygon } from 'leaflet' /** * - * @param {import('@rm/types').RMGeoJSON} featureCollection + * @param {{ + * geojson: import('@rm/types').RMGeoJSON, + * webhook?: boolean, + * handleClick?: (name: string) => () => Promise + * }} featureCollection * @returns */ -function ScanArea(featureCollection) { +function ScanArea({ geojson, webhook, handleClick }) { const search = useStorage((s) => s.filters.scanAreas?.filter?.search) const tapToToggle = useStorage((s) => s.userSettings.scanAreas.tapToToggle) const alwaysShowLabels = useStorage( (s) => s.userSettings.scanAreas.alwaysShowLabels, ) - const webhookMode = useWebhookStore((s) => s.mode) - return ( - webhookMode || + webhook || search === '' || f.properties.key.toLowerCase().includes(search.toLowerCase()) } @@ -36,7 +37,7 @@ function ScanArea(featureCollection) { click: ({ propagatedFrom: layer }) => { if (!layer.feature) return const { name, key, manual = false } = layer.feature.properties - if (webhookMode && name) { + if (webhook && name) { handleClick(name)().then((newAreas) => { layer.setStyle({ fillOpacity: newAreas.some( @@ -52,7 +53,7 @@ function ScanArea(featureCollection) { layer.setStyle({ fillOpacity: includes ? 0.2 : 0.8 }) setAreas( key, - featureCollection.features + geojson.features .filter((f) => !f.properties.manual) .map((f) => f.properties.key), ) @@ -77,7 +78,7 @@ function ScanArea(featureCollection) { feature.properties.fill || '#3388ff', fillOpacity: ( - webhookMode === 'areas' + webhook ? useWebhookStore .getState() .human?.area?.some( @@ -86,13 +87,13 @@ function ScanArea(featureCollection) { : ( useStorage.getState().filters?.scanAreas?.filter ?.areas || [] - ).includes(webhookMode ? name : key) + ).includes(webhook ? name : key) ) ? 0.8 : 0.2, }) .bindTooltip(popupContent, { - permanent: webhookMode ? true : alwaysShowLabels, + permanent: webhook ? true : alwaysShowLabels, direction: 'top', className: 'area-tooltip', }) @@ -106,8 +107,14 @@ function ScanArea(featureCollection) { ) } -export const ScanAreaTile = React.memo(ScanArea, (prev, next) => - prev.features.every( - (feat, i) => feat.properties.key === next.features[i].properties.key, - ), +export const ScanAreaTile = React.memo( + ScanArea, + (prev, next) => + prev.webhook === next.webhook && + prev.handleClick === next.handleClick && + prev.geojson.features.length === next.geojson.features.length && + prev.geojson.features.every( + (feat, i) => + feat.properties.key === next.geojson.features[i].properties.key, + ), ) diff --git a/src/features/scanner/ContextProvider.jsx b/src/features/scanner/ContextProvider.jsx index 509c40bf0..bb89597b5 100644 --- a/src/features/scanner/ContextProvider.jsx +++ b/src/features/scanner/ContextProvider.jsx @@ -1,7 +1,7 @@ // @ts-check import { createContext } from 'react' -export const DEFAULT = /** @type {import('./store').ScanConfig} */ ({ +export const DEFAULT = /** @type {import('./hooks/store').ScanConfig} */ ({ scannerType: '', showScanCount: false, showScanQueue: false, diff --git a/src/features/scanner/Marker.jsx b/src/features/scanner/Marker.jsx index 31a460a71..875c6df5d 100644 --- a/src/features/scanner/Marker.jsx +++ b/src/features/scanner/Marker.jsx @@ -3,7 +3,7 @@ import * as React from 'react' import { Marker, useMap } from 'react-leaflet' import fallbackIcon from '@assets/fallbackMarker' -import { useScanStore } from './store' +import { useScanStore } from './hooks/store' /** * @param {{ children: React.ReactNode }} props diff --git a/src/features/scanner/Popup.jsx b/src/features/scanner/Popup.jsx index abd00af17..4fcd65e49 100644 --- a/src/features/scanner/Popup.jsx +++ b/src/features/scanner/Popup.jsx @@ -18,7 +18,7 @@ import { ConfigContext } from './ContextProvider' /** * - * @param {{ children: React.ReactNode, mode: import('./store').ScanMode }} props + * @param {{ children: React.ReactNode, mode: import('./hooks/store').ScanMode }} props * @returns */ export function ScanOnDemandPopup({ children, mode }) { diff --git a/src/features/scanner/ScanDialog.jsx b/src/features/scanner/ScanDialog.jsx index d3c9cac31..ab400ce4e 100644 --- a/src/features/scanner/ScanDialog.jsx +++ b/src/features/scanner/ScanDialog.jsx @@ -9,7 +9,7 @@ import Header from '@components/Header' import Footer from '@components/Footer' import { SCAN_MODES } from '@assets/constants' -import { useScanStore } from './store' +import { useScanStore } from './hooks/store' const { setScanMode } = useScanStore.getState() diff --git a/src/features/scanner/ScanOnDemand.jsx b/src/features/scanner/ScanOnDemand.jsx index ed2cc78fb..3f993f169 100644 --- a/src/features/scanner/ScanOnDemand.jsx +++ b/src/features/scanner/ScanOnDemand.jsx @@ -12,7 +12,7 @@ import ScanZone from './scanZone' import { getScanNextCoords } from './scanNext/getCoords' import { getScanZoneCoords } from './scanZone/getCoords' import { ConfigContext, DEFAULT } from './ContextProvider' -import { useScanStore, useScannerSessionStorage } from './store' +import { useScanStore, useScannerSessionStorage } from './hooks/store' const { setScanMode } = useScanStore.getState() diff --git a/src/features/scanner/Shared.jsx b/src/features/scanner/Shared.jsx index ec3d35f25..de9fad610 100644 --- a/src/features/scanner/Shared.jsx +++ b/src/features/scanner/Shared.jsx @@ -12,7 +12,7 @@ import { Circle } from 'react-leaflet' import PermScanWifiIcon from '@mui/icons-material/PermScanWifi' import ClearIcon from '@mui/icons-material/Clear' -import { useScanStore, useScannerSessionStorage } from './store' +import { useScanStore, useScannerSessionStorage } from './hooks/store' const StyledListItem = styled(ListItem)(() => ({ padding: '2px 16px', @@ -63,7 +63,7 @@ export function ScanQueue() { /** * - * @param {{ mode: import('./store').ScanMode }} props + * @param {{ mode: import('./hooks/store').ScanMode }} props * @returns */ export function ScanConfirm({ mode }) { @@ -123,7 +123,7 @@ export function InAllowedArea() { /** * - * @param {{ mode: import('./store').ScanMode}} props + * @param {{ mode: import('./hooks/store').ScanMode}} props * @returns */ export function ScanCancel({ mode }) { diff --git a/src/features/scanner/store.js b/src/features/scanner/hooks/store.js similarity index 100% rename from src/features/scanner/store.js rename to src/features/scanner/hooks/store.js diff --git a/src/features/scanner/useCheckValid.js b/src/features/scanner/hooks/useCheckValid.js similarity index 95% rename from src/features/scanner/useCheckValid.js rename to src/features/scanner/hooks/useCheckValid.js index 4e1ff0c14..f72ef9e6f 100644 --- a/src/features/scanner/useCheckValid.js +++ b/src/features/scanner/hooks/useCheckValid.js @@ -2,7 +2,7 @@ import { useQuery } from '@apollo/client' import { CHECK_VALID_SCAN } from '@services/queries/scanner' import { useContext, useEffect } from 'react' -import { ConfigContext } from './ContextProvider' +import { ConfigContext } from '../ContextProvider' import { useScanStore } from './store' /** diff --git a/src/features/scanner/index.js b/src/features/scanner/index.js index 3c2f202f8..626e10d50 100644 --- a/src/features/scanner/index.js +++ b/src/features/scanner/index.js @@ -1,3 +1,4 @@ export * from './ScanDialog' export * from './ScanOnDemand' -export * from './store' +export * from './hooks/store' +export * from './hooks/useCheckValid' diff --git a/src/features/scanner/scanNext/PopupContent.jsx b/src/features/scanner/scanNext/PopupContent.jsx index 22a3ab12a..59060996f 100644 --- a/src/features/scanner/scanNext/PopupContent.jsx +++ b/src/features/scanner/scanNext/PopupContent.jsx @@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next' import { SCAN_SIZES } from '@assets/constants' -import { useScanStore } from '../store' +import { useScanStore } from '../hooks/store' export function ScanNextPopup() { const { t } = useTranslation() diff --git a/src/features/scanner/scanNext/getCoords.js b/src/features/scanner/scanNext/getCoords.js index c4f79ab66..04c4ff491 100644 --- a/src/features/scanner/scanNext/getCoords.js +++ b/src/features/scanner/scanNext/getCoords.js @@ -14,8 +14,8 @@ const DISTANCE = { /** * Get scan next coords * @param {[number, number]} center - * @param {import('../store').UseScanStore['scanNextSize']} size - * @returns {import('../store').UseScanStore['scanCoords']} + * @param {import('../hooks/store').UseScanStore['scanNextSize']} size + * @returns {import('../hooks/store').UseScanStore['scanCoords']} */ export const getScanNextCoords = (center, size) => { const coords = [center] diff --git a/src/features/scanner/scanNext/index.jsx b/src/features/scanner/scanNext/index.jsx index efda31a14..deafe5122 100644 --- a/src/features/scanner/scanNext/index.jsx +++ b/src/features/scanner/scanNext/index.jsx @@ -2,11 +2,11 @@ import * as React from 'react' import { ScanCircle, ScanCircles } from '../Shared' -import { useCheckValid } from '../useCheckValid' +import { useCheckValid } from '../hooks/useCheckValid' import { ScanNextPopup } from './PopupContent' import { ScanOnDemandMarker } from '../Marker' import { ScanOnDemandPopup } from '../Popup' -import { useScanStore } from '../store' +import { useScanStore } from '../hooks/store' const POKEMON_RADIUS = 70 const GYM_RADIUS = 750 diff --git a/src/features/scanner/scanZone/PopupContent.jsx b/src/features/scanner/scanZone/PopupContent.jsx index 04c6a23a8..550df604c 100644 --- a/src/features/scanner/scanZone/PopupContent.jsx +++ b/src/features/scanner/scanZone/PopupContent.jsx @@ -12,7 +12,7 @@ import { RADIUS_CHOICES } from '@assets/constants' import { StyledSubHeader } from '../Shared' import { ConfigContext } from '../ContextProvider' -import { useScanStore } from '../store' +import { useScanStore } from '../hooks/store' import { AdvAccordion } from './AdvAccordion' /** @@ -57,7 +57,7 @@ export function ScanZonePopup() { /** * * @param {{ - * name: keyof import("@rm/types").OnlyType, + * name: keyof import("@rm/types").OnlyType, * } & import('@mui/material').SliderProps} props * @returns */ diff --git a/src/features/scanner/scanZone/getCoords.js b/src/features/scanner/scanZone/getCoords.js index a9bc34f21..6264523ee 100644 --- a/src/features/scanner/scanZone/getCoords.js +++ b/src/features/scanner/scanZone/getCoords.js @@ -18,7 +18,7 @@ const BEARINGS = { * @param {[number, number]} center * @param {number} radius * @param {number} spacing - * @param {import('../store').UseScanStore['scanZoneSize']} scanZoneSize + * @param {import('../hooks/store').UseScanStore['scanZoneSize']} scanZoneSize * @returns */ export const getScanZoneCoords = (center, radius, spacing, scanZoneSize) => { diff --git a/src/features/scanner/scanZone/index.jsx b/src/features/scanner/scanZone/index.jsx index f41fc7bd1..aa60e9912 100644 --- a/src/features/scanner/scanZone/index.jsx +++ b/src/features/scanner/scanZone/index.jsx @@ -2,7 +2,7 @@ import * as React from 'react' import { ScanCircles } from '../Shared' -import { useCheckValid } from '../useCheckValid' +import { useCheckValid } from '../hooks/useCheckValid' import { ScanZonePopup } from './PopupContent' import { ScanOnDemandMarker } from '../Marker' import { ScanOnDemandPopup } from '../Popup' diff --git a/src/features/webhooks/Error.jsx b/src/features/webhooks/Error.jsx index 26d1cf33f..f1a38768a 100644 --- a/src/features/webhooks/Error.jsx +++ b/src/features/webhooks/Error.jsx @@ -4,7 +4,7 @@ import Typography from '@mui/material/Typography' import Grid from '@mui/material/Grid' import { useTranslation, Trans } from 'react-i18next' -import { useWebhookStore } from './store' +import { useWebhookStore } from './hooks/store' export default function WebhookError({ children }) { const { t } = useTranslation() diff --git a/src/features/webhooks/Manage.jsx b/src/features/webhooks/Manage.jsx index 2c26414d7..3ca057c1d 100644 --- a/src/features/webhooks/Manage.jsx +++ b/src/features/webhooks/Manage.jsx @@ -12,21 +12,22 @@ import { useTranslation } from 'react-i18next' import { useMemory } from '@hooks/useMemory' import { useLayoutStore } from '@hooks/useLayoutStore' -import Poracle from '@services/Poracle' import Utility from '@services/Utility' import Footer from '@components/Footer' import Header from '@components/Header' import { apolloClient } from '@services/apollo' import Query from '@services/Query' import { allProfiles } from '@services/queries/webhook' -import { WebhookItem } from '@features/drawer/SelectorItem' +import Menu from '@components/Menu' import Human from './human' import Tracked from './Tracked' -import Menu from '../../components/Menu' -import { setMode, setSelected, useWebhookStore } from './store' -import { useGenFullFilters, useGetHookContext } from './hooks' +import { setMode, setSelected, useWebhookStore } from './hooks/store' +import { useGenFilters } from './hooks/useGenFilters' +import { useGetHookContext } from './hooks/useGetHookContext' import ProfileEditing from './human/profile' +import { Poracle } from './services/Poracle' +import { WebhookItem } from './tiles/WebhookItem' export default function Manage() { const { t } = useTranslation() @@ -37,7 +38,7 @@ export default function Manage() { const feedbackLink = useMemory((s) => s.config.links.feedbackLink) - const filters = useGenFullFilters() + const filters = useGenFilters() const liveFilters = useWebhookStore((s) => s.tempFilters) /** @type {ReturnType>} */ @@ -188,7 +189,7 @@ export default function Manage() { ) } -/** @param {{ category: import('./store').WebhookStore['category'] }} props */ +/** @param {{ category: import('./hooks/store').WebhookStore['category'] }} props */ function TabIcon({ category }) { const Icons = useMemory((s) => s.Icons) return category === 'human' ? ( diff --git a/src/features/webhooks/Notification.jsx b/src/features/webhooks/Notification.jsx index 14ec049ae..45d428350 100644 --- a/src/features/webhooks/Notification.jsx +++ b/src/features/webhooks/Notification.jsx @@ -2,7 +2,7 @@ import * as React from 'react' import Notification from '@components/Notification' -import { resetAlert, useWebhookStore } from './store' +import { resetAlert, useWebhookStore } from './hooks/store' export function WebhookNotification() { const webhookAlert = useWebhookStore((s) => s.alert) diff --git a/src/features/webhooks/Selecting.jsx b/src/features/webhooks/Selecting.jsx index 218b9fc45..917fc790d 100644 --- a/src/features/webhooks/Selecting.jsx +++ b/src/features/webhooks/Selecting.jsx @@ -9,7 +9,7 @@ import { useMutation } from '@apollo/client' import { setProfile, allProfiles } from '@services/queries/webhook' -import { useWebhookStore, setSelected } from './store' +import { useWebhookStore, setSelected } from './hooks/store' export default function Selecting() { const { t } = useTranslation() diff --git a/src/features/webhooks/Tracked.jsx b/src/features/webhooks/Tracked.jsx index 09034f9d4..4448c31dc 100644 --- a/src/features/webhooks/Tracked.jsx +++ b/src/features/webhooks/Tracked.jsx @@ -11,12 +11,12 @@ import { GenericSearch } from '@features/drawer/ItemSearch' import TrackedTile from './tiles/TrackedTile' import Selecting from './Selecting' -import { useGetWebhookData } from './hooks' -import { useWebhookStore } from './store' +import { useGetWebhookData } from './hooks/useGetWebhookData' +import { useWebhookStore } from './hooks/store' /** * - * @param {{ category: Exclude }} props + * @param {{ category: Exclude }} props * @returns */ const Tracked = ({ category }) => { diff --git a/src/features/webhooks/index.jsx b/src/features/webhooks/Webhook.jsx similarity index 84% rename from src/features/webhooks/index.jsx rename to src/features/webhooks/Webhook.jsx index 1b523a744..c256a0939 100644 --- a/src/features/webhooks/index.jsx +++ b/src/features/webhooks/Webhook.jsx @@ -5,9 +5,9 @@ import Dialog from '@mui/material/Dialog' import { useMemory } from '@hooks/useMemory' import Manage from './Manage' -import { setMode, useWebhookStore } from './store' +import { setMode, useWebhookStore } from './hooks/store' -export default function Webhook() { +export function Webhook() { const webhookMode = useWebhookStore((s) => s.mode === 'open') const isMobile = useMemory((s) => s.isMobile) diff --git a/src/features/webhooks/WebhookAdv.jsx b/src/features/webhooks/WebhookAdv.jsx index ef5a062d6..d719defce 100644 --- a/src/features/webhooks/WebhookAdv.jsx +++ b/src/features/webhooks/WebhookAdv.jsx @@ -24,15 +24,14 @@ import { useLazyQuery } from '@apollo/client' import { useMemory } from '@hooks/useMemory' import { useStorage } from '@hooks/useStorage' - import Query from '@services/Query' import Utility from '@services/Utility' -import Poracle from '@services/Poracle' - import SliderTile from '@components/dialogs/filters/SliderTile' import Header from '@components/Header' import Footer from '@components/Footer' -import { useWebhookStore } from './store' + +import { useWebhookStore } from './hooks/store' +import { Poracle } from './services/Poracle' const skipFields = new Set([ 'profile_no', @@ -79,7 +78,7 @@ const wildCards = { invasion: ['i0'], } -export default function WebhookAdvanced() { +export function WebhookAdvanced() { const { id, category, open, selectedIds, onClose } = useWebhookStore( (s) => s.advanced, ) diff --git a/src/features/webhooks/store.js b/src/features/webhooks/hooks/store.js similarity index 100% rename from src/features/webhooks/store.js rename to src/features/webhooks/hooks/store.js diff --git a/src/features/webhooks/hooks.js b/src/features/webhooks/hooks/useGenFilters.js similarity index 55% rename from src/features/webhooks/hooks.js rename to src/features/webhooks/hooks/useGenFilters.js index a2088a211..2bcfb2e41 100644 --- a/src/features/webhooks/hooks.js +++ b/src/features/webhooks/hooks/useGenFilters.js @@ -1,207 +1,10 @@ // @ts-check -import { useEffect, useMemo, useRef } from 'react' -import { useQuery } from '@apollo/client' -import { useTranslation } from 'react-i18next' - +import { useMemo } from 'react' import { useMemory } from '@hooks/useMemory' -import { - WEBHOOK_CATEGORIES, - WEBHOOK_AREAS, - WEBHOOK_CONTEXT, - allProfiles, - WEBHOOK_USER, -} from '@services/queries/webhook' -import RobustTimeout from '@services/apollo/RobustTimeout' -import Poracle from '@services/Poracle' - -import { getContext, useWebhookStore } from './store' - -/** - * - * @returns {{ data: { group: string, children: string[] }[], loading: boolean }} - */ -export function useGetAreas() { - const { data, loading } = useQuery(WEBHOOK_AREAS, { - fetchPolicy: 'cache-first', - }) - - return { data: data?.webhookAreas || [], loading } -} -/** @returns {import('./store').WebhookStore['category'][]} */ -export function useGetHookContext() { - const mode = useWebhookStore((s) => s.mode) - - const { data: context } = useQuery(WEBHOOK_CONTEXT, { - fetchPolicy: 'no-cache', - skip: !mode, - }) - const { data: categories } = useQuery(WEBHOOK_CATEGORIES, { - fetchPolicy: 'no-cache', - skip: !mode, - }) - - useEffect(() => { - if (context?.webhookContext) { - useWebhookStore.setState({ - context: context.webhookContext, - }) - } - }, [context]) - - return categories?.webhookCategories || [] -} - -/** - * - * @template {import('./store').WebhookStore['category'] | 'profile'} T - * @param {T} category - * @returns {{ data: T extends 'human' ? { webhooks: string[], selected: string } : import("@rm/types").APIReturnType[T], loading: boolean }} - */ -export function useGetWebhookData(category) { - const { t } = useTranslation() - const search = useWebhookStore((s) => s.trackedSearch) - const realCategory = useWebhookStore((s) => s.category) - const profileNo = useWebhookStore((s) => s.human.current_profile_no) - const timeout = useRef(new RobustTimeout(10_000)) - - const { data, previousData, loading, refetch } = useQuery(allProfiles, { - fetchPolicy: 'cache-first', - variables: { - category, - status: 'GET', - }, - context: { - abortableContext: timeout.current, - }, - skip: category !== realCategory && category !== 'profile', - }) - const { data: userConfig } = useQuery(WEBHOOK_USER, { - fetchPolicy: 'no-cache', - skip: category !== 'human', - }) - - useEffect(() => { - if (category === realCategory) { - timeout.current.setupTimeout(refetch) - return () => { - timeout.current.off() - } - } - }, [category, realCategory]) - - const filtererData = useMemo(() => { - const source = data ?? previousData - return category === 'human' || category === 'profile' - ? source?.webhook?.[category] - : (source?.webhook?.[category] || []).filter( - (x) => - !search || - (x.description - ? x.description.toLowerCase().includes(search.toLowerCase()) - : Poracle.generateDescription(x, category) - .toLowerCase() - .includes(search)), - ) || [] - }, [data, previousData, search]) - - useEffect(() => { - if (!loading && data?.webhook) { - if (data.webhook.status === 'error') { - const { context } = useWebhookStore.getState() - useWebhookStore.setState({ - alert: { - open: true, - severity: data.webhook.status, - message: t(data.webhook.message, { name: context.name || '' }), - }, - }) - } else { - useWebhookStore.setState({ [category]: filtererData }) - } - } - }, [data, search]) - - useEffect(() => { - if (category === 'human') { - useWebhookStore.setState({ - multipleHooks: userConfig?.webhookUser?.webhooks?.length > 1, - }) - } - }, [userConfig]) - - useEffect(() => { - refetch() - }, [category, profileNo]) - - return { - data: - category === 'human' - ? userConfig?.webhookUser || { webhooks: [], selected: '' } - : filtererData || [], - loading, - } -} - -/** - * @template {import('./store').WebhookStore['category']} T - * @param {T} category */ -export function useSyncData(category) { - const cached = useWebhookStore((s) => s[category]) - - const { data, loading } = useQuery(allProfiles, { - fetchPolicy: 'no-cache', - variables: { - category, - status: 'GET', - }, - }) - - useEffect(() => { - if (data?.webhook?.[category]) { - useWebhookStore.setState({ - [category]: data.webhook[category], - }) - } - }, [data]) - return { data: cached, loading } -} +import { useWebhookStore } from './store' export function useGenFilters() { - const { - // masterfile: { invasions }, - filters: rmFilters, - } = useMemory.getState() - const category = useWebhookStore((s) => s.category) - const profile_no = useWebhookStore((s) => s.human.current_profile_no) || 0 - - if (category === 'human') { - return {} - } - if (category === 'pokemon') { - const pokemon = getContext(category) - const poracleFilters = { - global: { ...pokemon.defaults, profile_no }, - ...Object.fromEntries( - Object.keys(rmFilters[category]?.filter || {}).map((key) => [ - key, - { - ...pokemon.defaults, - pokemon_id: +key.split('-')[0], - form: +key.split('-')[1], - profile_no, - enabled: false, - }, - ]), - ), - } - delete poracleFilters.global.pokemon_id - delete poracleFilters.global.form - return poracleFilters - } -} - -export function useGenFullFilters() { const profile_no = useWebhookStore((s) => s.human.current_profile_no) const ui = useWebhookStore((s) => s.context.ui) diff --git a/src/features/webhooks/hooks/useGetAreas.js b/src/features/webhooks/hooks/useGetAreas.js new file mode 100644 index 000000000..3f7a10cb8 --- /dev/null +++ b/src/features/webhooks/hooks/useGetAreas.js @@ -0,0 +1,15 @@ +// @ts-check +import { useQuery } from '@apollo/client' + +import { WEBHOOK_AREAS } from '@services/queries/webhook' + +/** + * @returns {{ data: { group: string, children: string[] }[], loading: boolean }} + */ +export function useGetAreas() { + const { data, loading } = useQuery(WEBHOOK_AREAS, { + fetchPolicy: 'cache-first', + }) + + return { data: data?.webhookAreas || [], loading } +} diff --git a/src/features/webhooks/hooks/useGetHookContext.js b/src/features/webhooks/hooks/useGetHookContext.js new file mode 100644 index 000000000..3c0b57b8b --- /dev/null +++ b/src/features/webhooks/hooks/useGetHookContext.js @@ -0,0 +1,31 @@ +// @ts-check +import { useEffect } from 'react' +import { useQuery } from '@apollo/client' + +import { WEBHOOK_CATEGORIES, WEBHOOK_CONTEXT } from '@services/queries/webhook' + +import { useWebhookStore } from './store' + +/** @returns {import('./store').WebhookStore['category'][]} */ +export function useGetHookContext() { + const mode = useWebhookStore((s) => s.mode) + + const { data: context } = useQuery(WEBHOOK_CONTEXT, { + fetchPolicy: 'no-cache', + skip: !mode, + }) + const { data: categories } = useQuery(WEBHOOK_CATEGORIES, { + fetchPolicy: 'no-cache', + skip: !mode, + }) + + useEffect(() => { + if (context?.webhookContext) { + useWebhookStore.setState({ + context: context.webhookContext, + }) + } + }, [context]) + + return categories?.webhookCategories || [] +} diff --git a/src/features/webhooks/hooks/useGetWebhookData.js b/src/features/webhooks/hooks/useGetWebhookData.js new file mode 100644 index 000000000..5f0566677 --- /dev/null +++ b/src/features/webhooks/hooks/useGetWebhookData.js @@ -0,0 +1,101 @@ +// @ts-check +import { useEffect, useMemo, useRef } from 'react' +import { useQuery } from '@apollo/client' +import { useTranslation } from 'react-i18next' + +import { allProfiles, WEBHOOK_USER } from '@services/queries/webhook' +import RobustTimeout from '@services/apollo/RobustTimeout' +import { Poracle } from '../services/Poracle' + +import { useWebhookStore } from './store' + +/** + * + * @template {import('./store').WebhookStore['category'] | 'profile'} T + * @param {T} category + * @returns {{ data: T extends 'human' ? { webhooks: string[], selected: string } : import("@rm/types").APIReturnType[T], loading: boolean }} + */ +export function useGetWebhookData(category) { + const { t } = useTranslation() + const search = useWebhookStore((s) => s.trackedSearch) + const realCategory = useWebhookStore((s) => s.category) + const profileNo = useWebhookStore((s) => s.human.current_profile_no) + const timeout = useRef(new RobustTimeout(10_000)) + + const { data, previousData, loading, refetch } = useQuery(allProfiles, { + fetchPolicy: 'cache-first', + variables: { + category, + status: 'GET', + }, + context: { + abortableContext: timeout.current, + }, + skip: category !== realCategory && category !== 'profile', + }) + const { data: userConfig } = useQuery(WEBHOOK_USER, { + fetchPolicy: 'no-cache', + skip: category !== 'human', + }) + + useEffect(() => { + if (category === realCategory) { + timeout.current.setupTimeout(refetch) + return () => { + timeout.current.off() + } + } + }, [category, realCategory]) + + const filtererData = useMemo(() => { + const source = data ?? previousData + return category === 'human' || category === 'profile' + ? source?.webhook?.[category] + : (source?.webhook?.[category] || []).filter( + (x) => + !search || + (x.description + ? x.description.toLowerCase().includes(search.toLowerCase()) + : Poracle.generateDescription(x, category) + .toLowerCase() + .includes(search)), + ) || [] + }, [data, previousData, search]) + + useEffect(() => { + if (!loading && data?.webhook) { + if (data.webhook.status === 'error') { + const { context } = useWebhookStore.getState() + useWebhookStore.setState({ + alert: { + open: true, + severity: data.webhook.status, + message: t(data.webhook.message, { name: context.name || '' }), + }, + }) + } else { + useWebhookStore.setState({ [category]: filtererData }) + } + } + }, [data, search]) + + useEffect(() => { + if (category === 'human') { + useWebhookStore.setState({ + multipleHooks: userConfig?.webhookUser?.webhooks?.length > 1, + }) + } + }, [userConfig]) + + useEffect(() => { + refetch() + }, [category, profileNo]) + + return { + data: + category === 'human' + ? userConfig?.webhookUser || { webhooks: [], selected: '' } + : filtererData || [], + loading, + } +} diff --git a/src/features/webhooks/hooks/useSyncData.js b/src/features/webhooks/hooks/useSyncData.js new file mode 100644 index 000000000..3e7508f41 --- /dev/null +++ b/src/features/webhooks/hooks/useSyncData.js @@ -0,0 +1,31 @@ +// @ts-check +import { useEffect } from 'react' +import { useQuery } from '@apollo/client' + +import { allProfiles } from '@services/queries/webhook' + +import { useWebhookStore } from './store' + +/** + * @template {import('./store').WebhookStore['category']} T + * @param {T} category */ +export function useSyncData(category) { + const cached = useWebhookStore((s) => s[category]) + + const { data, loading } = useQuery(allProfiles, { + fetchPolicy: 'no-cache', + variables: { + category, + status: 'GET', + }, + }) + + useEffect(() => { + if (data?.webhook?.[category]) { + useWebhookStore.setState({ + [category]: data.webhook[category], + }) + } + }, [data]) + return { data: cached, loading } +} diff --git a/src/features/webhooks/human/Draggable.jsx b/src/features/webhooks/human/Draggable.jsx index eecf89f3f..6387d5d80 100644 --- a/src/features/webhooks/human/Draggable.jsx +++ b/src/features/webhooks/human/Draggable.jsx @@ -11,9 +11,9 @@ import { useTranslation } from 'react-i18next' import fallbackIcon from '@assets/fallbackMarker' -import { useWebhookStore } from '../store' +import { useWebhookStore } from '../hooks/store' -export default function DraggableMarker() { +export function WebhookMarker() { const map = useMap() const { t } = useTranslation() diff --git a/src/features/webhooks/human/Location.jsx b/src/features/webhooks/human/Location.jsx index df023a47e..e69abc77f 100644 --- a/src/features/webhooks/human/Location.jsx +++ b/src/features/webhooks/human/Location.jsx @@ -19,8 +19,8 @@ import useLocation from '@hooks/useLocation' import { Loading } from '@components/Loading' import { basicEqualFn } from '@hooks/useMemory' -import { setModeBtn, useWebhookStore } from '../store' -import { useSyncData } from '../hooks' +import { setModeBtn, useWebhookStore } from '../hooks/store' +import { useSyncData } from '../hooks/useSyncData' const Location = () => { const { lc, color } = useLocation() diff --git a/src/features/webhooks/human/area/AreaChip.jsx b/src/features/webhooks/human/area/AreaChip.jsx index 0edfaa277..cc2d13a44 100644 --- a/src/features/webhooks/human/area/AreaChip.jsx +++ b/src/features/webhooks/human/area/AreaChip.jsx @@ -6,7 +6,7 @@ import Chip from '@mui/material/Chip' import { apolloClient } from '@services/apollo' import { WEBHOOK_AREAS, setHuman } from '@services/queries/webhook' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' /** @param {string} areaName @param {string} [groupName] */ export const handleClick = diff --git a/src/features/webhooks/human/area/AreaGroup.jsx b/src/features/webhooks/human/area/AreaGroup.jsx index eb6553460..c08785812 100644 --- a/src/features/webhooks/human/area/AreaGroup.jsx +++ b/src/features/webhooks/human/area/AreaGroup.jsx @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next' import { Loading } from '@components/Loading' -import { useGetAreas } from '../../hooks' +import { useGetAreas } from '../../hooks/useGetAreas' import { MemoAreaChip, handleClick } from './AreaChip' export const AreaGroup = () => { diff --git a/src/features/webhooks/human/area/AreaSelection.jsx b/src/features/webhooks/human/area/AreaSelection.jsx index 9fea47b8e..b709c22e8 100644 --- a/src/features/webhooks/human/area/AreaSelection.jsx +++ b/src/features/webhooks/human/area/AreaSelection.jsx @@ -7,13 +7,14 @@ import { ScanAreaTile } from '@features/scanArea' import { WEBHOOK_GEOJSON } from '@services/queries/webhook' import { Loading } from '@components/Loading' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' +import { handleClick } from './AreaChip' const FALLBACK = { type: 'FeatureCollection', features: [], } -export default function WebhookAreaSelection() { +export function WebhookAreaSelection() { const webhookMode = useWebhookStore((s) => s.mode) const webhookName = useWebhookStore((s) => s.context.name) @@ -36,7 +37,13 @@ export default function WebhookAreaSelection() { return {t('loading', { category: t('areas') })} } if (webhookMode === 'areas' && data?.webhookGeojson) { - return + return ( + + ) } return null } diff --git a/src/features/webhooks/human/area/Selected.jsx b/src/features/webhooks/human/area/Selected.jsx index d03de6589..03c5df962 100644 --- a/src/features/webhooks/human/area/Selected.jsx +++ b/src/features/webhooks/human/area/Selected.jsx @@ -2,7 +2,7 @@ import * as React from 'react' import Typography from '@mui/material/Typography' import { Trans } from 'react-i18next' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' export const Selected = () => { const selectedAreas = useWebhookStore((s) => s.human.area || []) diff --git a/src/features/webhooks/human/area/index.jsx b/src/features/webhooks/human/area/index.jsx index 5cfc0d329..95038bf41 100644 --- a/src/features/webhooks/human/area/index.jsx +++ b/src/features/webhooks/human/area/index.jsx @@ -5,7 +5,7 @@ import Typography from '@mui/material/Typography' import Button from '@mui/material/Button' import Grid from '@mui/material/Unstable_Grid2' -import { setModeBtn } from '../../store' +import { setModeBtn } from '../../hooks/store' import { AreaAction, AreaGroup } from './AreaGroup' import { Selected } from './Selected' diff --git a/src/features/webhooks/human/profile/ActiveHourChip.jsx b/src/features/webhooks/human/profile/ActiveHourChip.jsx index 3a32c0227..6d631b05b 100644 --- a/src/features/webhooks/human/profile/ActiveHourChip.jsx +++ b/src/features/webhooks/human/profile/ActiveHourChip.jsx @@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next' import { useMutation } from '@apollo/client' import { allProfiles, setProfile } from '@services/queries/webhook' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' const StyledChip = styled(Chip)(({ theme }) => ({ margin: theme.spacing(0.5), diff --git a/src/features/webhooks/human/profile/CopyView.jsx b/src/features/webhooks/human/profile/CopyView.jsx index b403476ce..f7ea53523 100644 --- a/src/features/webhooks/human/profile/CopyView.jsx +++ b/src/features/webhooks/human/profile/CopyView.jsx @@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next' import { useMutation } from '@apollo/client' import { allProfiles, setProfile } from '@services/queries/webhook' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' /** @param {import('./ProfileTile').Props} props */ export const CopyView = ({ uid, handleViewChange }) => { diff --git a/src/features/webhooks/human/profile/DeleteVIew.jsx b/src/features/webhooks/human/profile/DeleteVIew.jsx index 6221d87cf..ce255be5d 100644 --- a/src/features/webhooks/human/profile/DeleteVIew.jsx +++ b/src/features/webhooks/human/profile/DeleteVIew.jsx @@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next' import { useMutation } from '@apollo/client' import { allProfiles, setProfile } from '@services/queries/webhook' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' /** @param {import('./ProfileTile').Props} props */ export const DeleteView = ({ handleViewChange, uid }) => { diff --git a/src/features/webhooks/human/profile/EditView.jsx b/src/features/webhooks/human/profile/EditView.jsx index 1961ebd45..e2afd3c71 100644 --- a/src/features/webhooks/human/profile/EditView.jsx +++ b/src/features/webhooks/human/profile/EditView.jsx @@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next' import { useMutation } from '@apollo/client' import { allProfiles, setProfile } from '@services/queries/webhook' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' /** @param {import('./ProfileTile').Props} props */ export const EditView = ({ handleViewChange, uid }) => { diff --git a/src/features/webhooks/human/profile/NewProfile.jsx b/src/features/webhooks/human/profile/NewProfile.jsx index a434f4fa3..fd38850e9 100644 --- a/src/features/webhooks/human/profile/NewProfile.jsx +++ b/src/features/webhooks/human/profile/NewProfile.jsx @@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next' import { useMutation } from '@apollo/client' import { allProfiles, setProfile } from '@services/queries/webhook' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' export const NewProfile = () => { const { t } = useTranslation() diff --git a/src/features/webhooks/human/profile/ProfileTile.jsx b/src/features/webhooks/human/profile/ProfileTile.jsx index 17e029ba7..055040930 100644 --- a/src/features/webhooks/human/profile/ProfileTile.jsx +++ b/src/features/webhooks/human/profile/ProfileTile.jsx @@ -3,6 +3,7 @@ import * as React from 'react' import Grid from '@mui/material/Unstable_Grid2' import Divider from '@mui/material/Divider' import { styled } from '@mui/material/styles' + import { ProfileView } from './ProfileView' import { EditView } from './EditView' import { DeleteView } from './DeleteVIew' diff --git a/src/features/webhooks/human/profile/ProfileView.jsx b/src/features/webhooks/human/profile/ProfileView.jsx index a95645c41..6b38eca9c 100644 --- a/src/features/webhooks/human/profile/ProfileView.jsx +++ b/src/features/webhooks/human/profile/ProfileView.jsx @@ -9,7 +9,7 @@ import IconButton from '@mui/material/IconButton' import { useMemory } from '@hooks/useMemory' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' import { ActiveHourChip } from './ActiveHourChip' /** @param {import('./ProfileTile').Props} props */ diff --git a/src/features/webhooks/human/profile/index.jsx b/src/features/webhooks/human/profile/index.jsx index 74a2b7ec1..2d41e216d 100644 --- a/src/features/webhooks/human/profile/index.jsx +++ b/src/features/webhooks/human/profile/index.jsx @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next' import { Loading } from '@components/Loading' -import { useGetWebhookData } from '../../hooks' +import { useGetWebhookData } from '../../hooks/useGetWebhookData' import { MemoNewProfile } from './NewProfile' import { ProfileTile } from './ProfileTile' diff --git a/src/features/webhooks/human/status/EnableSwitch.jsx b/src/features/webhooks/human/status/EnableSwitch.jsx index 2c75fe9af..dd464c936 100644 --- a/src/features/webhooks/human/status/EnableSwitch.jsx +++ b/src/features/webhooks/human/status/EnableSwitch.jsx @@ -5,7 +5,7 @@ import { useMutation } from '@apollo/client' import { useTranslation } from 'react-i18next' import { setHuman } from '@services/queries/webhook' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' export function EnableSwitch() { const { t } = useTranslation() diff --git a/src/features/webhooks/human/status/HookSelection.jsx b/src/features/webhooks/human/status/HookSelection.jsx index 0abf6e39c..771685e31 100644 --- a/src/features/webhooks/human/status/HookSelection.jsx +++ b/src/features/webhooks/human/status/HookSelection.jsx @@ -17,8 +17,8 @@ import { } from '@services/queries/webhook' import { Loading } from '@components/Loading' -import { useGetWebhookData } from '../../hooks' -import { useWebhookStore } from '../../store' +import { useGetWebhookData } from '../../hooks/useGetWebhookData' +import { useWebhookStore } from '../../hooks/store' export function HookSelection() { const { t } = useTranslation() diff --git a/src/features/webhooks/human/status/ProfileSelect.jsx b/src/features/webhooks/human/status/ProfileSelect.jsx index 3d498bf9d..72a9124b8 100644 --- a/src/features/webhooks/human/status/ProfileSelect.jsx +++ b/src/features/webhooks/human/status/ProfileSelect.jsx @@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next' import { allProfiles, setHuman } from '@services/queries/webhook' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' /** @type {React.CSSProperties} */ const STYLE = { minWidth: 100 } diff --git a/src/features/webhooks/human/status/index.jsx b/src/features/webhooks/human/status/index.jsx index 05ec547cd..4051d54df 100644 --- a/src/features/webhooks/human/status/index.jsx +++ b/src/features/webhooks/human/status/index.jsx @@ -5,7 +5,7 @@ import Divider from '@mui/material/Divider' import { ProfileSelect } from './ProfileSelect' import { EnableSwitch } from './EnableSwitch' import { HookSelection } from './HookSelection' -import { useWebhookStore } from '../../store' +import { useWebhookStore } from '../../hooks/store' export default function Status() { const multipleHooks = useWebhookStore((s) => s.multipleHooks) diff --git a/src/features/webhooks/index.js b/src/features/webhooks/index.js new file mode 100644 index 000000000..ff9f36906 --- /dev/null +++ b/src/features/webhooks/index.js @@ -0,0 +1,9 @@ +export * from './Webhook' +export * from './hooks/store' +export * from './hooks/useSyncData' +export * from './human/Draggable' +export * from './human/area/AreaSelection' +export { handleClick } from './human/area/AreaChip' +export * from './Notification' +export * from './WebhookAdv' +export * from './services/Poracle' diff --git a/src/services/Poracle.js b/src/features/webhooks/services/Poracle.js similarity index 98% rename from src/services/Poracle.js rename to src/features/webhooks/services/Poracle.js index e3c8c9057..92eb036e4 100644 --- a/src/services/Poracle.js +++ b/src/features/webhooks/services/Poracle.js @@ -1,8 +1,8 @@ // @ts-check import { t } from 'i18next' -import { useWebhookStore } from '@features/webhooks/store' +import { useWebhookStore } from '../hooks/store' -export default class Poracle { +export class Poracle { static getMapCategory(poracleCategory) { switch (poracleCategory) { case 'gym': @@ -302,7 +302,7 @@ export default class Poracle { /** * * @param {object} item - * @param {Exclude} category + * @param {Exclude} category * @returns {string} */ static generateDescription(item, category) { diff --git a/src/features/webhooks/tiles/TrackedTile.jsx b/src/features/webhooks/tiles/TrackedTile.jsx index f2119d45e..f986904a4 100644 --- a/src/features/webhooks/tiles/TrackedTile.jsx +++ b/src/features/webhooks/tiles/TrackedTile.jsx @@ -8,12 +8,12 @@ import Checkbox from '@mui/material/Checkbox' import Box from '@mui/material/Box' import Utility from '@services/Utility' -import Poracle from '@services/Poracle' import { useMemory } from '@hooks/useMemory' import { apolloClient, apolloCache } from '@services/apollo' import * as webhookNodes from '@services/queries/webhook' -import { useWebhookStore, setSelected } from '../store' +import { useWebhookStore, setSelected } from '../hooks/store' +import { Poracle } from '../services/Poracle' export default function TrackedTile({ index }) { const category = useWebhookStore((s) => s.category) diff --git a/src/features/webhooks/tiles/WebhookItem.jsx b/src/features/webhooks/tiles/WebhookItem.jsx new file mode 100644 index 000000000..0a8271461 --- /dev/null +++ b/src/features/webhooks/tiles/WebhookItem.jsx @@ -0,0 +1,45 @@ +// @ts-check +import * as React from 'react' + +import { SelectorItem } from '@features/drawer/SelectorItem' + +import { useWebhookStore } from '../hooks/store' +import { Poracle } from '../services/Poracle' + +/** @param {import('@features/drawer/SelectorItem').BaseProps} props */ +export function WebhookItem({ id, category, ...props }) { + const filter = useWebhookStore((s) => s.tempFilters[id]) + + const setFilter = (newFilter) => { + useWebhookStore.setState((prev) => ({ + tempFilters: { + ...prev.tempFilters, + [id]: newFilter + ? { + ...newFilter, + enabled: newFilter.enabled, + } + : { enabled: true, ...Poracle.getOtherData(id) }, + }, + })) + } + return ( + + useWebhookStore.setState({ + advanced: { + id, + uid: 0, + open: true, + category, + selectedIds: [], + }, + }) + } + /> + ) +} diff --git a/src/hooks/useWebhook.js b/src/hooks/useWebhook.js index 2d4807746..ad3e84b57 100644 --- a/src/hooks/useWebhook.js +++ b/src/hooks/useWebhook.js @@ -2,7 +2,7 @@ import { useEffect } from 'react' import { useMutation } from '@apollo/client' import { useTranslation } from 'react-i18next' import Query from '@services/Query' -import { useWebhookStore } from '@features/webhooks/store' +import { useWebhookStore } from '@features/webhooks' import { allProfiles } from '@services/queries/webhook' export default function useWebhook({ category }) { diff --git a/src/pages/map/components/Container.jsx b/src/pages/map/components/Container.jsx index f98ab9f61..db5b4478c 100644 --- a/src/pages/map/components/Container.jsx +++ b/src/pages/map/components/Container.jsx @@ -8,8 +8,7 @@ import { useMapStore } from '@hooks/useMapStore' import Utility from '@services/Utility' import { ScanOnDemand } from '@features/scanner' -import DraggableMarker from '@features/webhooks/human/Draggable' -import WebhookAreaSelection from '@features/webhooks/human/area/AreaSelection' +import { WebhookMarker, WebhookAreaSelection } from '@features/webhooks' import { ActiveWeather } from '@features/weather' import { Effects } from './Effects' @@ -65,7 +64,7 @@ export default function Container() { - +