Skip to content
Snippets Groups Projects
Commit a7a2e580 authored by Nguyen12.Minh@live.uwe.ac.uk's avatar Nguyen12.Minh@live.uwe.ac.uk
Browse files

modified create shop and product

parent d6a18c31
No related branches found
No related tags found
No related merge requests found
Pipeline #8909 failed
......@@ -56,18 +56,17 @@ def create_product_frame(parent, switch_func, API_URL, token):
price_val = price_entry.get().strip()
desc_val = desc_entry.get().strip()
stock_val = stock_entry.get().strip()
# shop_val = shop_id_entry.get().strip()
if not title_val or not price_val or not stock_val:
messagebox.showerror("Error", "Title, Price, and Stock are required")
return
# In a real scenario, you would pass the shop_id from view_shop.
# For now, use a placeholder shop_id (e.g., 1)
data = {
"name": title_val,
"price": price_val,
"description": desc_val,
"stock": stock_val,
"shop_id": 1 # Replace with the actual shop id
# "shop_id": shop_val,
}
files = {}
if os.path.isfile(image_path.get()):
......
......@@ -31,7 +31,6 @@ def create_shop_frame(parent, switch_func, API_URL, token):
address_label = ctk.CTkLabel(frame, text="Address:")
address_label.pack(pady=5)
address_entry = ctk.CTkEntry(frame, width=300)
address_entry.insert(0, "123 Main St")
address_entry.pack(pady=5)
# Shop Image Upload
......@@ -76,7 +75,7 @@ def create_shop_frame(parent, switch_func, API_URL, token):
if resp.status_code == 200:
shop = resp.json()
messagebox.showinfo("Success", "Shop created successfully!")
switch_func("view_shop", shop) # Pass the shop data to the view shop frame
switch_func("create_product", shop) # Pass the shop data to the view shop frame
else:
messagebox.showerror("Error", f"Failed to create shop. Status: {resp.status_code}\n{resp.text}")
except Exception as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment