diff --git a/package.json b/package.json index ff1a73d..bfeab6a 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "@fortawesome/react-fontawesome": "^0.2.0", "@mui/icons-material": "^5.15.2", "@mui/material": "^5.14.11", - "@tanstack/react-query": "^4.10.3", - "@tanstack/react-query-devtools": "^4.11.0", + "@tanstack/react-query": "^5.32.0", + "@tanstack/react-query-devtools": "^5.32.0", "emoji-mart": "^5.6.0", "@types/react": "^18.3.0", "dayjs": "^1.11.10", diff --git a/src/components/ProtectedRoute.tsx b/src/components/ProtectedRoute.tsx index 88d9a33..3de50ba 100644 --- a/src/components/ProtectedRoute.tsx +++ b/src/components/ProtectedRoute.tsx @@ -17,9 +17,9 @@ const ProtectedRoute: FC = ({ role, outlet }) => { if (!user.roles.includes(role)) { //TODO: ErrorView return ( - + <>

Permission denied

-
+ ) } diff --git a/src/components/common/Modal.tsx b/src/components/common/Modal.tsx index f8285f4..b2d3306 100644 --- a/src/components/common/Modal.tsx +++ b/src/components/common/Modal.tsx @@ -1,4 +1,4 @@ -import React, { FC, ReactNode } from 'react' +import { FC, ReactNode } from 'react' import { Breakpoint, Button, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, Stack, SxProps } from '@mui/material' import { Close } from '@mui/icons-material' diff --git a/src/components/message/Message.tsx b/src/components/message/Message.tsx index 38ab79c..f68df1f 100644 --- a/src/components/message/Message.tsx +++ b/src/components/message/Message.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react' +import { FC, useState } from 'react' import { Message as MessageType } from '../../api/Message' import MessageModalDelete from './MessageModalDelete' import MessageMap from './MessageMap' diff --git a/src/components/message/MessageAttachments.tsx b/src/components/message/MessageAttachments.tsx index 5cd2b58..b76ca5a 100644 --- a/src/components/message/MessageAttachments.tsx +++ b/src/components/message/MessageAttachments.tsx @@ -1,5 +1,5 @@ import { ImageList, ImageListItem } from '@mui/material' -import React, { FC, useCallback, useState } from 'react' +import { FC, useCallback, useState } from 'react' import Lightbox from 'react-image-lightbox' import { Message } from '../../api/Message' import 'react-image-lightbox/style.css' diff --git a/src/components/message/MessageForm.tsx b/src/components/message/MessageForm.tsx index 31a05a1..f047684 100644 --- a/src/components/message/MessageForm.tsx +++ b/src/components/message/MessageForm.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback, useEffect, useState } from 'react' +import { FC, useCallback, useEffect, useState } from 'react' import { useMessageApi } from '../../api/Message' import { Ticker } from '../../api/Ticker' import { SubmitHandler, useForm } from 'react-hook-form' @@ -40,10 +40,12 @@ const MessageForm: FC = ({ ticker }) => { const [isSubmitting, setIsSubmitting] = useState(false) const [attachments, setAttachments] = useState([]) const [mapDialogOpen, setMapDialogOpen] = useState(false) + // eslint-disable-next-line @typescript-eslint/no-explicit-any const emptyMap: FeatureCollection = { type: 'FeatureCollection', features: [], } + // eslint-disable-next-line @typescript-eslint/no-explicit-any const [map, setMap] = useState>(emptyMap) /** @@ -85,6 +87,7 @@ const MessageForm: FC = ({ ticker }) => { setValue('message', message.toString() + emoji.native + ' ') } + // eslint-disable-next-line @typescript-eslint/no-explicit-any const onMapUpdate = useCallback((featureGroups: FeatureCollection) => { setMap(featureGroups) }, []) @@ -96,7 +99,7 @@ const MessageForm: FC = ({ ticker }) => { }) postMessage(ticker.id.toString(), data.message, map, uploads).finally(() => { - queryClient.invalidateQueries(['messages', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['messages', ticker.id] }) setAttachments([]) setIsSubmitting(false) }) diff --git a/src/components/message/MessageFormCounter.tsx b/src/components/message/MessageFormCounter.tsx index 2249da6..31ef395 100644 --- a/src/components/message/MessageFormCounter.tsx +++ b/src/components/message/MessageFormCounter.tsx @@ -1,6 +1,6 @@ +import { FC, useEffect, useState } from 'react' import { ChipPropsColorOverrides, Chip } from '@mui/material' import { OverridableStringUnion } from '@mui/types' -import React, { FC, useEffect, useState } from 'react' interface Props { maxLength: number diff --git a/src/components/message/MessageList.tsx b/src/components/message/MessageList.tsx index 6c508d1..99b0aa9 100644 --- a/src/components/message/MessageList.tsx +++ b/src/components/message/MessageList.tsx @@ -1,4 +1,4 @@ -import React, { FC, useEffect } from 'react' +import { FC, useEffect } from 'react' import { useInfiniteQuery } from '@tanstack/react-query' import { Ticker } from '../../api/Ticker' import { useMessageApi } from '../../api/Message' @@ -20,7 +20,10 @@ const MessageList: FC = ({ ticker }) => { return getMessages(ticker.id, pageParam) } - const { data, fetchNextPage, isFetchingNextPage, hasNextPage, status } = useInfiniteQuery(['messages', ticker.id], fetchMessages, { + const { data, fetchNextPage, isFetchingNextPage, hasNextPage, status } = useInfiniteQuery({ + queryKey: ['messages', ticker.id], + queryFn: fetchMessages, + initialPageParam: 0, getNextPageParam: lastPage => { return lastPage.data.messages.length === 10 ? lastPage.data.messages.slice(-1).pop()?.id : undefined }, @@ -50,7 +53,7 @@ const MessageList: FC = ({ ticker }) => { } }, [fetchNextPage, hasNextPage]) - if (status === 'loading') { + if (status === 'pending') { return } diff --git a/src/components/message/MessageMapModal.tsx b/src/components/message/MessageMapModal.tsx index 9e773bd..ed11ba0 100644 --- a/src/components/message/MessageMapModal.tsx +++ b/src/components/message/MessageMapModal.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react' +import { FC, useState } from 'react' import L, { FeatureGroup as FG, latLng } from 'leaflet' import { FeatureGroup, GeoJSON, MapContainer, TileLayer } from 'react-leaflet' import { EditControl } from 'react-leaflet-draw' @@ -10,7 +10,9 @@ import Modal from '../common/Modal' interface Props { open: boolean onClose: () => void + // eslint-disable-next-line @typescript-eslint/no-explicit-any onChange: (features: FeatureCollection) => void + // eslint-disable-next-line @typescript-eslint/no-explicit-any map: FeatureCollection ticker: Ticker } @@ -29,7 +31,7 @@ const MessageMapModal: FC = ({ open, onChange, onClose, map, ticker }) => const handleChange = () => { const geoJSON = new L.GeoJSON(map) geoJSON.eachLayer(layer => featureGroup.addLayer(layer)) - // @ts-ignore + // @ts-expect-error - toGeoJSON() is not part of the type definition onChange(featureGroup.toGeoJSON()) onClose() } diff --git a/src/components/message/MessageModalDelete.tsx b/src/components/message/MessageModalDelete.tsx index a1f5771..d2c000c 100644 --- a/src/components/message/MessageModalDelete.tsx +++ b/src/components/message/MessageModalDelete.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback } from 'react' +import { FC, useCallback } from 'react' import { useQueryClient } from '@tanstack/react-query' import { Message, useMessageApi } from '../../api/Message' import useAuth from '../useAuth' @@ -16,7 +16,7 @@ const MessageModalDelete: FC = ({ message, onClose, open }) => { const handleDelete = useCallback(() => { deleteMessage(message).then(() => { - queryClient.invalidateQueries(['messages', message.ticker]) + queryClient.invalidateQueries({ queryKey: ['messages', message.ticker] }) onClose() }) }, [deleteMessage, message, onClose, queryClient]) diff --git a/src/components/message/UploadButton.tsx b/src/components/message/UploadButton.tsx index e7c49da..1979d46 100644 --- a/src/components/message/UploadButton.tsx +++ b/src/components/message/UploadButton.tsx @@ -1,4 +1,4 @@ -import React, { createRef, FC, useCallback } from 'react' +import { createRef, FC, useCallback } from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { IconButton } from '@mui/material' import { Ticker } from '../../api/Ticker' @@ -23,11 +23,11 @@ const UploadButton: FC = ({ onUpload, ticker }) => { const handleUpload = (e: React.FormEvent) => { e.preventDefault() - // @ts-ignore + // @ts-expect-error files is not a property of Event const files = e.target.files as Array const formData = new FormData() for (let i = 0; i < files.length; i++) { - // @ts-ignore + // @ts-expect-error files is not a property of Event formData.append('files', files[i]) } formData.append('ticker', ticker.id.toString()) @@ -38,12 +38,12 @@ const UploadButton: FC = ({ onUpload, ticker }) => { } return ( - + <> - + ) } diff --git a/src/components/settings/InactiveSettingsCard.tsx b/src/components/settings/InactiveSettingsCard.tsx index 3c749e2..6d94f34 100644 --- a/src/components/settings/InactiveSettingsCard.tsx +++ b/src/components/settings/InactiveSettingsCard.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react' +import { FC, useState } from 'react' import { useQuery } from '@tanstack/react-query' import { useSettingsApi } from '../../api/Settings' import ErrorView from '../../views/ErrorView' @@ -14,7 +14,7 @@ const InactiveSettingsCard: FC = () => { const [formOpen, setFormOpen] = useState(false) const { token } = useAuth() const { getInactiveSettings } = useSettingsApi(token) - const { isLoading, error, data } = useQuery(['inactive_settings'], getInactiveSettings) + const { isLoading, error, data } = useQuery({ queryKey: ['inactive_settings'], queryFn: getInactiveSettings }) const handleFormOpen = () => { setFormOpen(true) diff --git a/src/components/settings/InactiveSettingsForm.tsx b/src/components/settings/InactiveSettingsForm.tsx index 24fe442..4c39c2e 100644 --- a/src/components/settings/InactiveSettingsForm.tsx +++ b/src/components/settings/InactiveSettingsForm.tsx @@ -39,7 +39,7 @@ const InactiveSettingsForm: FC = ({ name, setting, callback }) => { const onSubmit: SubmitHandler = data => { putInactiveSettings(data) - .then(() => queryClient.invalidateQueries(['inactive_settings'])) + .then(() => queryClient.invalidateQueries({ queryKey: ['inactive_settings'] })) .finally(() => callback()) } diff --git a/src/components/settings/RefreshIntervalCard.tsx b/src/components/settings/RefreshIntervalCard.tsx index 5f8285e..f8c3299 100644 --- a/src/components/settings/RefreshIntervalCard.tsx +++ b/src/components/settings/RefreshIntervalCard.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react' +import { FC, useState } from 'react' import { useQuery } from '@tanstack/react-query' import { useSettingsApi } from '../../api/Settings' import ErrorView from '../../views/ErrorView' @@ -13,7 +13,7 @@ const RefreshIntervalCard: FC = () => { const [formOpen, setFormOpen] = useState(false) const { token } = useAuth() const { getRefreshInterval } = useSettingsApi(token) - const { isLoading, error, data } = useQuery(['refresh_interval_setting'], getRefreshInterval) + const { isLoading, error, data } = useQuery({ queryKey: ['refresh_interval_setting'], queryFn: getRefreshInterval }) const handleFormOpen = () => { setFormOpen(true) diff --git a/src/components/settings/RefreshIntervalForm.tsx b/src/components/settings/RefreshIntervalForm.tsx index e4b6331..d529759 100644 --- a/src/components/settings/RefreshIntervalForm.tsx +++ b/src/components/settings/RefreshIntervalForm.tsx @@ -27,7 +27,7 @@ const RefreshIntervalForm: FC = ({ name, setting, callback }) => { const onSubmit: SubmitHandler = data => { putRefreshInterval(data.refreshInterval) - .then(() => queryClient.invalidateQueries(['refresh_interval_setting'])) + .then(() => queryClient.invalidateQueries({ queryKey: ['refresh_interval_setting'] })) .finally(() => callback()) } diff --git a/src/components/ticker/MastodonCard.tsx b/src/components/ticker/MastodonCard.tsx index 5675480..8bdbcc3 100644 --- a/src/components/ticker/MastodonCard.tsx +++ b/src/components/ticker/MastodonCard.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback, useState } from 'react' +import { FC, useCallback, useState } from 'react' import { faMastodon } from '@fortawesome/free-brands-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useQueryClient } from '@tanstack/react-query' @@ -23,13 +23,13 @@ const MastodonCard: FC = ({ ticker }) => { const handleDisconnect = useCallback(() => { deleteTickerMastodon(ticker).finally(() => { - queryClient.invalidateQueries(['ticker', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] }) }) }, [deleteTickerMastodon, queryClient, ticker]) const handleToggle = useCallback(() => { putTickerMastodon({ active: !mastodon.active }, ticker).finally(() => { - queryClient.invalidateQueries(['ticker', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] }) }) }, [mastodon.active, putTickerMastodon, queryClient, ticker]) diff --git a/src/components/ticker/MastodonForm.tsx b/src/components/ticker/MastodonForm.tsx index 2727154..d5402f4 100644 --- a/src/components/ticker/MastodonForm.tsx +++ b/src/components/ticker/MastodonForm.tsx @@ -24,7 +24,7 @@ const MastodonForm: FC = ({ callback, ticker }) => { const onSubmit: SubmitHandler = data => { putTickerMastodon(data, ticker).finally(() => { - queryClient.invalidateQueries(['ticker', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] }) callback() }) } diff --git a/src/components/ticker/TelegramCard.tsx b/src/components/ticker/TelegramCard.tsx index c17a7aa..75b2207 100644 --- a/src/components/ticker/TelegramCard.tsx +++ b/src/components/ticker/TelegramCard.tsx @@ -1,9 +1,9 @@ +import { FC, useCallback, useState } from 'react' import { faTelegram } from '@fortawesome/free-brands-svg-icons' import { faBan, faGear, faPause, faPlay } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Box, Button, Card, CardActions, CardContent, Divider, Link, Stack, Typography } from '@mui/material' import { useQueryClient } from '@tanstack/react-query' -import React, { FC, useCallback, useState } from 'react' import { Ticker, useTickerApi } from '../../api/Ticker' import useAuth from '../useAuth' import TelegramModalForm from './TelegramModalForm' @@ -21,12 +21,12 @@ const TelegramCard: FC = ({ ticker }) => { const telegram = ticker.telegram const handleToggle = useCallback(() => { - putTickerTelegram({ active: !telegram.active }, ticker).finally(() => queryClient.invalidateQueries(['ticker', ticker.id])) + putTickerTelegram({ active: !telegram.active }, ticker).finally(() => queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] })) }, [putTickerTelegram, queryClient, telegram.active, ticker]) const handleDisconnect = useCallback(() => { deleteTickerTelegram(ticker).finally(() => { - queryClient.invalidateQueries(['ticker', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] }) }) }, [deleteTickerTelegram, queryClient, ticker]) diff --git a/src/components/ticker/TelegramForm.tsx b/src/components/ticker/TelegramForm.tsx index 1204ef7..6d4eca5 100644 --- a/src/components/ticker/TelegramForm.tsx +++ b/src/components/ticker/TelegramForm.tsx @@ -29,7 +29,7 @@ const TelegramForm: FC = ({ callback, ticker }) => { const onSubmit: SubmitHandler = data => { putTickerTelegram(data, ticker).finally(() => { - queryClient.invalidateQueries(['ticker', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] }) callback() }) } diff --git a/src/components/ticker/Ticker.tsx b/src/components/ticker/Ticker.tsx index cfb7982..8765583 100644 --- a/src/components/ticker/Ticker.tsx +++ b/src/components/ticker/Ticker.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react' +import { FC, useState } from 'react' import { Ticker as Model } from '../../api/Ticker' import MessageForm from '../message/MessageForm' import TickerCard from './TickerCard' diff --git a/src/components/ticker/TickerDangerZoneCard.tsx b/src/components/ticker/TickerDangerZoneCard.tsx index f7f4d81..1dfc777 100644 --- a/src/components/ticker/TickerDangerZoneCard.tsx +++ b/src/components/ticker/TickerDangerZoneCard.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react' +import { FC, useState } from 'react' import { Box, Button, Card, CardContent, Typography } from '@mui/material' import { Ticker } from '../../api/Ticker' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' diff --git a/src/components/ticker/TickerForm.tsx b/src/components/ticker/TickerForm.tsx index 99f4864..3e9dffe 100644 --- a/src/components/ticker/TickerForm.tsx +++ b/src/components/ticker/TickerForm.tsx @@ -85,13 +85,13 @@ const TickerForm: FC = ({ callback, id, ticker }) => { const onSubmit: SubmitHandler = data => { if (ticker) { putTicker(data, ticker.id).finally(() => { - queryClient.invalidateQueries(['tickers']) - queryClient.invalidateQueries(['ticker', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['tickers'] }) + queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] }) callback() }) } else { postTicker(data).finally(() => { - queryClient.invalidateQueries(['tickers']) + queryClient.invalidateQueries({ queryKey: ['tickers'] }) callback() }) } diff --git a/src/components/ticker/TickerList.tsx b/src/components/ticker/TickerList.tsx index c7279b7..f19dcc7 100644 --- a/src/components/ticker/TickerList.tsx +++ b/src/components/ticker/TickerList.tsx @@ -11,7 +11,7 @@ import { Card, CardContent, Table, TableCell, TableContainer, TableHead, TableRo const TickerList: FC = () => { const { token, user } = useAuth() const { getTickers } = useTickerApi(token) - const { isLoading, error, data } = useQuery(['tickers'], getTickers) + const { isLoading, error, data } = useQuery({ queryKey: ['tickers'], queryFn: getTickers }) if (isLoading) { return diff --git a/src/components/ticker/TickerModalDelete.tsx b/src/components/ticker/TickerModalDelete.tsx index 1a6e1ab..72fbab5 100644 --- a/src/components/ticker/TickerModalDelete.tsx +++ b/src/components/ticker/TickerModalDelete.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback } from 'react' +import { FC, useCallback } from 'react' import { useQueryClient } from '@tanstack/react-query' import { Ticker, useTickerApi } from '../../api/Ticker' import useAuth from '../useAuth' @@ -17,7 +17,7 @@ const TickerModalDelete: FC = ({ open, onClose, ticker }) => { const handleDelete = useCallback(() => { deleteTicker(ticker).finally(() => { - queryClient.invalidateQueries(['tickers']) + queryClient.invalidateQueries({ queryKey: ['tickers'] }) }) }, [deleteTicker, ticker, queryClient]) diff --git a/src/components/ticker/TickerResetModal.tsx b/src/components/ticker/TickerResetModal.tsx index d68a0b4..cdf8be8 100644 --- a/src/components/ticker/TickerResetModal.tsx +++ b/src/components/ticker/TickerResetModal.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback } from 'react' +import { FC, useCallback } from 'react' import { Ticker, useTickerApi } from '../../api/Ticker' import useAuth from '../useAuth' import { useQueryClient } from '@tanstack/react-query' @@ -18,9 +18,9 @@ const TickerResetModal: FC = ({ onClose, open, ticker }) => { const handleReset = useCallback(() => { putTickerReset(ticker) .then(() => { - queryClient.invalidateQueries(['messages', ticker.id]) - queryClient.invalidateQueries(['tickerUsers', ticker.id]) - queryClient.invalidateQueries(['ticker', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['messages', ticker.id] }) + queryClient.invalidateQueries({ queryKey: ['tickerUsers', ticker.id] }) + queryClient.invalidateQueries({ queryKey: ['ticker', ticker.id] }) }) .finally(() => { onClose() diff --git a/src/components/ticker/TickerUserListItem.tsx b/src/components/ticker/TickerUserListItem.tsx index 403cf3a..beeaf97 100644 --- a/src/components/ticker/TickerUserListItem.tsx +++ b/src/components/ticker/TickerUserListItem.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react' +import { FC, useState } from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { IconButton, ListItem, ListItemIcon, ListItemText } from '@mui/material' import { Ticker } from '../../api/Ticker' diff --git a/src/components/ticker/TickerUserModalDelete.tsx b/src/components/ticker/TickerUserModalDelete.tsx index bf64362..7f6f52c 100644 --- a/src/components/ticker/TickerUserModalDelete.tsx +++ b/src/components/ticker/TickerUserModalDelete.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback } from 'react' +import { FC, useCallback } from 'react' import { useQueryClient } from '@tanstack/react-query' import { Ticker, useTickerApi } from '../../api/Ticker' import { User } from '../../api/User' @@ -19,7 +19,7 @@ const TickerUserModalDelete: FC = ({ open, onClose, ticker, user }) => { const handleDelete = useCallback(() => { deleteTickerUser(ticker, user).finally(() => { - queryClient.invalidateQueries(['tickerUsers', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['tickerUsers', ticker.id] }) onClose() }) }, [deleteTickerUser, ticker, user, queryClient, onClose]) diff --git a/src/components/ticker/TickerUsersCard.tsx b/src/components/ticker/TickerUsersCard.tsx index 85ea67b..6fbc291 100644 --- a/src/components/ticker/TickerUsersCard.tsx +++ b/src/components/ticker/TickerUsersCard.tsx @@ -1,4 +1,4 @@ -import React, { FC, useState } from 'react' +import { FC, useState } from 'react' import { useQuery } from '@tanstack/react-query' import { Ticker, useTickerApi } from '../../api/Ticker' import TickerUserList from './TickerUserList' @@ -18,8 +18,11 @@ const TickerUsersCard: FC = ({ ticker }) => { const { token } = useAuth() const { getTickerUsers } = useTickerApi(token) const [formOpen, setFormOpen] = useState(false) - const { isLoading, error, data } = useQuery(['tickerUsers', ticker.id], () => { - return getTickerUsers(ticker) + const { isLoading, error, data } = useQuery({ + queryKey: ['tickerUsers', ticker.id], + queryFn: () => { + return getTickerUsers(ticker) + }, }) if (isLoading) { diff --git a/src/components/ticker/TickerUsersForm.tsx b/src/components/ticker/TickerUsersForm.tsx index baa5ae9..f89a267 100644 --- a/src/components/ticker/TickerUsersForm.tsx +++ b/src/components/ticker/TickerUsersForm.tsx @@ -1,4 +1,4 @@ -import React, { FC, useEffect, useState } from 'react' +import { FC, useEffect, useState } from 'react' import { SubmitHandler, useForm } from 'react-hook-form' import { useQueryClient } from '@tanstack/react-query' import { Ticker, useTickerApi } from '../../api/Ticker' @@ -36,7 +36,7 @@ const TickerUsersForm: FC = ({ onSubmit, ticker, defaultValue }) => { const updateTickerUsers: SubmitHandler = () => { putTickerUsers(ticker, users).then(() => { - queryClient.invalidateQueries(['tickerUsers', ticker.id]) + queryClient.invalidateQueries({ queryKey: ['tickerUsers', ticker.id] }) onSubmit() }) } diff --git a/src/components/ticker/TickersDropdown.tsx b/src/components/ticker/TickersDropdown.tsx index 1a48a70..d4f5b55 100644 --- a/src/components/ticker/TickersDropdown.tsx +++ b/src/components/ticker/TickersDropdown.tsx @@ -1,4 +1,4 @@ -import React, { FC, useEffect, useState } from 'react' +import { FC, useEffect, useState } from 'react' import { Box, Chip, FormControl, InputLabel, MenuItem, OutlinedInput, Select, SelectChangeEvent, SxProps, useTheme } from '@mui/material' import { Ticker, useTickerApi } from '../../api/Ticker' import useAuth from '../useAuth' diff --git a/src/components/useAuth.tsx b/src/components/useAuth.tsx index b6faf74..3fd2875 100644 --- a/src/components/useAuth.tsx +++ b/src/components/useAuth.tsx @@ -1,4 +1,4 @@ -import React, { createContext, ReactNode, useCallback, useContext, useEffect, useMemo, useState } from 'react' +import { createContext, ReactNode, useCallback, useContext, useEffect, useMemo, useState } from 'react' import { login as loginApi } from '../api/Auth' import { useLocation, useNavigate } from 'react-router' import { jwtDecode } from 'jwt-decode' diff --git a/src/components/useFeature.tsx b/src/components/useFeature.tsx index 2649cf7..23a3f71 100644 --- a/src/components/useFeature.tsx +++ b/src/components/useFeature.tsx @@ -1,4 +1,4 @@ -import React, { createContext, ReactNode, useContext, useEffect, useMemo, useState } from 'react' +import { createContext, ReactNode, useContext, useEffect, useMemo, useState } from 'react' import { Features, useFeatureApi } from '../api/Features' import useAuth from './useAuth' diff --git a/src/components/user/UserForm.tsx b/src/components/user/UserForm.tsx index 4c209cf..7671b4a 100644 --- a/src/components/user/UserForm.tsx +++ b/src/components/user/UserForm.tsx @@ -1,4 +1,4 @@ -import React, { FC, useEffect } from 'react' +import { FC, useEffect } from 'react' import { SubmitHandler, useForm } from 'react-hook-form' import { User, useUserApi } from '../../api/User' import { useQueryClient } from '@tanstack/react-query' @@ -51,12 +51,12 @@ const UserForm: FC = ({ id, user, callback }) => { if (user) { putUser(formData, user).finally(() => { - queryClient.invalidateQueries(['users']) + queryClient.invalidateQueries({ queryKey: ['users'] }) callback() }) } else { postUser(formData).finally(() => { - queryClient.invalidateQueries(['users']) + queryClient.invalidateQueries({ queryKey: ['users'] }) callback() }) } diff --git a/src/components/user/UserList.tsx b/src/components/user/UserList.tsx index 9fc5bc5..6a473c4 100644 --- a/src/components/user/UserList.tsx +++ b/src/components/user/UserList.tsx @@ -10,7 +10,7 @@ import Loader from '../Loader' const UserList: FC = () => { const { token } = useAuth() const { getUsers } = useUserApi(token) - const { isLoading, error, data } = useQuery(['users'], getUsers) + const { isLoading, error, data } = useQuery({ queryKey: ['users'], queryFn: getUsers }) if (isLoading) { return diff --git a/src/components/user/UserModalDelete.tsx b/src/components/user/UserModalDelete.tsx index 64edba9..00d6049 100644 --- a/src/components/user/UserModalDelete.tsx +++ b/src/components/user/UserModalDelete.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback } from 'react' +import { FC, useCallback } from 'react' import { useQueryClient } from '@tanstack/react-query' import { User, useUserApi } from '../../api/User' import useAuth from '../useAuth' @@ -17,7 +17,7 @@ const UserModalDelete: FC = ({ onClose, open, user }) => { const handleDelete = useCallback(() => { deleteUser(user).finally(() => { - queryClient.invalidateQueries(['users']) + queryClient.invalidateQueries({ queryKey: ['users'] }) onClose() }) }, [deleteUser, user, queryClient, onClose]) diff --git a/src/views/ErrorView.tsx b/src/views/ErrorView.tsx index 712a307..87fd965 100644 --- a/src/views/ErrorView.tsx +++ b/src/views/ErrorView.tsx @@ -11,7 +11,7 @@ const ErrorView: FC = ({ children, queryKey }) => { const queryClient = useQueryClient() const handleClick = () => { - queryClient.invalidateQueries(queryKey) + queryClient.invalidateQueries({ queryKey: queryKey }) } return ( diff --git a/src/views/LoginView.tsx b/src/views/LoginView.tsx index b28c9cb..0119d38 100644 --- a/src/views/LoginView.tsx +++ b/src/views/LoginView.tsx @@ -1,5 +1,5 @@ import { Alert, Box, Button, Container, Grid, Paper, TextField, Typography } from '@mui/material' -import React, { FC, useEffect } from 'react' +import { FC, useEffect } from 'react' import { SubmitHandler, useForm } from 'react-hook-form' import { useNavigate } from 'react-router' import useAuth from '../components/useAuth' diff --git a/src/views/TickerView.tsx b/src/views/TickerView.tsx index 6edaa8c..638de55 100644 --- a/src/views/TickerView.tsx +++ b/src/views/TickerView.tsx @@ -18,7 +18,10 @@ const TickerView: FC = () => { const { tickerId } = useParams() as TickerViewParams const tickerIdNum = parseInt(tickerId) - const { isLoading, error, data } = useQuery(['ticker', tickerIdNum], () => getTicker(tickerIdNum)) + const { isLoading, error, data } = useQuery({ + queryKey: ['ticker', tickerIdNum], + queryFn: () => getTicker(tickerIdNum), + }) if (isLoading) { return diff --git a/src/views/UsersView.tsx b/src/views/UsersView.tsx index 4c0df23..2b4350e 100644 --- a/src/views/UsersView.tsx +++ b/src/views/UsersView.tsx @@ -1,7 +1,7 @@ import { faPlus } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { Button, Card, Grid, Stack, Typography } from '@mui/material' -import React, { FC, useState } from 'react' +import { FC, useState } from 'react' import UserList from '../components/user/UserList' import UserModalForm from '../components/user/UserModalForm' import Layout from './Layout' diff --git a/yarn.lock b/yarn.lock index 0315bfd..cbe410c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -905,34 +905,29 @@ resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e" integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA== -"@tanstack/match-sorter-utils@^8.1.1": - version "8.5.14" - resolved "https://registry.yarnpkg.com/@tanstack/match-sorter-utils/-/match-sorter-utils-8.5.14.tgz#12efcd536abe491d09521e0242bc4d51442f8a8a" - integrity sha512-lVNhzTcOJ2bZ4IU+PeCPQ36vowBHvviJb2ZfdRFX5uhy7G0jM8N34zAMbmS5ZmVH8D2B7oU82OWo0e/5ZFzQrw== - dependencies: - remove-accents "0.4.2" +"@tanstack/query-core@5.32.0": + version "5.32.0" + resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-5.32.0.tgz#e097ec2b394a2f64de33c98cd8baf3525c99641a" + integrity sha512-Z3flEgCat55DRXU5UMwYU1U+DgFZKA3iufyOKs+II7iRAo0uXkeU7PH5e6sOH1CGEag0IpKmZxlUFpCg6roSKw== -"@tanstack/query-core@4.10.3": - version "4.10.3" - resolved "https://registry.yarnpkg.com/@tanstack/query-core/-/query-core-4.10.3.tgz#a6477bab9ed1ae4561ca0a59ae06f8c615c692b7" - integrity sha512-+ME02sUmBfx3Pjd+0XtEthK8/4rVMD2jcxvnW9DSgFONpKtpjzfRzjY4ykzpDw1QEo2eoPvl7NS8J5mNI199aA== +"@tanstack/query-devtools@5.28.10": + version "5.28.10" + resolved "https://registry.yarnpkg.com/@tanstack/query-devtools/-/query-devtools-5.28.10.tgz#33e9a42dd2199fca12f0dd2d891570ecdbfd3c7b" + integrity sha512-5UN629fKa5/1K/2Pd26gaU7epxRrYiT1gy+V+pW5K6hnf1DeUKK3pANSb2eHKlecjIKIhTwyF7k9XdyE2gREvQ== -"@tanstack/react-query-devtools@^4.11.0": - version "4.11.0" - resolved "https://registry.yarnpkg.com/@tanstack/react-query-devtools/-/react-query-devtools-4.11.0.tgz#a2adf21fa644eae5b834ba4235b99818301ab702" - integrity sha512-g/414SruE0TEp4jeMYxVUSXGXCc+zMY9j0gB8Q6B91gmyPseNqs9WLkVrqxRXoQDyRvDcphVOaEANNygGx+zGg== +"@tanstack/react-query-devtools@^5.32.0": + version "5.32.0" + resolved "https://registry.yarnpkg.com/@tanstack/react-query-devtools/-/react-query-devtools-5.32.0.tgz#a3e930b9b5cdb5e52215e1314d28a50202589e72" + integrity sha512-KWrzLoUjs9JtDSH3H2qbm5MjjykyAT8DkvP8tukw3gBG4ziu5WaWHciBjMsYSe1JB79AOxxGovzjW/Cd9+ofVw== dependencies: - "@tanstack/match-sorter-utils" "^8.1.1" - superjson "^1.10.0" - use-sync-external-store "^1.2.0" + "@tanstack/query-devtools" "5.28.10" -"@tanstack/react-query@^4.10.3": - version "4.10.3" - resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-4.10.3.tgz#294deefa0fb6ada88bc4631d346ef5d5551c5443" - integrity sha512-4OEJjkcsCTmG3ui7RjsVzsXerWQvInTe95CBKFyOV/GchMUlNztoFnnYmlMhX7hLUqJMhbG9l7M507V7+xU8Hw== +"@tanstack/react-query@^5.32.0": + version "5.32.0" + resolved "https://registry.yarnpkg.com/@tanstack/react-query/-/react-query-5.32.0.tgz#52d441e7ad2a0098dc426f3834f68150c13f265b" + integrity sha512-+E3UudQtarnx9A6xhpgMZapyF+aJfNBGFMgI459FnduEZqT/9KhOWnMOneZahLRt52yzskSA0AuOyLkXHK0yBA== dependencies: - "@tanstack/query-core" "4.10.3" - use-sync-external-store "^1.2.0" + "@tanstack/query-core" "5.32.0" "@testing-library/dom@^10.0.0": version "10.0.0" @@ -1781,13 +1776,6 @@ convert-source-map@^2.0.0: resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-2.0.0.tgz#4b560f649fc4e918dd0ab75cf4961e8bc882d82a" integrity sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg== -copy-anything@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/copy-anything/-/copy-anything-3.0.2.tgz#7189171ff5e1893b2287e8bf574b8cd448ed50b1" - integrity sha512-CzATjGXzUQ0EvuvgOCI6A4BGOo2bcVx8B+eC2nF862iv9fopnPQwlrbACakNCHRIJbCSBj+J/9JeDf60k64MkA== - dependencies: - is-what "^4.1.6" - cosmiconfig@^7.0.0: version "7.0.1" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.1.tgz#714d756522cace867867ccb4474c5d01bbae5d6d" @@ -3347,11 +3335,6 @@ is-weakset@^2.0.1: call-bind "^1.0.2" get-intrinsic "^1.1.1" -is-what@^4.1.6: - version "4.1.7" - resolved "https://registry.yarnpkg.com/is-what/-/is-what-4.1.7.tgz#c41dc1d2d2d6a9285c624c2505f61849c8b1f9cc" - integrity sha512-DBVOQNiPKnGMxRMLIYSwERAS5MVY1B7xYiGnpgctsOFvVDz9f9PFXXxMcTOHuoqYp4NK9qFYQaIC1NRRxLMpBQ== - isarray@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" @@ -4694,11 +4677,6 @@ remark-rehype@^11.0.0: unified "^11.0.0" vfile "^6.0.0" -remove-accents@0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/remove-accents/-/remove-accents-0.4.2.tgz#0a43d3aaae1e80db919e07ae254b285d9e1c7bb5" - integrity sha512-7pXIJqJOq5tFgG1A2Zxti3Ht8jJF337m4sowbuHsW30ZnkQFnDzy9qBNhgzX8ZLW4+UBcXiiR7SwR6pokHsxiA== - requires-port@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" @@ -5092,13 +5070,6 @@ stylis@4.2.0: resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.2.0.tgz#79daee0208964c8fe695a42fcffcac633a211a51" integrity sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw== -superjson@^1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/superjson/-/superjson-1.10.0.tgz#279362e6c1789b0b6bdfa280e82ee43d0e0fa514" - integrity sha512-ks6I5fm5KXUbDqt4Epe1VwkKDaC9+kIj5HF7yhiHjChFne0EkFqsnTv1mdHE2IT6fq2CzLC3zeA/fw0BRIoNwA== - dependencies: - copy-anything "^3.0.2" - supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -5418,11 +5389,6 @@ url-parse@^1.5.3: querystringify "^2.1.1" requires-port "^1.0.0" -use-sync-external-store@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a" - integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA== - util-deprecate@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"