From 9546b2e9f40b8151a1339eee7838798c3f18d1d5 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 29 Oct 2024 17:42:04 +0100 Subject: [PATCH] autofixes --- postcss.config.js | 9 +- rollup.config.js | 36 +- src/Components/AppShell/AppShell.tsx | 9 +- src/Components/AppShell/Content.tsx | 2 +- src/Components/AppShell/ContextWrapper.tsx | 31 +- src/Components/AppShell/NavBar.tsx | 102 +++-- src/Components/AppShell/SetAssetsApi.tsx | 15 +- src/Components/AppShell/SideBar.tsx | 96 +++-- src/Components/AppShell/SidebarSubmenu.tsx | 42 +- src/Components/AppShell/Sitemap.tsx | 37 +- src/Components/AppShell/hooks/useAssets.tsx | 41 +- src/Components/AppShell/index.tsx | 8 +- src/Components/Auth/LoginPage.tsx | 84 ++-- src/Components/Auth/RequestPasswordPage.tsx | 56 ++- src/Components/Auth/SetNewPasswordPage.tsx | 56 ++- src/Components/Auth/SignupPage.tsx | 85 ++-- src/Components/Auth/index.tsx | 10 +- src/Components/Auth/useAuth.tsx | 126 +++--- src/Components/Gaming/Modal.tsx | 22 +- src/Components/Gaming/Quests.tsx | 56 ++- src/Components/Gaming/hooks/useQuests.tsx | 36 +- src/Components/Gaming/index.tsx | 4 +- src/Components/Input/Autocomplete.tsx | 64 ++- src/Components/Input/ComboBoxInput.tsx | 19 +- src/Components/Input/SelectBox.tsx | 36 +- src/Components/Input/TextAreaInput.tsx | 106 ++--- src/Components/Input/TextInput.tsx | 49 +-- src/Components/Input/index.tsx | 6 +- src/Components/Map/ItemForm.tsx | 35 +- src/Components/Map/ItemView.tsx | 21 +- src/Components/Map/Layer.tsx | 368 ++++++++--------- src/Components/Map/Permissions.tsx | 30 +- .../Map/Subcomponents/AddButton.tsx | 42 +- .../Map/Subcomponents/Controls/Control.tsx | 9 +- .../Subcomponents/Controls/FilterControl.tsx | 46 +-- .../Controls/GratitudeControl.tsx | 20 +- .../Subcomponents/Controls/LayerControl.tsx | 37 +- .../Subcomponents/Controls/LocateControl.tsx | 69 ++-- .../Subcomponents/Controls/QuestControl.tsx | 21 +- .../Subcomponents/Controls/SearchControl.tsx | 229 +++++------ .../Subcomponents/Controls/SidebarControl.tsx | 10 +- .../Subcomponents/Controls/TagsControl.tsx | 11 +- .../Map/Subcomponents/ItemFormPopup.tsx | 194 +++++---- .../ItemPopupComponents/HeaderView.tsx | 81 ++-- .../ItemPopupComponents/PopupButton.tsx | 19 +- .../PopupCheckboxInput.tsx | 5 +- .../PopupStartEndInput.tsx | 14 +- .../PopupTextAreaInput.tsx | 7 +- .../ItemPopupComponents/PopupTextInput.tsx | 7 +- .../ItemPopupComponents/StartEndView.tsx | 7 +- .../ItemPopupComponents/TextView.tsx | 151 ++++--- .../Map/Subcomponents/ItemViewPopup.tsx | 80 ++-- .../Map/Subcomponents/SelectPosition.tsx | 9 +- src/Components/Map/Tags.tsx | 64 ++- src/Components/Map/UtopiaMap.tsx | 17 +- src/Components/Map/UtopiaMapInner.tsx | 199 +++++---- src/Components/Map/hooks/useClusterRef.tsx | 37 +- src/Components/Map/hooks/useDebounce.tsx | 12 +- src/Components/Map/hooks/useFilter.tsx | 376 +++++++++--------- src/Components/Map/hooks/useItems.tsx | 192 +++++---- src/Components/Map/hooks/useLayers.tsx | 59 +-- src/Components/Map/hooks/useLeafletRefs.tsx | 88 ++-- src/Components/Map/hooks/usePermissions.tsx | 138 ++++--- .../Map/hooks/useSelectPosition.tsx | 215 +++++----- src/Components/Map/hooks/useTags.tsx | 154 ++++--- src/Components/Map/hooks/useTimeout.tsx | 34 +- .../Map/hooks/useWindowDimension.tsx | 24 +- src/Components/Map/index.tsx | 26 +- src/Components/Map/setItemLocation.tsx | 5 +- src/Components/Profile/ProfileForm.tsx | 226 ++++++----- src/Components/Profile/ProfileView.tsx | 254 ++++++------ .../Profile/Subcomponents/ActionsButton.tsx | 55 ++- .../Profile/Subcomponents/AvatarWidget.tsx | 277 +++++++------ .../Profile/Subcomponents/ColorPicker.tsx | 52 ++- .../Profile/Subcomponents/ContactInfo.tsx | 28 +- .../Profile/Subcomponents/FormHeader.tsx | 30 +- .../Subcomponents/LinkedItemsHeaderView.tsx | 42 +- .../Profile/Subcomponents/PlusButton.tsx | 18 +- .../Subcomponents/ProfileSubHeader.tsx | 17 +- .../Profile/Subcomponents/RelationCard.tsx | 5 +- .../Profile/Subcomponents/SocialShareBar.tsx | 12 +- .../Subcomponents/SocialShareButton.tsx | 92 ++--- .../Profile/Subcomponents/TagsWidget.tsx | 98 +++-- .../Profile/Templates/OnepagerForm.tsx | 120 +++--- .../Profile/Templates/OnepagerView.tsx | 61 ++- .../Profile/Templates/SimpleForm.tsx | 8 +- .../Profile/Templates/SimpleView.tsx | 2 +- src/Components/Profile/Templates/TabsForm.tsx | 91 ++--- src/Components/Profile/Templates/TabsView.tsx | 74 ++-- src/Components/Profile/UserSettings.tsx | 95 ++--- .../Profile/hooks/useClickOutside.tsx | 40 +- src/Components/Profile/index.tsx | 8 +- src/Components/Profile/itemFunctions.ts | 353 ++++++++-------- src/Components/Templates/AttestationForm.tsx | 126 +++--- src/Components/Templates/CardPage.tsx | 13 +- src/Components/Templates/CircleLayout.tsx | 31 +- src/Components/Templates/DateUserInfo.tsx | 19 +- src/Components/Templates/DialogModal.tsx | 46 +-- src/Components/Templates/EmojiPicker.tsx | 59 ++- src/Components/Templates/ItemCard.tsx | 12 +- src/Components/Templates/MapOverlayPage.tsx | 56 ++- src/Components/Templates/MarketView.tsx | 61 ++- src/Components/Templates/MoonCalendar.tsx | 56 ++- .../Templates/OverlayItemsIndexPage.tsx | 209 +++++----- src/Components/Templates/SelectUser.tsx | 33 +- src/Components/Templates/TagView.tsx | 12 +- src/Components/Templates/TitleCard.tsx | 11 +- src/Components/Templates/index.tsx | 16 +- src/Components/Typography/ErrorText.tsx | 10 +- src/Components/Typography/Subtitle.tsx | 10 +- src/Utils/FormatTags.ts | 12 +- src/Utils/GetValue.ts | 18 +- src/Utils/HashTagRegex.tsx | 2 +- src/Utils/MarkerIconFactory.ts | 44 +- src/Utils/Moon.ts | 36 +- src/Utils/RandomColor.ts | 43 +- src/Utils/ReplaceURLs.ts | 27 +- src/Utils/ReverseGeocoder.ts | 34 +- src/Utils/TimeAgo.ts | 23 +- src/index.tsx | 18 +- src/types.ts | 65 ++- tailwind.config.js | 72 ++-- 122 files changed, 3659 insertions(+), 3978 deletions(-) diff --git a/postcss.config.js b/postcss.config.js index 3bf778b7..a3f5603f 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,8 +1,7 @@ // eslint-disable-next-line no-undef module.exports = { - plugins: { - tailwindcss: {}, - autoprefixer: {}, - } + plugins: { + tailwindcss: {}, + autoprefixer: {} } - \ No newline at end of file +} diff --git a/rollup.config.js b/rollup.config.js index 30cd35a8..e868bf42 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,21 +2,21 @@ import postcss from 'rollup-plugin-postcss' import typescript from 'rollup-plugin-typescript2' export default { - input: 'src/index.tsx', - output: [ - { - dir: 'dist/', - format: 'esm', - exports: 'named', - sourcemap: true, - strict: false - } - ], - plugins: [ - postcss({ - plugins: [] - }), - typescript(), - ], - external: ['react', 'react-dom', 'leaflet', 'react-leaflet', 'react-toastify' , 'react-string-replace', 'react-toastify/dist/ReactToastify.css','tw-elements' ,'react-router-dom', 'react-leaflet-cluster', '@tanstack/react-query', 'tributejs', 'prop-types', 'leaflet/dist/leaflet.css', '@heroicons/react/20/solid'] - } \ No newline at end of file + input: 'src/index.tsx', + output: [ + { + dir: 'dist/', + format: 'esm', + exports: 'named', + sourcemap: true, + strict: false + } + ], + plugins: [ + postcss({ + plugins: [] + }), + typescript() + ], + external: ['react', 'react-dom', 'leaflet', 'react-leaflet', 'react-toastify', 'react-string-replace', 'react-toastify/dist/ReactToastify.css', 'tw-elements', 'react-router-dom', 'react-leaflet-cluster', '@tanstack/react-query', 'tributejs', 'prop-types', 'leaflet/dist/leaflet.css', '@heroicons/react/20/solid'] +} diff --git a/src/Components/AppShell/AppShell.tsx b/src/Components/AppShell/AppShell.tsx index c388d922..be317061 100644 --- a/src/Components/AppShell/AppShell.tsx +++ b/src/Components/AppShell/AppShell.tsx @@ -2,11 +2,10 @@ import * as React from 'react' import NavBar from './NavBar' import { SetAssetsApi } from './SetAssetsApi' import { AssetsApi } from '../../types' -import { ContextWrapper } from './ContextWrapper'; +import { ContextWrapper } from './ContextWrapper' - -export function AppShell({ appName, children, assetsApi, userType }: { appName: string, children: React.ReactNode, assetsApi: AssetsApi, userType: string }) { - return ( +export function AppShell ({ appName, children, assetsApi, userType }: { appName: string, children: React.ReactNode, assetsApi: AssetsApi, userType: string }) { + return (
@@ -16,5 +15,5 @@ export function AppShell({ appName, children, assetsApi, userType }: { appName:
- ) + ) } diff --git a/src/Components/AppShell/Content.tsx b/src/Components/AppShell/Content.tsx index 3631f58a..f4625187 100644 --- a/src/Components/AppShell/Content.tsx +++ b/src/Components/AppShell/Content.tsx @@ -4,7 +4,7 @@ type ContentProps = { children?: React.ReactNode; } -export function Content({children} : ContentProps) { +export function Content ({ children } : ContentProps) { return (
{children} diff --git a/src/Components/AppShell/ContextWrapper.tsx b/src/Components/AppShell/ContextWrapper.tsx index 01468225..ddb54697 100644 --- a/src/Components/AppShell/ContextWrapper.tsx +++ b/src/Components/AppShell/ContextWrapper.tsx @@ -10,24 +10,23 @@ import { PermissionsProvider } from '../Map/hooks/usePermissions' import { SelectPositionProvider } from '../Map/hooks/useSelectPosition' import { TagsProvider } from '../Map/hooks/useTags' import { AssetsProvider } from './hooks/useAssets' -import { useContext, createContext } from 'react'; -import { BrowserRouter as Router, useLocation } from 'react-router-dom'; - +import { useContext, createContext } from 'react' +import { BrowserRouter as Router, useLocation } from 'react-router-dom' // Helper context to determine if the ContextWrapper is already present. -const ContextCheckContext = createContext(false); +const ContextCheckContext = createContext(false) // eslint-disable-next-line react/prop-types export const ContextWrapper = ({ children }) => { - const isWrapped = useContext(ContextCheckContext); + const isWrapped = useContext(ContextCheckContext) // Check if we are already inside a Router - let location; + let location try { // eslint-disable-next-line react-hooks/rules-of-hooks - location = useLocation(); + location = useLocation() } catch (e) { - location = null; + location = null } // Case 1: Only the Router is missing, but ContextWrapper is already provided @@ -36,7 +35,7 @@ export const ContextWrapper = ({ children }) => { {children} - ); + ) } // Case 2: Neither Router nor ContextWrapper is present @@ -49,7 +48,7 @@ export const ContextWrapper = ({ children }) => { - ); + ) } // Case 3: Only ContextWrapper is missing @@ -58,16 +57,16 @@ export const ContextWrapper = ({ children }) => { {children} - ); + ) } // Case 4: Both Router and ContextWrapper are already present - return children; -}; + return children +} // eslint-disable-next-line react/prop-types export const Wrappers = ({ children }) => { - const queryClient = new QueryClient(); + const queryClient = new QueryClient() return ( @@ -103,5 +102,5 @@ export const Wrappers = ({ children }) => { - ); -}; \ No newline at end of file + ) +} diff --git a/src/Components/AppShell/NavBar.tsx b/src/Components/AppShell/NavBar.tsx index e09be0ce..ebde697d 100644 --- a/src/Components/AppShell/NavBar.tsx +++ b/src/Components/AppShell/NavBar.tsx @@ -1,72 +1,64 @@ -import { useAuth } from "../Auth" -import { Link, useLocation } from "react-router-dom"; -import { toast } from "react-toastify"; +import { useAuth } from '../Auth' +import { Link, useLocation } from 'react-router-dom' +import { toast } from 'react-toastify' import QuestionMarkIcon from '@heroicons/react/24/outline/QuestionMarkCircleIcon' -import { useEffect, useRef, useState } from "react"; -import { useItems } from "../Map/hooks/useItems"; -import { Item } from "../../types"; +import { useEffect, useRef, useState } from 'react' +import { useItems } from '../Map/hooks/useItems' +import { Item } from '../../types' +export default function NavBar ({ appName, userType }: { appName: string, userType: string }) { + const { isAuthenticated, user, logout } = useAuth() -export default function NavBar({ appName, userType}: { appName: string, userType: string }) { - - - const { isAuthenticated, user, logout } = useAuth(); - - const [userProfile, setUserProfile] = useState({}as Item); - const items = useItems(); + const [userProfile, setUserProfile] = useState({}as Item) + const items = useItems() useEffect(() => { - const profile = user && items.find(i => (i.user_created?.id === user.id) && i.layer?.itemType.name === userType); - profile ? setUserProfile(profile) : setUserProfile({id: crypto.randomUUID(), name: user?.first_name, text: ""}); + const profile = user && items.find(i => (i.user_created?.id === user.id) && i.layer?.itemType.name === userType) + profile ? setUserProfile(profile) : setUserProfile({ id: crypto.randomUUID(), name: user?.first_name, text: '' }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [user, items]) useEffect(() => { - + }, [userProfile]) - - const nameRef = useRef(null); - const [nameWidth, setNameWidth] = useState(0); - const location = useLocation(); + + const nameRef = useRef(null) + const [nameWidth, setNameWidth] = useState(0) + const location = useLocation() const [showNav, setShowNav] = useState(false) - - useEffect(() => { - showNav && nameRef && setNameWidth(nameRef.current.scrollWidth) + showNav && nameRef && setNameWidth(nameRef.current.scrollWidth) }, [nameRef, appName, showNav]) - - - useEffect(() => { - const params = new URLSearchParams(location.search); - const embedded = params.get("embedded"); - embedded!="true" && setShowNav(true) - }, [location]); - + const params = new URLSearchParams(location.search) + const embedded = params.get('embedded') + embedded != 'true' && setShowNav(true) + }, [location]) const onLogout = () => { toast.promise( logout(), { success: { - render() { + render () { return `Bye bye` }, // other options - icon: "πŸ‘‹", + icon: 'πŸ‘‹' }, error: { - render( {data} ) { + render ({ data }) { return `${data}` - }, + } }, pending: 'logging out ..' - }); + }) } - if(showNav) return ( + if (showNav) { + return ( <>
-
-

{appName}

+
+

{appName}

- - - {isAuthenticated ? -
- + {isAuthenticated + ?
+ { userProfile?.image &&
- +
} -
{userProfile.name||user?.first_name}
+
{userProfile.name || user?.first_name}
- : -
+ :
-
+
Login
-
+
Sign Up
@@ -126,11 +115,10 @@ export default function NavBar({ appName, userType}: { appName: string, userType -
    -
  • Login
  • -
  • Sign Up
  • +
  • Login
  • +
  • Sign Up
@@ -139,6 +127,6 @@ export default function NavBar({ appName, userType}: { appName: string, userType
- ) - else return (<>) + ) + } else return (<>) } diff --git a/src/Components/AppShell/SetAssetsApi.tsx b/src/Components/AppShell/SetAssetsApi.tsx index 410d3063..e4874d47 100644 --- a/src/Components/AppShell/SetAssetsApi.tsx +++ b/src/Components/AppShell/SetAssetsApi.tsx @@ -1,15 +1,14 @@ import { useSetAssetApi } from './hooks/useAssets' -import { AssetsApi } from '../../types'; -import { useEffect } from 'react'; +import { AssetsApi } from '../../types' +import { useEffect } from 'react' -export const SetAssetsApi = ({assetsApi}:{assetsApi: AssetsApi}) => { - const setAssetsApi = useSetAssetApi(); +export const SetAssetsApi = ({ assetsApi }:{assetsApi: AssetsApi}) => { + const setAssetsApi = useSetAssetApi() - useEffect(() => { - setAssetsApi(assetsApi) + useEffect(() => { + setAssetsApi(assetsApi) // eslint-disable-next-line react-hooks/exhaustive-deps - }, [assetsApi]) - + }, [assetsApi]) return ( <> diff --git a/src/Components/AppShell/SideBar.tsx b/src/Components/AppShell/SideBar.tsx index 7b1754c5..59a9a2d5 100644 --- a/src/Components/AppShell/SideBar.tsx +++ b/src/Components/AppShell/SideBar.tsx @@ -1,13 +1,12 @@ -import { useRef, useState } from 'react' -import { useEffect } from 'react' -import { NavLink, useLocation } from 'react-router-dom'; +import { useRef, useState, useEffect } from 'react' +import { NavLink, useLocation } from 'react-router-dom' import { Sidenav, - initTE, -} from "tw-elements"; -import SidebarSubmenu from './SidebarSubmenu'; -import ChevronRightIcon from '@heroicons/react/24/outline/ChevronRightIcon'; -import * as React from 'react'; + initTE +} from 'tw-elements' +import SidebarSubmenu from './SidebarSubmenu' +import ChevronRightIcon from '@heroicons/react/24/outline/ChevronRightIcon' +import * as React from 'react' type route = { path: string; @@ -18,53 +17,46 @@ type route = { blank?: boolean } - -export function SideBar({ routes, bottomRoutes }: { routes: route[], bottomRoutes?: route[] }) { - +export function SideBar ({ routes, bottomRoutes }: { routes: route[], bottomRoutes?: route[] }) { // prevent react18 from calling useEffect twice const init = useRef(false) - const location = useLocation(); - - const [instance, setInstance] = useState(null); - const [slim, setSlim] = useState(false); - + const location = useLocation() + const [instance, setInstance] = useState(null) + const [slim, setSlim] = useState(false) const toggleSlim = () => { - setSlim(!slim); - instance.toggleSlim(); + setSlim(!slim) + instance.toggleSlim() } - - useEffect(() => { if (!init.current) { - initTE({ Sidenav }); + initTE({ Sidenav }) const instance = Sidenav.getInstance( - document.getElementById("sidenav") - ); - setInstance(instance); - instance.toggleSlim(); - init.current = true; + document.getElementById('sidenav') + ) + setInstance(instance) + instance.toggleSlim() + init.current = true } }, []) const [embedded, setEmbedded] = useState(true) - useEffect(() => { - const params = new URLSearchParams(location.search); - const embedded = params.get("embedded"); - embedded != "true" && setEmbedded(false) - }, [location]); + const params = new URLSearchParams(location.search) + const embedded = params.get('embedded') + embedded != 'true' && setEmbedded(false) + }, [location]) - const params = new URLSearchParams(window.location.search); + const params = new URLSearchParams(window.location.search) return (