Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -108,7 +108,7 @@ def generate_plan_id(user_data):
|
|
| 108 |
|
| 109 |
# Function to display saved records as a table and save to CSV
|
| 110 |
def display_saved_records():
|
| 111 |
-
st.subheader(":
|
| 112 |
df = pd.DataFrame(st.session_state.data)
|
| 113 |
|
| 114 |
if not df.empty:
|
|
@@ -206,9 +206,9 @@ set_bg_hack_image(demo_image_path, width='100%', height='100vh')
|
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
-
|
| 210 |
-
# Section 1: Plan Info
|
| 211 |
st.sidebar.image('Fynd_logo2.png', width=300)
|
|
|
|
| 212 |
st.sidebar.title(":blue[Plan maker]")
|
| 213 |
user_name = st.sidebar.text_input("Enter your name:")
|
| 214 |
st.sidebar.title(":blue[Section 1: Plan Info]")
|
|
@@ -340,8 +340,9 @@ if bundle_by == "Feature specific":
|
|
| 340 |
if selected_fee_nature == "Slab based":
|
| 341 |
st.write("Enter values for Slab based fee structure:")
|
| 342 |
|
| 343 |
-
|
| 344 |
-
|
|
|
|
| 345 |
global_data_rows = []
|
| 346 |
|
| 347 |
def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
|
|
@@ -350,8 +351,8 @@ if bundle_by == "Feature specific":
|
|
| 350 |
user_input = int(user_input.strip()) if user_input else None
|
| 351 |
Usage = int(Usage.strip()) if Usage else None
|
| 352 |
Capping_or_Minimum_Guarantee = int(Capping_or_Minimum_Guarantee.strip()) if Capping_or_Minimum_Guarantee else None
|
| 353 |
-
|
| 354 |
-
|
| 355 |
new_row = {
|
| 356 |
"Slab": slab,
|
| 357 |
"Max_value": max_value,
|
|
@@ -360,33 +361,28 @@ if bundle_by == "Feature specific":
|
|
| 360 |
"Capping/Min_Guarantee_value": Capping_or_Minimum_Guarantee,
|
| 361 |
"Threshold": threshold
|
| 362 |
}
|
| 363 |
-
|
| 364 |
-
|
| 365 |
global_data_rows.append(new_row)
|
| 366 |
-
save_slab_data(new_row)
|
| 367 |
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
for i, row in enumerate(global_data_rows):
|
| 371 |
-
st.write(f"Entry {i + 1}:")
|
| 372 |
-
st.table([row])
|
| 373 |
|
| 374 |
-
# Streamlit UI code
|
| 375 |
def main():
|
| 376 |
st.title("Slab Data Management")
|
| 377 |
-
|
| 378 |
-
|
| 379 |
col1, col2 = st.columns([2, 2])
|
| 380 |
with col1:
|
| 381 |
-
slab = st.selectbox("Slab:", [1, 2, 3], key="slab_select")
|
| 382 |
user_input = st.text_input("**Commercial Value:**", key="user_input")
|
| 383 |
Capping_or_Minimum_Guarantee = st.text_input("**Capping/Min_Guarantee:**", key="Capping_or_Minimum_Guarantee_input")
|
| 384 |
with col2:
|
| 385 |
max_value = st.text_input("**Max value:**", key="max_value_input")
|
| 386 |
Usage = st.text_input("**Usage:**", key="Usage_input")
|
| 387 |
threshold = st.text_input("**Threshold:**", key="threshold_input")
|
| 388 |
-
|
| 389 |
-
|
| 390 |
if st.button("Add Data", key="add_data_button"):
|
| 391 |
if not (slab and user_input and Capping_or_Minimum_Guarantee):
|
| 392 |
st.warning("Please fill in all required fields.")
|
|
@@ -394,12 +390,18 @@ if bundle_by == "Feature specific":
|
|
| 394 |
add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold)
|
| 395 |
st.success(f"Data for Slab '{slab}' added successfully!")
|
| 396 |
|
| 397 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 398 |
|
| 399 |
if __name__ == "__main__":
|
| 400 |
main()
|
| 401 |
|
| 402 |
|
|
|
|
| 403 |
elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 404 |
user_input = st.number_input("**Commercial value:**", min_value=0.0, help="Enter a valid number")
|
| 405 |
|
|
@@ -484,7 +486,7 @@ elif bundle_by == "Single value":
|
|
| 484 |
|
| 485 |
|
| 486 |
# Section 2: Company Info
|
| 487 |
-
st.sidebar.title("Section 2: Rule Info")
|
| 488 |
a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS",
|
| 489 |
"GMC", "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "PixelBin", "Boltic", "CoPilot"]
|
| 490 |
ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
|
|
|
|
| 108 |
|
| 109 |
# Function to display saved records as a table and save to CSV
|
| 110 |
def display_saved_records():
|
| 111 |
+
st.subheader(":blue[Saved Records]")
|
| 112 |
df = pd.DataFrame(st.session_state.data)
|
| 113 |
|
| 114 |
if not df.empty:
|
|
|
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
+
# Display the image in the sidebar
|
|
|
|
| 210 |
st.sidebar.image('Fynd_logo2.png', width=300)
|
| 211 |
+
|
| 212 |
st.sidebar.title(":blue[Plan maker]")
|
| 213 |
user_name = st.sidebar.text_input("Enter your name:")
|
| 214 |
st.sidebar.title(":blue[Section 1: Plan Info]")
|
|
|
|
| 340 |
if selected_fee_nature == "Slab based":
|
| 341 |
st.write("Enter values for Slab based fee structure:")
|
| 342 |
|
| 343 |
+
import streamlit as st
|
| 344 |
+
|
| 345 |
+
# Initialize an empty list to store data rows
|
| 346 |
global_data_rows = []
|
| 347 |
|
| 348 |
def add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold):
|
|
|
|
| 351 |
user_input = int(user_input.strip()) if user_input else None
|
| 352 |
Usage = int(Usage.strip()) if Usage else None
|
| 353 |
Capping_or_Minimum_Guarantee = int(Capping_or_Minimum_Guarantee.strip()) if Capping_or_Minimum_Guarantee else None
|
| 354 |
+
|
| 355 |
+
# Create a new row dictionary
|
| 356 |
new_row = {
|
| 357 |
"Slab": slab,
|
| 358 |
"Max_value": max_value,
|
|
|
|
| 361 |
"Capping/Min_Guarantee_value": Capping_or_Minimum_Guarantee,
|
| 362 |
"Threshold": threshold
|
| 363 |
}
|
| 364 |
+
|
| 365 |
+
# Append new_row to global list of rows
|
| 366 |
global_data_rows.append(new_row)
|
|
|
|
| 367 |
|
| 368 |
+
# Save or process data as needed
|
| 369 |
+
save_slab_data(new_row)
|
|
|
|
|
|
|
|
|
|
| 370 |
|
|
|
|
| 371 |
def main():
|
| 372 |
st.title("Slab Data Management")
|
| 373 |
+
|
| 374 |
+
# Inputs for adding data
|
| 375 |
col1, col2 = st.columns([2, 2])
|
| 376 |
with col1:
|
| 377 |
+
slab = st.selectbox("Slab:", [1, 2, 3], key="slab_select") # Selectbox for slab numbers
|
| 378 |
user_input = st.text_input("**Commercial Value:**", key="user_input")
|
| 379 |
Capping_or_Minimum_Guarantee = st.text_input("**Capping/Min_Guarantee:**", key="Capping_or_Minimum_Guarantee_input")
|
| 380 |
with col2:
|
| 381 |
max_value = st.text_input("**Max value:**", key="max_value_input")
|
| 382 |
Usage = st.text_input("**Usage:**", key="Usage_input")
|
| 383 |
threshold = st.text_input("**Threshold:**", key="threshold_input")
|
| 384 |
+
|
| 385 |
+
# Button to add data
|
| 386 |
if st.button("Add Data", key="add_data_button"):
|
| 387 |
if not (slab and user_input and Capping_or_Minimum_Guarantee):
|
| 388 |
st.warning("Please fill in all required fields.")
|
|
|
|
| 390 |
add_data(slab, max_value, user_input, Usage, Capping_or_Minimum_Guarantee, threshold)
|
| 391 |
st.success(f"Data for Slab '{slab}' added successfully!")
|
| 392 |
|
| 393 |
+
# Display all entries in a single table
|
| 394 |
+
if global_data_rows:
|
| 395 |
+
st.subheader("All Slabs Data Summary")
|
| 396 |
+
for i, row in enumerate(global_data_rows):
|
| 397 |
+
st.write(f"Entry {i + 1}:")
|
| 398 |
+
st.table([row])
|
| 399 |
|
| 400 |
if __name__ == "__main__":
|
| 401 |
main()
|
| 402 |
|
| 403 |
|
| 404 |
+
|
| 405 |
elif selected_fee_nature in ["Fixed %", "Flat currency"]:
|
| 406 |
user_input = st.number_input("**Commercial value:**", min_value=0.0, help="Enter a valid number")
|
| 407 |
|
|
|
|
| 486 |
|
| 487 |
|
| 488 |
# Section 2: Company Info
|
| 489 |
+
st.sidebar.title(":blue[Section 2: Rule Info]")
|
| 490 |
a1 = ["GoFynd", "Uniket", "B2B", "Marketplaces", "StoreOS", "Storefronts", "ONDC", "Fynd OMS", "Fynd TMS", "Fynd WMS",
|
| 491 |
"GMC", "Catalog Cloud", "Fynd Commerce Platform", "Logistics", "PixelBin", "Boltic", "CoPilot"]
|
| 492 |
ordering_channels = st.sidebar.selectbox("Product lines", [""] + a1, help="Select the ordering channels")
|