fix(deps): update dependency @tanstack/react-query to v5

refactor(fe-queries): refactor useQuery calls to object syntax

refactor(fe-queries): fix types for QueryResult (unknown -> Error)
This commit is contained in:
renovate[bot] 2023-12-31 15:51:40 +00:00 committed by Marc Cataford
parent 5561e5432b
commit 99fef92a78
Signed by: marc
GPG key ID: 048E042F22B5DC79
5 changed files with 29 additions and 40 deletions

View file

@ -5,7 +5,7 @@
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.1",
"@mui/material": "^5.14.2",
"@tanstack/react-query": "^4.32.6",
"@tanstack/react-query": "^5.0.0",
"axios": "^1.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"

View file

@ -33,7 +33,7 @@ describe("FileDetails", () => {
vi.spyOn(fileQueries, "useFileDetails").mockReturnValue({
data: mockItem,
isLoading: false,
} as UseQueryResult<FileData, unknown>)
} as UseQueryResult<FileData, Error>)
const user = userEvent.setup()
const { getByLabelText, debug, rerender } = render(
@ -63,7 +63,7 @@ describe("FileDetails", () => {
vi.spyOn(fileQueries, "useFileDetails").mockReturnValue({
data: mockItem,
isLoading: false,
} as UseQueryResult<FileData, unknown>)
} as UseQueryResult<FileData, Error>)
const user = userEvent.setup()
const { getByLabelText, debug, rerender } = render(
@ -93,7 +93,7 @@ describe("FileDetails", () => {
vi.spyOn(fileQueries, "useFileDetails").mockReturnValue({
data: mockItem,
isLoading: false,
} as UseQueryResult<FileData, unknown>)
} as UseQueryResult<FileData, Error>)
const navigateMock = vi.fn().mockImplementation((a: string) => {})
vi.spyOn(locationContextUtils, "useLocationContext").mockReturnValue({

View file

@ -20,7 +20,7 @@ function LoginView() {
const [password, setPassword] = React.useState<string>("")
const { navigate } = useLocationContext()
const { mutate, isError, isLoading } = useMutation({
const { mutate, isError, isPending } = useMutation({
mutationFn: async ({
email,
password,
@ -97,7 +97,7 @@ function LoginView() {
variant="contained"
onClick={onLoginClick}
aria-label="submit login"
disabled={!isFormValid || isLoading}
disabled={!isFormValid || isPending}
>
Log in
</Button>

View file

@ -4,18 +4,24 @@ import axios from "../axios"
import { type FileData } from "../types/files"
function useOwnFileList() {
return useQuery(["file-list"], async () => {
return useQuery({
queryKey: ["file-list"],
queryFn: async () => {
const response = await axios.get<Array<FileData>>("/files/")
return response.data
},
})
}
function useFileDetails(fileId: string) {
return useQuery(["file-details", fileId], async () => {
return useQuery({
queryKey: ["file-details", fileId],
queryFn: async () => {
const response = await axios.get<FileData>(`/files/${fileId}/`)
return response.data
},
})
}

View file

@ -2120,29 +2120,21 @@ __metadata:
languageName: node
linkType: hard
"@tanstack/query-core@npm:4.36.1":
version: 4.36.1
resolution: "@tanstack/query-core@npm:4.36.1"
checksum: 7c648872cd491bcab2aa4c18e0b7ca130c072f05c277a5876977fa3bfa87634bbfde46e9d249236587d78c39866889a02e4e202b478dc6074ff96093732ae56d
"@tanstack/query-core@npm:5.17.0":
version: 5.17.0
resolution: "@tanstack/query-core@npm:5.17.0"
checksum: bc1fb9c5e78e2c844131e980dbbb9d70f0d8629446af929425a6a4dee25b86186a93deb4653c0246bac750a6214e65572aa1825cb256022ce1d010c748edd735
languageName: node
linkType: hard
"@tanstack/react-query@npm:^4.32.6":
version: 4.36.1
resolution: "@tanstack/react-query@npm:4.36.1"
"@tanstack/react-query@npm:^5.0.0":
version: 5.17.0
resolution: "@tanstack/react-query@npm:5.17.0"
dependencies:
"@tanstack/query-core": "npm:4.36.1"
use-sync-external-store: "npm:^1.2.0"
"@tanstack/query-core": "npm:5.17.0"
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
react-native: "*"
peerDependenciesMeta:
react-dom:
optional: true
react-native:
optional: true
checksum: 764b860c3ac8d254fc6b07e01054a0f58058644d59626c724b213293fbf1e31c198cbb26e4c32c0d16dcaec0353c0ae19147d9c667675b31f8cea1d64f1ff4ac
react: ^18.0.0
checksum: 76bf8e8466da4c9cb566e6e83400b8283fb924d9197dcf56154f8f444a365d6d01282a358642ac488964c4de49505886cbc29b53c716dcf5eb6d658a64372d1a
languageName: node
linkType: hard
@ -4941,7 +4933,7 @@ __metadata:
"@emotion/styled": "npm:^11.11.0"
"@mui/icons-material": "npm:^5.14.1"
"@mui/material": "npm:^5.14.2"
"@tanstack/react-query": "npm:^4.32.6"
"@tanstack/react-query": "npm:^5.0.0"
"@testing-library/dom": "npm:^9.3.3"
"@testing-library/jest-dom": "npm:^6.1.5"
"@testing-library/react": "npm:^14.1.2"
@ -5487,15 +5479,6 @@ __metadata:
languageName: node
linkType: hard
"use-sync-external-store@npm:^1.2.0":
version: 1.2.0
resolution: "use-sync-external-store@npm:1.2.0"
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
checksum: a676216affc203876bd47981103f201f28c2731361bb186367e12d287a7566763213a8816910c6eb88265eccd4c230426eb783d64c373c4a180905be8820ed8e
languageName: node
linkType: hard
"util-deprecate@npm:^1.0.1":
version: 1.0.2
resolution: "util-deprecate@npm:1.0.2"