27 lines
656 B
Python
27 lines
656 B
Python
from typing import Optional
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from app.api.dependencies import CurrentOwnerUser, SessionDep
|
|
from app.crud.shop_crud import create_shop
|
|
from app.schemas.shop_schemas import ShopCreate, ShopPublic
|
|
|
|
router = APIRouter(prefix="/shop", tags=["Dashboard"])
|
|
|
|
|
|
@router.post("", status_code=201)
|
|
async def register_new_shop(
|
|
session: SessionDep,
|
|
current_user: CurrentOwnerUser,
|
|
shop_data: ShopCreate
|
|
) -> bool:
|
|
create_shop(session, shop_data, current_user)
|
|
return True
|
|
|
|
|
|
@router.get("")
|
|
async def get_owned_shop_info(
|
|
current_user: CurrentOwnerUser
|
|
) -> Optional[ShopPublic]:
|
|
return current_user.owned_shop
|