Renamed hooks on frontend and started working on shop registration

This commit is contained in:
Thastertyn committed 2025-03-13 15:41:44 +01:00
1 parent 3b42ea6914
commit 9c2b88b103
35 files changed
+180 -37

No files matched your search

+21 -2
View File
@@ -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()