🎨 Format with Biome (#1097)

This commit is contained in:
Alejandra
2024-03-17 17:28:45 +01:00
committed by GitHub
parent d4ee4db2f0
commit 94a2037f8a
31 changed files with 407 additions and 391 deletions

View File

@@ -1,4 +1,3 @@
import React from 'react'
import {
AlertDialog,
AlertDialogBody,
@@ -7,12 +6,13 @@ import {
AlertDialogHeader,
AlertDialogOverlay,
Button,
} from '@chakra-ui/react'
import { useForm } from 'react-hook-form'
import { useMutation, useQueryClient } from 'react-query'
} from "@chakra-ui/react"
import React from "react"
import { useForm } from "react-hook-form"
import { useMutation, useQueryClient } from "react-query"
import { ItemsService, UsersService } from '../../client'
import useCustomToast from '../../hooks/useCustomToast'
import { ItemsService, UsersService } from "../../client"
import useCustomToast from "../../hooks/useCustomToast"
interface DeleteProps {
type: string
@@ -31,9 +31,9 @@ const Delete: React.FC<DeleteProps> = ({ type, id, isOpen, onClose }) => {
} = useForm()
const deleteEntity = async (id: number) => {
if (type === 'Item') {
if (type === "Item") {
await ItemsService.deleteItem({ id: id })
} else if (type === 'User') {
} else if (type === "User") {
await UsersService.deleteUser({ userId: id })
} else {
throw new Error(`Unexpected type: ${type}`)
@@ -43,21 +43,21 @@ const Delete: React.FC<DeleteProps> = ({ type, id, isOpen, onClose }) => {
const mutation = useMutation(deleteEntity, {
onSuccess: () => {
showToast(
'Success',
"Success",
`The ${type.toLowerCase()} was deleted successfully.`,
'success',
"success",
)
onClose()
},
onError: () => {
showToast(
'An error occurred.',
"An error occurred.",
`An error occurred while deleting the ${type.toLowerCase()}.`,
'error',
"error",
)
},
onSettled: () => {
queryClient.invalidateQueries(type === 'Item' ? 'items' : 'users')
queryClient.invalidateQueries(type === "Item" ? "items" : "users")
},
})
@@ -71,7 +71,7 @@ const Delete: React.FC<DeleteProps> = ({ type, id, isOpen, onClose }) => {
isOpen={isOpen}
onClose={onClose}
leastDestructiveRef={cancelRef}
size={{ base: 'sm', md: 'md' }}
size={{ base: "sm", md: "md" }}
isCentered
>
<AlertDialogOverlay>
@@ -79,9 +79,9 @@ const Delete: React.FC<DeleteProps> = ({ type, id, isOpen, onClose }) => {
<AlertDialogHeader>Delete {type}</AlertDialogHeader>
<AlertDialogBody>
{type === 'User' && (
{type === "User" && (
<span>
All items associated with this user will also be{' '}
All items associated with this user will also be{" "}
<strong>permantly deleted. </strong>
</span>
)}