From 61df31ab5abb7deda51ad6c8ed58e1edcc1efdc1 Mon Sep 17 00:00:00 2001 From: Lennart Schmidt Date: Mon, 13 Nov 2023 14:52:06 +0100 Subject: [PATCH 1/3] added console log hook for state --- hooks/useConsoleLog.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 hooks/useConsoleLog.tsx diff --git a/hooks/useConsoleLog.tsx b/hooks/useConsoleLog.tsx new file mode 100644 index 0000000..876fa96 --- /dev/null +++ b/hooks/useConsoleLog.tsx @@ -0,0 +1,9 @@ +import { useEffect } from 'react'; + +export function useConsoleLog( + state: T | null, indicator: string = "" +) { + useEffect(() => { + console.log(indicator, state); + }, [state]) +} From d169d9ce47176ec72eb60fa8b5fc07d99e7f899f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20H=C3=B6tter?= Date: Fri, 1 Dec 2023 07:15:36 +0100 Subject: [PATCH 2/3] pre websocket-auth error --- hooks/useLocalStorage.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/hooks/useLocalStorage.tsx b/hooks/useLocalStorage.tsx index aa147ae..3ba6915 100644 --- a/hooks/useLocalStorage.tsx +++ b/hooks/useLocalStorage.tsx @@ -6,9 +6,11 @@ type ItemWithExpiration = { }; export function readItemGroupFromLocalStorage(group: string): any { - const itemGroupString = localStorage.getItem(group); - if (itemGroupString) { - return JSON.parse(itemGroupString); + if (typeof localStorage !== 'undefined') { + const itemGroupString = localStorage.getItem(group); + if (itemGroupString) { + return JSON.parse(itemGroupString); + } } return {}; } @@ -28,7 +30,9 @@ export function useLocalStorage( if (item.expiration && Date.now() > item.expiration) { // Item has expired, remove it delete itemGroup[key]; - localStorage.setItem(group, JSON.stringify(itemGroup)); + if (typeof localStorage !== 'undefined') { + localStorage.setItem(group, JSON.stringify(itemGroup)); + } } else { return item.value; } @@ -45,7 +49,9 @@ export function useLocalStorage( expiration: timeoutSeconds ? Date.now() + timeoutSeconds * 1000 : null, }; itemGroup[key] = item; - localStorage.setItem(group, JSON.stringify(itemGroup)); + if (typeof localStorage !== 'undefined') { + localStorage.setItem(group, JSON.stringify(itemGroup)); + } }, [state]); return [state, setState]; From 619439e5db12835db445778aada35863d9873f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20H=C3=B6tter?= Date: Wed, 27 Dec 2023 17:17:47 +0100 Subject: [PATCH 3/3] minor change --- components/Dropdown.tsx | 7 +++---- components/InfoButton.tsx | 10 ++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/components/Dropdown.tsx b/components/Dropdown.tsx index d155db7..27502ba 100644 --- a/components/Dropdown.tsx +++ b/components/Dropdown.tsx @@ -1,11 +1,10 @@ import { Fragment, useEffect, useRef, useState } from 'react' import { Menu, Transition } from '@headlessui/react' -import { ChevronDownIcon } from '@heroicons/react/20/solid' import { DropdownProps } from '../types/dropdown'; import { combineClassNames } from '../../javascript-functions/general'; import { SELECT_ALL, checkDropdownProps, prepareDropdownOptionsToArray, setOptionsWithSearchBar } from '../helpers/dropdown-helper'; import { Tooltip } from '@nextui-org/react'; -import { IconTrashXFilled } from '@tabler/icons-react'; +import { IconChevronDown, IconTrashXFilled } from '@tabler/icons-react'; import useOnClickOutside from '../hooks/useHooks/useOnClickOutside'; export default function Dropdown(props: DropdownProps) { @@ -107,7 +106,7 @@ export default function Dropdown(props: DropdownProps) { className="h-9 w-full text-sm border-gray-300 rounded-md placeholder-italic border text-gray-900 pr-8 pl-4 truncate placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-300 focus:ring-offset-2 focus:ring-offset-gray-100" placeholder="Type to search..." /> -