diff --git a/frontend/modify-openapi-operationids.js b/frontend/modify-openapi-operationids.js index fa222ba6cc..b22fd17f9e 100644 --- a/frontend/modify-openapi-operationids.js +++ b/frontend/modify-openapi-operationids.js @@ -1,4 +1,4 @@ -import * as fs from 'fs' +import * as fs from "node:fs" async function modifyOpenAPIFile(filePath) { try { @@ -26,11 +26,11 @@ async function modifyOpenAPIFile(filePath) { filePath, JSON.stringify(openapiContent, null, 2), ) - console.log('File successfully modified') + console.log("File successfully modified") } catch (err) { - console.error('Error:', err) + console.error("Error:", err) } } -const filePath = './openapi.json' +const filePath = "./openapi.json" modifyOpenAPIFile(filePath) diff --git a/frontend/src/components/Admin/AddUser.tsx b/frontend/src/components/Admin/AddUser.tsx index 207dc5ed08..2fa91d513a 100644 --- a/frontend/src/components/Admin/AddUser.tsx +++ b/frontend/src/components/Admin/AddUser.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { Button, Checkbox, @@ -14,13 +13,14 @@ import { ModalFooter, ModalHeader, ModalOverlay, -} from '@chakra-ui/react' -import { SubmitHandler, useForm } from 'react-hook-form' -import { useMutation, useQueryClient } from 'react-query' +} from "@chakra-ui/react" +import type React from "react" +import { type SubmitHandler, useForm } from "react-hook-form" +import { useMutation, useQueryClient } from "react-query" -import { UserCreate, UsersService } from '../../client' -import { ApiError } from '../../client/core/ApiError' -import useCustomToast from '../../hooks/useCustomToast' +import { type UserCreate, UsersService } from "../../client" +import type { ApiError } from "../../client/core/ApiError" +import useCustomToast from "../../hooks/useCustomToast" interface AddUserProps { isOpen: boolean @@ -41,13 +41,13 @@ const AddUser: React.FC = ({ isOpen, onClose }) => { getValues, formState: { errors, isSubmitting }, } = useForm({ - mode: 'onBlur', - criteriaMode: 'all', + mode: "onBlur", + criteriaMode: "all", defaultValues: { - email: '', - full_name: '', - password: '', - confirm_password: '', + email: "", + full_name: "", + password: "", + confirm_password: "", is_superuser: false, is_active: false, }, @@ -59,16 +59,16 @@ const AddUser: React.FC = ({ isOpen, onClose }) => { const mutation = useMutation(addUser, { onSuccess: () => { - showToast('Success!', 'User created successfully.', 'success') + showToast("Success!", "User created successfully.", "success") reset() onClose() }, onError: (err: ApiError) => { const errDetail = err.body?.detail - showToast('Something went wrong.', `${errDetail}`, 'error') + showToast("Something went wrong.", `${errDetail}`, "error") }, onSettled: () => { - queryClient.invalidateQueries('users') + queryClient.invalidateQueries("users") }, }) @@ -81,7 +81,7 @@ const AddUser: React.FC = ({ isOpen, onClose }) => { @@ -93,11 +93,11 @@ const AddUser: React.FC = ({ isOpen, onClose }) => { Email = ({ isOpen, onClose }) => { Full name @@ -123,11 +123,11 @@ const AddUser: React.FC = ({ isOpen, onClose }) => { Set Password = ({ isOpen, onClose }) => { Confirm Password value === getValues().password || - 'The passwords do not match', + "The passwords do not match", })} placeholder="Password" type="password" @@ -162,12 +162,12 @@ const AddUser: React.FC = ({ isOpen, onClose }) => { - + Is superuser? - + Is active? diff --git a/frontend/src/components/Admin/EditUser.tsx b/frontend/src/components/Admin/EditUser.tsx index dd52241857..f852972d44 100644 --- a/frontend/src/components/Admin/EditUser.tsx +++ b/frontend/src/components/Admin/EditUser.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { Button, Checkbox, @@ -14,12 +13,18 @@ import { ModalFooter, ModalHeader, ModalOverlay, -} from '@chakra-ui/react' -import { SubmitHandler, useForm } from 'react-hook-form' -import { useMutation, useQueryClient } from 'react-query' +} from "@chakra-ui/react" +import type React from "react" +import { type SubmitHandler, useForm } from "react-hook-form" +import { useMutation, useQueryClient } from "react-query" -import { ApiError, UserOut, UserUpdate, UsersService } from '../../client' -import useCustomToast from '../../hooks/useCustomToast' +import { + type ApiError, + type UserOut, + type UserUpdate, + UsersService, +} from "../../client" +import useCustomToast from "../../hooks/useCustomToast" interface EditUserProps { user: UserOut @@ -42,8 +47,8 @@ const EditUser: React.FC = ({ user, isOpen, onClose }) => { getValues, formState: { errors, isSubmitting, isDirty }, } = useForm({ - mode: 'onBlur', - criteriaMode: 'all', + mode: "onBlur", + criteriaMode: "all", defaultValues: user, }) @@ -53,20 +58,20 @@ const EditUser: React.FC = ({ user, isOpen, onClose }) => { const mutation = useMutation(updateUser, { onSuccess: () => { - showToast('Success!', 'User updated successfully.', 'success') + showToast("Success!", "User updated successfully.", "success") onClose() }, onError: (err: ApiError) => { const errDetail = err.body?.detail - showToast('Something went wrong.', `${errDetail}`, 'error') + showToast("Something went wrong.", `${errDetail}`, "error") }, onSettled: () => { - queryClient.invalidateQueries('users') + queryClient.invalidateQueries("users") }, }) const onSubmit: SubmitHandler = async (data) => { - if (data.password === '') { + if (data.password === "") { data.password = undefined } mutation.mutate(data) @@ -82,7 +87,7 @@ const EditUser: React.FC = ({ user, isOpen, onClose }) => { @@ -94,11 +99,11 @@ const EditUser: React.FC = ({ user, isOpen, onClose }) => { Email = ({ user, isOpen, onClose }) => { Full name - + Set Password = ({ user, isOpen, onClose }) => { Confirm Password value === getValues().password || - 'The passwords do not match', + "The passwords do not match", })} placeholder="Password" type="password" @@ -149,12 +154,12 @@ const EditUser: React.FC = ({ user, isOpen, onClose }) => { - + Is superuser? - + Is active? diff --git a/frontend/src/components/Common/ActionsMenu.tsx b/frontend/src/components/Common/ActionsMenu.tsx index 94ec8c1843..359ce9d09d 100644 --- a/frontend/src/components/Common/ActionsMenu.tsx +++ b/frontend/src/components/Common/ActionsMenu.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { Button, Menu, @@ -6,14 +5,15 @@ import { MenuItem, MenuList, useDisclosure, -} from '@chakra-ui/react' -import { BsThreeDotsVertical } from 'react-icons/bs' -import { FiEdit, FiTrash } from 'react-icons/fi' +} from "@chakra-ui/react" +import type React from "react" +import { BsThreeDotsVertical } from "react-icons/bs" +import { FiEdit, FiTrash } from "react-icons/fi" -import EditUser from '../Admin/EditUser' -import EditItem from '../Items/EditItem' -import Delete from './DeleteAlert' -import { ItemOut, UserOut } from '../../client' +import type { ItemOut, UserOut } from "../../client" +import EditUser from "../Admin/EditUser" +import EditItem from "../Items/EditItem" +import Delete from "./DeleteAlert" interface ActionsMenuProps { type: string @@ -49,7 +49,7 @@ const ActionsMenu: React.FC = ({ type, value, disabled }) => { Delete {type} - {type === 'User' ? ( + {type === "User" ? ( = ({ 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 = ({ 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 = ({ type, id, isOpen, onClose }) => { isOpen={isOpen} onClose={onClose} leastDestructiveRef={cancelRef} - size={{ base: 'sm', md: 'md' }} + size={{ base: "sm", md: "md" }} isCentered > @@ -79,9 +79,9 @@ const Delete: React.FC = ({ type, id, isOpen, onClose }) => { Delete {type} - {type === 'User' && ( + {type === "User" && ( - All items associated with this user will also be{' '} + All items associated with this user will also be{" "} permantly deleted. )} diff --git a/frontend/src/components/Common/Navbar.tsx b/frontend/src/components/Common/Navbar.tsx index 3cecb48e2a..b0593509ce 100644 --- a/frontend/src/components/Common/Navbar.tsx +++ b/frontend/src/components/Common/Navbar.tsx @@ -1,9 +1,9 @@ -import React from 'react' -import { Button, Flex, Icon, useDisclosure } from '@chakra-ui/react' -import { FaPlus } from 'react-icons/fa' +import { Button, Flex, Icon, useDisclosure } from "@chakra-ui/react" +import type React from "react" +import { FaPlus } from "react-icons/fa" -import AddUser from '../Admin/AddUser' -import AddItem from '../Items/AddItem' +import AddUser from "../Admin/AddUser" +import AddItem from "../Items/AddItem" interface NavbarProps { type: string @@ -26,8 +26,8 @@ const Navbar: React.FC = ({ type }) => { diff --git a/frontend/src/components/Common/NotFound.tsx b/frontend/src/components/Common/NotFound.tsx index e3ce2bc4c3..1c6019c1b7 100644 --- a/frontend/src/components/Common/NotFound.tsx +++ b/frontend/src/components/Common/NotFound.tsx @@ -1,6 +1,6 @@ -import React from 'react' -import { Button, Container, Text } from '@chakra-ui/react' -import { Link } from '@tanstack/react-router' +import { Button, Container, Text } from "@chakra-ui/react" +import { Link } from "@tanstack/react-router" +import type React from "react" const NotFound: React.FC = () => { return ( diff --git a/frontend/src/components/Common/Sidebar.tsx b/frontend/src/components/Common/Sidebar.tsx index 65d0fc5349..4f92714065 100644 --- a/frontend/src/components/Common/Sidebar.tsx +++ b/frontend/src/components/Common/Sidebar.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { Box, Drawer, @@ -12,21 +11,22 @@ import { Text, useColorModeValue, useDisclosure, -} from '@chakra-ui/react' -import { FiLogOut, FiMenu } from 'react-icons/fi' -import { useQueryClient } from 'react-query' +} from "@chakra-ui/react" +import type React from "react" +import { FiLogOut, FiMenu } from "react-icons/fi" +import { useQueryClient } from "react-query" -import Logo from '../../assets/images/fastapi-logo.svg' -import { UserOut } from '../../client' -import useAuth from '../../hooks/useAuth' -import SidebarItems from './SidebarItems' +import Logo from "../../assets/images/fastapi-logo.svg" +import type { UserOut } from "../../client" +import useAuth from "../../hooks/useAuth" +import SidebarItems from "./SidebarItems" const Sidebar: React.FC = () => { const queryClient = useQueryClient() - const bgColor = useColorModeValue('ui.white', 'ui.dark') - const textColor = useColorModeValue('ui.dark', 'ui.white') - const secBgColor = useColorModeValue('ui.secondary', 'ui.darkSlate') - const currentUser = queryClient.getQueryData('currentUser') + const bgColor = useColorModeValue("ui.white", "ui.dark") + const textColor = useColorModeValue("ui.dark", "ui.white") + const secBgColor = useColorModeValue("ui.secondary", "ui.darkSlate") + const currentUser = queryClient.getQueryData("currentUser") const { isOpen, onOpen, onClose } = useDisclosure() const { logout } = useAuth() @@ -39,7 +39,7 @@ const Sidebar: React.FC = () => { {/* Mobile */} { h="100vh" position="sticky" top="0" - display={{ base: 'none', md: 'flex' }} + display={{ base: "none", md: "flex" }} > = ({ onClose }) => { const queryClient = useQueryClient() - const textColor = useColorModeValue('ui.main', 'ui.white') - const bgActive = useColorModeValue('#E2E8F0', '#4A5568') - const currentUser = queryClient.getQueryData('currentUser') + const textColor = useColorModeValue("ui.main", "ui.white") + const bgActive = useColorModeValue("#E2E8F0", "#4A5568") + const currentUser = queryClient.getQueryData("currentUser") const finalItems = currentUser?.is_superuser - ? [...items, { icon: FiUsers, title: 'Admin', path: '/admin' }] + ? [...items, { icon: FiUsers, title: "Admin", path: "/admin" }] : items const listItems = finalItems.map((item) => ( @@ -36,7 +36,7 @@ const SidebarItems: React.FC = ({ onClose }) => { activeProps={{ style: { background: bgActive, - borderRadius: '12px', + borderRadius: "12px", }, }} color={textColor} diff --git a/frontend/src/components/Common/UserMenu.tsx b/frontend/src/components/Common/UserMenu.tsx index 1b2020a245..add861b081 100644 --- a/frontend/src/components/Common/UserMenu.tsx +++ b/frontend/src/components/Common/UserMenu.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { Box, IconButton, @@ -6,12 +5,13 @@ import { MenuButton, MenuItem, MenuList, -} from '@chakra-ui/react' -import { FaUserAstronaut } from 'react-icons/fa' -import { FiLogOut, FiUser } from 'react-icons/fi' +} from "@chakra-ui/react" +import type React from "react" +import { FaUserAstronaut } from "react-icons/fa" +import { FiLogOut, FiUser } from "react-icons/fi" -import useAuth from '../../hooks/useAuth' -import { Link } from '@tanstack/react-router' +import { Link } from "@tanstack/react-router" +import useAuth from "../../hooks/useAuth" const UserMenu: React.FC = () => { const { logout } = useAuth() @@ -24,7 +24,7 @@ const UserMenu: React.FC = () => { <> {/* Desktop */} = ({ isOpen, onClose }) => { reset, formState: { errors, isSubmitting }, } = useForm({ - mode: 'onBlur', - criteriaMode: 'all', + mode: "onBlur", + criteriaMode: "all", defaultValues: { - title: '', - description: '', + title: "", + description: "", }, }) @@ -47,16 +47,16 @@ const AddItem: React.FC = ({ isOpen, onClose }) => { const mutation = useMutation(addItem, { onSuccess: () => { - showToast('Success!', 'Item created successfully.', 'success') + showToast("Success!", "Item created successfully.", "success") reset() onClose() }, onError: (err: ApiError) => { const errDetail = err.body?.detail - showToast('Something went wrong.', `${errDetail}`, 'error') + showToast("Something went wrong.", `${errDetail}`, "error") }, onSettled: () => { - queryClient.invalidateQueries('items') + queryClient.invalidateQueries("items") }, }) @@ -69,7 +69,7 @@ const AddItem: React.FC = ({ isOpen, onClose }) => { @@ -81,8 +81,8 @@ const AddItem: React.FC = ({ isOpen, onClose }) => { Title = ({ isOpen, onClose }) => { Description diff --git a/frontend/src/components/Items/EditItem.tsx b/frontend/src/components/Items/EditItem.tsx index 03a0b7b2be..b1dca38ec9 100644 --- a/frontend/src/components/Items/EditItem.tsx +++ b/frontend/src/components/Items/EditItem.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { Button, FormControl, @@ -12,12 +11,18 @@ import { ModalFooter, ModalHeader, ModalOverlay, -} from '@chakra-ui/react' -import { SubmitHandler, useForm } from 'react-hook-form' +} from "@chakra-ui/react" +import type React from "react" +import { type SubmitHandler, useForm } from "react-hook-form" -import { useMutation, useQueryClient } from 'react-query' -import { ApiError, ItemOut, ItemUpdate, ItemsService } from '../../client' -import useCustomToast from '../../hooks/useCustomToast' +import { useMutation, useQueryClient } from "react-query" +import { + type ApiError, + type ItemOut, + type ItemUpdate, + ItemsService, +} from "../../client" +import useCustomToast from "../../hooks/useCustomToast" interface EditItemProps { item: ItemOut @@ -34,8 +39,8 @@ const EditItem: React.FC = ({ item, isOpen, onClose }) => { reset, formState: { isSubmitting, errors, isDirty }, } = useForm({ - mode: 'onBlur', - criteriaMode: 'all', + mode: "onBlur", + criteriaMode: "all", defaultValues: item, }) @@ -45,15 +50,15 @@ const EditItem: React.FC = ({ item, isOpen, onClose }) => { const mutation = useMutation(updateItem, { onSuccess: () => { - showToast('Success!', 'Item updated successfully.', 'success') + showToast("Success!", "Item updated successfully.", "success") onClose() }, onError: (err: ApiError) => { const errDetail = err.body?.detail - showToast('Something went wrong.', `${errDetail}`, 'error') + showToast("Something went wrong.", `${errDetail}`, "error") }, onSettled: () => { - queryClient.invalidateQueries('items') + queryClient.invalidateQueries("items") }, }) @@ -71,7 +76,7 @@ const EditItem: React.FC = ({ item, isOpen, onClose }) => { @@ -83,8 +88,8 @@ const EditItem: React.FC = ({ item, isOpen, onClose }) => { Title @@ -96,7 +101,7 @@ const EditItem: React.FC = ({ item, isOpen, onClose }) => { Description diff --git a/frontend/src/components/UserSettings/Appearance.tsx b/frontend/src/components/UserSettings/Appearance.tsx index 100426c6c1..aa690c792f 100644 --- a/frontend/src/components/UserSettings/Appearance.tsx +++ b/frontend/src/components/UserSettings/Appearance.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { Badge, Container, @@ -7,7 +6,8 @@ import { RadioGroup, Stack, useColorMode, -} from '@chakra-ui/react' +} from "@chakra-ui/react" +import type React from "react" const Appearance: React.FC = () => { const { colorMode, toggleColorMode } = useColorMode() diff --git a/frontend/src/components/UserSettings/ChangePassword.tsx b/frontend/src/components/UserSettings/ChangePassword.tsx index 8fc9613ac6..5b28b0984d 100644 --- a/frontend/src/components/UserSettings/ChangePassword.tsx +++ b/frontend/src/components/UserSettings/ChangePassword.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { Box, Button, @@ -9,19 +8,20 @@ import { Heading, Input, useColorModeValue, -} from '@chakra-ui/react' -import { SubmitHandler, useForm } from 'react-hook-form' -import { useMutation } from 'react-query' +} from "@chakra-ui/react" +import type React from "react" +import { type SubmitHandler, useForm } from "react-hook-form" +import { useMutation } from "react-query" -import { ApiError, UpdatePassword, UsersService } from '../../client' -import useCustomToast from '../../hooks/useCustomToast' +import { type ApiError, type UpdatePassword, UsersService } from "../../client" +import useCustomToast from "../../hooks/useCustomToast" interface UpdatePasswordForm extends UpdatePassword { confirm_password: string } const ChangePassword: React.FC = () => { - const color = useColorModeValue('inherit', 'ui.white') + const color = useColorModeValue("inherit", "ui.white") const showToast = useCustomToast() const { register, @@ -30,8 +30,8 @@ const ChangePassword: React.FC = () => { getValues, formState: { errors, isSubmitting }, } = useForm({ - mode: 'onBlur', - criteriaMode: 'all', + mode: "onBlur", + criteriaMode: "all", }) const UpdatePassword = async (data: UpdatePassword) => { @@ -40,12 +40,12 @@ const ChangePassword: React.FC = () => { const mutation = useMutation(UpdatePassword, { onSuccess: () => { - showToast('Success!', 'Password updated.', 'success') + showToast("Success!", "Password updated.", "success") reset() }, onError: (err: ApiError) => { const errDetail = err.body?.detail - showToast('Something went wrong.', `${errDetail}`, 'error') + showToast("Something went wrong.", `${errDetail}`, "error") }, }) @@ -59,14 +59,14 @@ const ChangePassword: React.FC = () => { Change Password - + Current password @@ -80,11 +80,11 @@ const ChangePassword: React.FC = () => { Set Password { Confirm Password value === getValues().new_password || - 'The passwords do not match', + "The passwords do not match", })} placeholder="Password" type="password" diff --git a/frontend/src/components/UserSettings/DeleteAccount.tsx b/frontend/src/components/UserSettings/DeleteAccount.tsx index 257b99dfb5..d048c7e94b 100644 --- a/frontend/src/components/UserSettings/DeleteAccount.tsx +++ b/frontend/src/components/UserSettings/DeleteAccount.tsx @@ -1,13 +1,13 @@ -import React from 'react' import { Button, Container, Heading, Text, useDisclosure, -} from '@chakra-ui/react' +} from "@chakra-ui/react" +import type React from "react" -import DeleteConfirmation from './DeleteConfirmation' +import DeleteConfirmation from "./DeleteConfirmation" const DeleteAccount: React.FC = () => { const confirmationModal = useDisclosure() diff --git a/frontend/src/components/UserSettings/DeleteConfirmation.tsx b/frontend/src/components/UserSettings/DeleteConfirmation.tsx index ab401a3e51..1a781113a4 100644 --- a/frontend/src/components/UserSettings/DeleteConfirmation.tsx +++ b/frontend/src/components/UserSettings/DeleteConfirmation.tsx @@ -1,4 +1,3 @@ -import React from 'react' import { AlertDialog, AlertDialogBody, @@ -7,13 +6,14 @@ 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 { ApiError, UserOut, UsersService } from '../../client' -import useAuth from '../../hooks/useAuth' -import useCustomToast from '../../hooks/useCustomToast' +import { type ApiError, type UserOut, UsersService } from "../../client" +import useAuth from "../../hooks/useAuth" +import useCustomToast from "../../hooks/useCustomToast" interface DeleteProps { isOpen: boolean @@ -28,7 +28,7 @@ const DeleteConfirmation: React.FC = ({ isOpen, onClose }) => { handleSubmit, formState: { isSubmitting }, } = useForm() - const currentUser = queryClient.getQueryData('currentUser') + const currentUser = queryClient.getQueryData("currentUser") const { logout } = useAuth() const deleteCurrentUser = async (id: number) => { @@ -38,19 +38,19 @@ const DeleteConfirmation: React.FC = ({ isOpen, onClose }) => { const mutation = useMutation(deleteCurrentUser, { onSuccess: () => { showToast( - 'Success', - 'Your account has been successfully deleted.', - 'success', + "Success", + "Your account has been successfully deleted.", + "success", ) logout() onClose() }, onError: (err: ApiError) => { const errDetail = err.body?.detail - showToast('Something went wrong.', `${errDetail}`, 'error') + showToast("Something went wrong.", `${errDetail}`, "error") }, onSettled: () => { - queryClient.invalidateQueries('currentUser') + queryClient.invalidateQueries("currentUser") }, }) @@ -64,7 +64,7 @@ const DeleteConfirmation: React.FC = ({ isOpen, onClose }) => { isOpen={isOpen} onClose={onClose} leastDestructiveRef={cancelRef} - size={{ base: 'sm', md: 'md' }} + size={{ base: "sm", md: "md" }} isCentered > @@ -72,7 +72,7 @@ const DeleteConfirmation: React.FC = ({ isOpen, onClose }) => { Confirmation Required - All your account data will be{' '} + All your account data will be{" "} permanently deleted. If you are sure, please click "Confirm" to proceed. This action cannot be undone. diff --git a/frontend/src/components/UserSettings/UserInformation.tsx b/frontend/src/components/UserSettings/UserInformation.tsx index af30ba67d4..6be3b0515d 100644 --- a/frontend/src/components/UserSettings/UserInformation.tsx +++ b/frontend/src/components/UserSettings/UserInformation.tsx @@ -1,4 +1,3 @@ -import React, { useState } from 'react' import { Box, Button, @@ -11,17 +10,24 @@ import { Input, Text, useColorModeValue, -} from '@chakra-ui/react' -import { SubmitHandler, useForm } from 'react-hook-form' -import { useMutation, useQueryClient } from 'react-query' +} from "@chakra-ui/react" +import type React from "react" +import { useState } from "react" +import { type SubmitHandler, useForm } from "react-hook-form" +import { useMutation, useQueryClient } from "react-query" -import { ApiError, UserOut, UserUpdateMe, UsersService } from '../../client' -import useAuth from '../../hooks/useAuth' -import useCustomToast from '../../hooks/useCustomToast' +import { + type ApiError, + type UserOut, + type UserUpdateMe, + UsersService, +} from "../../client" +import useAuth from "../../hooks/useAuth" +import useCustomToast from "../../hooks/useCustomToast" const UserInformation: React.FC = () => { const queryClient = useQueryClient() - const color = useColorModeValue('inherit', 'ui.white') + const color = useColorModeValue("inherit", "ui.white") const showToast = useCustomToast() const [editMode, setEditMode] = useState(false) const { user: currentUser } = useAuth() @@ -32,8 +38,8 @@ const UserInformation: React.FC = () => { getValues, formState: { isSubmitting, errors, isDirty }, } = useForm({ - mode: 'onBlur', - criteriaMode: 'all', + mode: "onBlur", + criteriaMode: "all", defaultValues: { full_name: currentUser?.full_name, email: currentUser?.email, @@ -50,15 +56,15 @@ const UserInformation: React.FC = () => { const mutation = useMutation(updateInfo, { onSuccess: () => { - showToast('Success!', 'User updated successfully.', 'success') + showToast("Success!", "User updated successfully.", "success") }, onError: (err: ApiError) => { const errDetail = err.body?.detail - showToast('Something went wrong.', `${errDetail}`, 'error') + showToast("Something went wrong.", `${errDetail}`, "error") }, onSettled: () => { - queryClient.invalidateQueries('users') - queryClient.invalidateQueries('currentUser') + queryClient.invalidateQueries("users") + queryClient.invalidateQueries("currentUser") }, }) @@ -77,7 +83,7 @@ const UserInformation: React.FC = () => { User Information - + Full name @@ -85,7 +91,7 @@ const UserInformation: React.FC = () => { {editMode ? ( @@ -93,9 +99,9 @@ const UserInformation: React.FC = () => { - {currentUser?.full_name || 'N/A'} + {currentUser?.full_name || "N/A"} )} @@ -106,11 +112,11 @@ const UserInformation: React.FC = () => { {editMode ? ( { {editMode && (