From 9c2b88b1035d2f6034e9e448f32b44f740485bce Mon Sep 17 00:00:00 2001 From: Thastertyn Date: Thu, 13 Mar 2025 15:41:44 +0100 Subject: [PATCH] Renamed hooks on frontend and started working on shop registration --- backend/app/api/__init__.py | 3 +- backend/app/api/dependencies.py | 3 +- backend/app/api/routes/login_routes.py | 24 ++++-- backend/app/api/routes/shop/__init__.py | 2 - backend/app/api/routes/shop/shop_routes.py | 0 .../app/api/routes/shop/shop_user_routes.py | 3 +- backend/app/api/routes/shop_routes.py | 18 +++++ backend/app/api/routes/utils_routes.py | 10 ++- backend/app/crud/shop_crud.py | 23 +++++- backend/app/database/models/shop_model.py | 2 +- backend/app/main.py | 8 +- backend/app/schemas/shop_schemas.py | 8 ++ frontend/src/components/ui/toaster.tsx | 2 +- frontend/src/hooks/api/useUser.ts | 0 frontend/src/hooks/useAuth.ts | 77 +++++++++++++++++++ ...se-dialog-state.tsx => useDialogState.tsx} | 0 .../hooks/{use-mobile.tsx => useMobile.tsx} | 0 .../src/hooks/{use-toast.ts => useToast.ts} | 0 frontend/src/main.tsx | 2 +- .../pages/auth/otp/components/otp-form.tsx | 2 +- .../src/pages/chats/components/new-chat.tsx | 2 +- .../pages/settings/account/account-form.tsx | 2 +- .../settings/appearance/appearance-form.tsx | 2 +- .../pages/settings/display/display-form.tsx | 2 +- .../notifications/notifications-form.tsx | 2 +- .../pages/settings/profile/profile-form.tsx | 2 +- .../pages/tasks/components/tasks-dialogs.tsx | 2 +- .../tasks/components/tasks-import-dialog.tsx | 2 +- .../tasks/components/tasks-mutate-drawer.tsx | 2 +- .../src/pages/tasks/context/tasks-context.tsx | 2 +- .../users/components/users-action-dialog.tsx | 2 +- .../users/components/users-delete-dialog.tsx | 2 +- .../users/components/users-invite-dialog.tsx | 2 +- .../src/pages/users/context/users-context.tsx | 2 +- frontend/src/utils/handle-server-error.ts | 2 +- 35 files changed, 180 insertions(+), 37 deletions(-) delete mode 100644 backend/app/api/routes/shop/shop_routes.py create mode 100644 backend/app/api/routes/shop_routes.py create mode 100644 backend/app/schemas/shop_schemas.py delete mode 100644 frontend/src/hooks/api/useUser.ts create mode 100644 frontend/src/hooks/useAuth.ts rename frontend/src/hooks/{use-dialog-state.tsx => useDialogState.tsx} (100%) rename frontend/src/hooks/{use-mobile.tsx => useMobile.tsx} (100%) rename frontend/src/hooks/{use-toast.ts => useToast.ts} (100%) diff --git a/backend/app/api/__init__.py b/backend/app/api/__init__.py index 84ece3b..063f653 100644 --- a/backend/app/api/__init__.py +++ b/backend/app/api/__init__.py @@ -1,6 +1,6 @@ from fastapi import APIRouter -from app.api.routes import cart_routes, login_routes, shop, user_routes, utils_routes +from app.api.routes import cart_routes, login_routes, shop, user_routes, utils_routes, shop_routes api_router = APIRouter() @@ -9,3 +9,4 @@ api_router.include_router(user_routes.router) api_router.include_router(utils_routes.router) api_router.include_router(login_routes.router) api_router.include_router(shop.shop_router) +api_router.include_router(shop_routes.router) diff --git a/backend/app/api/dependencies.py b/backend/app/api/dependencies.py index 0108b73..97ff70f 100644 --- a/backend/app/api/dependencies.py +++ b/backend/app/api/dependencies.py @@ -2,7 +2,7 @@ from typing import Annotated import jwt from fastapi import Depends, HTTPException, status -from fastapi.security import OAuth2PasswordBearer +from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm from jwt.exceptions import InvalidTokenError from pydantic import ValidationError from sqlmodel import Session @@ -19,6 +19,7 @@ reusable_oauth2 = OAuth2PasswordBearer( SessionDep = Annotated[Session, Depends(get_session)] TokenDep = Annotated[str, Depends(reusable_oauth2)] +LoginDep = Annotated[OAuth2PasswordRequestForm, Depends()] def get_current_user(session: SessionDep, token: TokenDep) -> User: diff --git a/backend/app/api/routes/login_routes.py b/backend/app/api/routes/login_routes.py index 8525fcb..279c59e 100644 --- a/backend/app/api/routes/login_routes.py +++ b/backend/app/api/routes/login_routes.py @@ -1,24 +1,32 @@ from datetime import timedelta -from typing import Annotated -from fastapi import APIRouter, Depends, HTTPException -from fastapi.security import OAuth2PasswordRequestForm +from fastapi import APIRouter, HTTPException -from app.api.dependencies import SessionDep +from app.api.dependencies import LoginDep, SessionDep from app.core import security from app.core.config import settings from app.crud import user_crud from app.schemas.user_schemas import Token -router = APIRouter(tags=["Login"]) +router = APIRouter(tags=["Dashboard", "Login"]) -@router.post("/login/access-token") +@router.post("/login/access-token", include_in_schema=settings.is_local_environment, response_model=Token) def login_access_token( - session: SessionDep, form_data: Annotated[OAuth2PasswordRequestForm, Depends()] + session: SessionDep, form_data: LoginDep ) -> Token: """ - OAuth2 compatible token login, get an access token for future requests + OAuth2 compatible token login for the dashboard. + + This endpoint generates an access token required for authenticating future + requests to the dashboard section of the application. The token is valid for + a predefined expiration period. + + - **username**: User's email + - **password**: User's password + + **Note:** This login is restricted to dashboard access only and cannot be + used for tenant accounts access to shops """ user = None user = user_crud.authenticate( diff --git a/backend/app/api/routes/shop/__init__.py b/backend/app/api/routes/shop/__init__.py index f2f3c8a..3b67b30 100644 --- a/backend/app/api/routes/shop/__init__.py +++ b/backend/app/api/routes/shop/__init__.py @@ -1,5 +1,3 @@ -from typing import Annotated - from fastapi import APIRouter from app.api.routes.shop import shop_login_routes, shop_user_routes diff --git a/backend/app/api/routes/shop/shop_routes.py b/backend/app/api/routes/shop/shop_routes.py deleted file mode 100644 index e69de29..0000000 diff --git a/backend/app/api/routes/shop/shop_user_routes.py b/backend/app/api/routes/shop/shop_user_routes.py index 0c06270..88c80cd 100644 --- a/backend/app/api/routes/shop/shop_user_routes.py +++ b/backend/app/api/routes/shop/shop_user_routes.py @@ -9,7 +9,8 @@ from app.database.models.user_model import UserRole from app.schemas.user_schemas import UserRegister router = APIRouter( - prefix="/user" + prefix="/user", + tags=["User"] ) diff --git a/backend/app/api/routes/shop_routes.py b/backend/app/api/routes/shop_routes.py new file mode 100644 index 0000000..30014ab --- /dev/null +++ b/backend/app/api/routes/shop_routes.py @@ -0,0 +1,18 @@ +from fastapi import APIRouter + +from app.api.dependencies import CurrentOwnerUser, SessionDep +from app.schemas.shop_schemas import ShopCreate +from app.schemas.user_schemas import Token + +router = APIRouter(prefix="/shop", tags=["Shop"]) + + +@router.post("") +def register_new_shop( + session: SessionDep, + current_user: CurrentOwnerUser, + shop_data: ShopCreate +) -> Token: + """ + OAuth2 compatible token login, get an access token for future requests + """ diff --git a/backend/app/api/routes/utils_routes.py b/backend/app/api/routes/utils_routes.py index 4ac348c..e1e03ea 100644 --- a/backend/app/api/routes/utils_routes.py +++ b/backend/app/api/routes/utils_routes.py @@ -1,23 +1,29 @@ import logging +from fastapi import APIRouter from sqlmodel import select -from fastapi import APIRouter from app.api.dependencies import SessionDep from app.core.config import settings logger = logging.getLogger(__name__) -router = APIRouter(prefix="/utils", tags=["utils"]) +router = APIRouter(prefix="/utils", tags=["Utils"]) @router.get("/health-check/") async def health_check() -> bool: + """ + Ping the API whether it's alive or not + """ return True @router.get("/test-db/", include_in_schema=settings.is_local_environment) async def test_db(session: SessionDep) -> bool: + """ + Ping database using select 1 to see if connection works + """ try: session.exec(select(1)) return True diff --git a/backend/app/crud/shop_crud.py b/backend/app/crud/shop_crud.py index 905ce0d..25e372b 100644 --- a/backend/app/crud/shop_crud.py +++ b/backend/app/crud/shop_crud.py @@ -1,11 +1,30 @@ from typing import Optional -from uuid import UUID +from uuid import UUID, uuid4 from sqlmodel import Session, select -from app.database.models.shop_model import Shop +from app.database.models.shop_model import Shop, ShopStatus +from app.database.models.user_model import User +from app.schemas.shop_schemas import ShopCreate + def get_shop_id_from_uuid(session: Session, shop_id: int) -> Optional[UUID]: stmt = select(Shop).where(Shop.id == shop_id) db_shop = session.exec(stmt).one_or_none() return db_shop + + +def create_shop(session: Session, shop_data: ShopCreate, creator: User) -> None: + shop_uuid = uuid4() + new_shop = Shop( + uuid=shop_uuid, + owner_id=creator.id, + name=shop_data.name, + description=shop_data.description, + status=ShopStatus.INACTIVE, + contact_email=creator.email, + phone_number=creator.phone_number, + currency=shop_data.currency + ) + session.add(new_shop) + session.commit() diff --git a/backend/app/database/models/shop_model.py b/backend/app/database/models/shop_model.py index 2753a38..21639fa 100644 --- a/backend/app/database/models/shop_model.py +++ b/backend/app/database/models/shop_model.py @@ -48,7 +48,7 @@ class Shop(SQLModel, table=True): logo: Optional[str] = Field(max_length=100) contact_email: str = Field(max_length=128, nullable=False, unique=True) phone_number: str = Field(max_length=15, nullable=False) - address: str = Field(nullable=False) + address: str = Field(nullable=True) currency: str = Field(max_length=3, nullable=False) business_hours: ShopBusinessHours = Field( diff --git a/backend/app/main.py b/backend/app/main.py index 0a6ae43..408fdeb 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -8,6 +8,7 @@ from app.utils import logger logger.setup_logger() + def custom_generate_unique_id(route: APIRoute) -> str: return f"{route.tags[0]}-{route.name}" @@ -15,7 +16,12 @@ def custom_generate_unique_id(route: APIRoute) -> str: app = FastAPI( title="SWAG Shop", version="0.0.1", - generate_unique_id_function=custom_generate_unique_id + generate_unique_id_function=custom_generate_unique_id, + openapi_tags=[ + {"name": "Dashboard", "description": "Operations endpoints related the admin dashboard. Hidden in production"}, + {"name": "Shop", "description": "Shop endpoints which include also user, product and other entity management"}, + {"name": "Utils"}, + ] ) diff --git a/backend/app/schemas/shop_schemas.py b/backend/app/schemas/shop_schemas.py new file mode 100644 index 0000000..f7f788c --- /dev/null +++ b/backend/app/schemas/shop_schemas.py @@ -0,0 +1,8 @@ + +from sqlmodel import Field, SQLModel + + +class ShopCreate(SQLModel): + name: str = Field(max_length=100, nullable=False, unique=True) + description: str = Field(max_length=500, nullable=False) + currency: str = Field(max_length=3, nullable=False) diff --git a/frontend/src/components/ui/toaster.tsx b/frontend/src/components/ui/toaster.tsx index bfbe21c..ad001cb 100644 --- a/frontend/src/components/ui/toaster.tsx +++ b/frontend/src/components/ui/toaster.tsx @@ -1,4 +1,4 @@ -import { useToast } from "@/hooks/use-toast"; +import { useToast } from "@/hooks/useToast"; import { Toast, ToastClose, diff --git a/frontend/src/hooks/api/useUser.ts b/frontend/src/hooks/api/useUser.ts deleted file mode 100644 index e69de29..0000000 diff --git a/frontend/src/hooks/useAuth.ts b/frontend/src/hooks/useAuth.ts new file mode 100644 index 0000000..713c4d5 --- /dev/null +++ b/frontend/src/hooks/useAuth.ts @@ -0,0 +1,77 @@ +import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" +import { useNavigate } from "@tanstack/react-router" +import { useState } from "react" + +import { + type BodyLoginLoginAccessToken as AccessToken, + type ApiError, + LoginService, + type UserPublic, + type UserRegister, + UsersService, +} from "@/client" +import { handleError } from "@/utils" + +const isLoggedIn = () => { + return localStorage.getItem("access_token") !== null +} + +const useAuth = () => { + const [error, setError] = useState(null) + const navigate = useNavigate() + const queryClient = useQueryClient() + const { data: user } = useQuery({ + queryKey: ["currentUser"], + queryFn: UsersService.readUserMe, + enabled: isLoggedIn(), + }) + + const signUpMutation = useMutation({ + mutationFn: (data: UserRegister) => + UsersService.registerUser({ requestBody: data }), + + onSuccess: () => { + navigate({ to: "/login" }) + }, + onError: (err: ApiError) => { + handleError(err) + }, + onSettled: () => { + queryClient.invalidateQueries({ queryKey: ["users"] }) + }, + }) + + const login = async (data: AccessToken) => { + const response = await LoginService.loginAccessToken({ + formData: data, + }) + localStorage.setItem("access_token", response.access_token) + } + + const loginMutation = useMutation({ + mutationFn: login, + onSuccess: () => { + navigate({ to: "/" }) + }, + onError: (err: ApiError) => { + handleError(err) + }, + }) + + const logout = () => { + localStorage.removeItem("access_token") + navigate({ to: "/login" }) + } + + return { + signUpMutation, + loginMutation, + logout, + user, + error, + resetError: () => setError(null), + } +} + +export { isLoggedIn } +export default useAuth diff --git a/frontend/src/hooks/use-dialog-state.tsx b/frontend/src/hooks/useDialogState.tsx similarity index 100% rename from frontend/src/hooks/use-dialog-state.tsx rename to frontend/src/hooks/useDialogState.tsx diff --git a/frontend/src/hooks/use-mobile.tsx b/frontend/src/hooks/useMobile.tsx similarity index 100% rename from frontend/src/hooks/use-mobile.tsx rename to frontend/src/hooks/useMobile.tsx diff --git a/frontend/src/hooks/use-toast.ts b/frontend/src/hooks/useToast.ts similarity index 100% rename from frontend/src/hooks/use-toast.ts rename to frontend/src/hooks/useToast.ts diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index b02caf4..8c8f27e 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -9,7 +9,7 @@ import { import { RouterProvider, createRouter } from "@tanstack/react-router"; import { useAuthStore } from "@/stores/authStore"; import { handleServerError } from "@/utils/handle-server-error"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { FontProvider } from "./context/font-context"; import { ThemeProvider } from "./context/theme-context"; import "./index.css"; diff --git a/frontend/src/pages/auth/otp/components/otp-form.tsx b/frontend/src/pages/auth/otp/components/otp-form.tsx index 2863a19..eacd93e 100644 --- a/frontend/src/pages/auth/otp/components/otp-form.tsx +++ b/frontend/src/pages/auth/otp/components/otp-form.tsx @@ -4,7 +4,7 @@ import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { useNavigate } from "@tanstack/react-router"; import { cn } from "@/lib/utils"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button } from "@/components/ui/button"; import { Form, diff --git a/frontend/src/pages/chats/components/new-chat.tsx b/frontend/src/pages/chats/components/new-chat.tsx index 2b5cabd..0736435 100644 --- a/frontend/src/pages/chats/components/new-chat.tsx +++ b/frontend/src/pages/chats/components/new-chat.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; import { IconCheck, IconX } from "@tabler/icons-react"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { diff --git a/frontend/src/pages/settings/account/account-form.tsx b/frontend/src/pages/settings/account/account-form.tsx index b9ce5f9..e9d9ef8 100644 --- a/frontend/src/pages/settings/account/account-form.tsx +++ b/frontend/src/pages/settings/account/account-form.tsx @@ -4,7 +4,7 @@ import { useForm } from "react-hook-form"; import { CalendarIcon, CaretSortIcon, CheckIcon } from "@radix-ui/react-icons"; import { zodResolver } from "@hookform/resolvers/zod"; import { cn } from "@/lib/utils"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button } from "@/components/ui/button"; import { Calendar } from "@/components/ui/calendar"; import { diff --git a/frontend/src/pages/settings/appearance/appearance-form.tsx b/frontend/src/pages/settings/appearance/appearance-form.tsx index c10e522..bd601c6 100644 --- a/frontend/src/pages/settings/appearance/appearance-form.tsx +++ b/frontend/src/pages/settings/appearance/appearance-form.tsx @@ -6,7 +6,7 @@ import { fonts } from "@/config/fonts"; import { cn } from "@/lib/utils"; import { useFont } from "@/context/font-context"; import { useTheme } from "@/context/theme-context"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button, buttonVariants } from "@/components/ui/button"; import { Form, diff --git a/frontend/src/pages/settings/display/display-form.tsx b/frontend/src/pages/settings/display/display-form.tsx index c137647..66201a0 100644 --- a/frontend/src/pages/settings/display/display-form.tsx +++ b/frontend/src/pages/settings/display/display-form.tsx @@ -1,7 +1,7 @@ import { z } from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { diff --git a/frontend/src/pages/settings/notifications/notifications-form.tsx b/frontend/src/pages/settings/notifications/notifications-form.tsx index 4f99984..67383f4 100644 --- a/frontend/src/pages/settings/notifications/notifications-form.tsx +++ b/frontend/src/pages/settings/notifications/notifications-form.tsx @@ -2,7 +2,7 @@ import { z } from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { Link } from "@tanstack/react-router"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { diff --git a/frontend/src/pages/settings/profile/profile-form.tsx b/frontend/src/pages/settings/profile/profile-form.tsx index 21e4d6a..cb3f5ea 100644 --- a/frontend/src/pages/settings/profile/profile-form.tsx +++ b/frontend/src/pages/settings/profile/profile-form.tsx @@ -3,7 +3,7 @@ import { useFieldArray, useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { Link } from "@tanstack/react-router"; import { cn } from "@/lib/utils"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button } from "@/components/ui/button"; import { Form, diff --git a/frontend/src/pages/tasks/components/tasks-dialogs.tsx b/frontend/src/pages/tasks/components/tasks-dialogs.tsx index 8482cc0..ffcde1b 100644 --- a/frontend/src/pages/tasks/components/tasks-dialogs.tsx +++ b/frontend/src/pages/tasks/components/tasks-dialogs.tsx @@ -1,4 +1,4 @@ -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { ConfirmDialog } from "@/components/confirm-dialog"; import { useTasks } from "../context/tasks-context"; import { TasksImportDialog } from "./tasks-import-dialog"; diff --git a/frontend/src/pages/tasks/components/tasks-import-dialog.tsx b/frontend/src/pages/tasks/components/tasks-import-dialog.tsx index 1d1a20c..c9befc9 100644 --- a/frontend/src/pages/tasks/components/tasks-import-dialog.tsx +++ b/frontend/src/pages/tasks/components/tasks-import-dialog.tsx @@ -1,7 +1,7 @@ import { z } from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button } from "@/components/ui/button"; import { Dialog, diff --git a/frontend/src/pages/tasks/components/tasks-mutate-drawer.tsx b/frontend/src/pages/tasks/components/tasks-mutate-drawer.tsx index d0c24ec..574322a 100644 --- a/frontend/src/pages/tasks/components/tasks-mutate-drawer.tsx +++ b/frontend/src/pages/tasks/components/tasks-mutate-drawer.tsx @@ -1,7 +1,7 @@ import { z } from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button } from "@/components/ui/button"; import { Form, diff --git a/frontend/src/pages/tasks/context/tasks-context.tsx b/frontend/src/pages/tasks/context/tasks-context.tsx index ea616c9..590bebf 100644 --- a/frontend/src/pages/tasks/context/tasks-context.tsx +++ b/frontend/src/pages/tasks/context/tasks-context.tsx @@ -1,5 +1,5 @@ import React, { useState } from "react"; -import useDialogState from "@/hooks/use-dialog-state"; +import useDialogState from "@/hooks/useDialogState"; import { Task } from "../data/schema"; type TasksDialogType = "create" | "update" | "delete" | "import"; diff --git a/frontend/src/pages/users/components/users-action-dialog.tsx b/frontend/src/pages/users/components/users-action-dialog.tsx index 719bc97..07c340e 100644 --- a/frontend/src/pages/users/components/users-action-dialog.tsx +++ b/frontend/src/pages/users/components/users-action-dialog.tsx @@ -3,7 +3,7 @@ import { z } from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button } from "@/components/ui/button"; import { Dialog, diff --git a/frontend/src/pages/users/components/users-delete-dialog.tsx b/frontend/src/pages/users/components/users-delete-dialog.tsx index 53b60f0..bdfbc3a 100644 --- a/frontend/src/pages/users/components/users-delete-dialog.tsx +++ b/frontend/src/pages/users/components/users-delete-dialog.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import { IconAlertTriangle } from "@tabler/icons-react"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; diff --git a/frontend/src/pages/users/components/users-invite-dialog.tsx b/frontend/src/pages/users/components/users-invite-dialog.tsx index 076ae5b..d5a2810 100644 --- a/frontend/src/pages/users/components/users-invite-dialog.tsx +++ b/frontend/src/pages/users/components/users-invite-dialog.tsx @@ -2,7 +2,7 @@ import { z } from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; import { IconMailPlus, IconSend } from "@tabler/icons-react"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; import { Button } from "@/components/ui/button"; import { Dialog, diff --git a/frontend/src/pages/users/context/users-context.tsx b/frontend/src/pages/users/context/users-context.tsx index e48d6c3..64c74c4 100644 --- a/frontend/src/pages/users/context/users-context.tsx +++ b/frontend/src/pages/users/context/users-context.tsx @@ -1,5 +1,5 @@ import React, { useState } from "react"; -import useDialogState from "@/hooks/use-dialog-state"; +import useDialogState from "@/hooks/useDialogState"; import { User } from "../data/schema"; type UsersDialogType = "invite" | "add" | "edit" | "delete"; diff --git a/frontend/src/utils/handle-server-error.ts b/frontend/src/utils/handle-server-error.ts index 45a6f26..9daaea8 100644 --- a/frontend/src/utils/handle-server-error.ts +++ b/frontend/src/utils/handle-server-error.ts @@ -1,5 +1,5 @@ import { AxiosError } from "axios"; -import { toast } from "@/hooks/use-toast"; +import { toast } from "@/hooks/useToast"; export function handleServerError(error: unknown) { // eslint-disable-next-line no-console