File size: 3,929 Bytes
ee39444
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import streamlit as st
import requests
import os

st.set_page_config(layout="wide")
st.html("styles.html")
# endpoint = os.getenv('blog_lead_endpoint')
endpoint = "http://127.0.0.1:8000/query/"

def main():
    st.markdown('<h1 class="stTitle">Hook2Lead</h1>', unsafe_allow_html=True)
    st.markdown('<h2 class="stSubheader">Share your hooks, and we will connect you with interested leads</h2>', unsafe_allow_html=True)
    email_options = [
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "[email protected]"
    ]

    account_stages = [
        "Pre-Sales",
        "Pre-Sales (Unresponsive, After Call)",
        "Pre-Sales (Long-Term/ Cold)",
        "Sales Opportunity",
        "Closed Lost (Opportunity)",
        "Current Client",
        "Pre-Sales (Short-Term/ Hot)",
        "Pre-Sales (Mid-Term/ Warm)",
        "Project Cancelled"
    ]

    query_types = ["blog", "announcement", "AI_trend"]

    # Get the current number of queries from query params
    if 'num_queries' not in st.session_state:
        st.session_state.num_queries = 1

    # Creating a form
    with st.form(key='blog2lead_form'):
        email_address = st.selectbox("**Select your email address**", email_options)
        selected_stages = st.multiselect("**Select Account Stages (optional)**", account_stages)

        queries = {}
        query_types_selected = []

        # Add query fields based on the current number of queries
        for i in range(st.session_state.num_queries):
            cols = st.columns([3, 1])  # Adjust the width ratio here
            with cols[0]:
                query_label = ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][i]
                query = st.text_input(f"**Enter your {query_label} hook**", key=f"query_{i}", help="you can enter your hook directly or a url")
            with cols[1]:
                query_type = st.selectbox(f"**Select {query_label}  hook type**", query_types, key=f"type_{i}")
            if query.strip():
              queries[query] = query_type

        # Button to add more query fields
        add_query = st.form_submit_button(label='Add another query')
        submit_button = st.form_submit_button(label='Submit')

    if add_query:
        st.session_state.num_queries += 1
        st.rerun()
    if submit_button:
        if queries and email_address:
            # Define your data payload to send
            queries = {k: v for k, v in queries.items() if k and v}
            data_to_send = {
                "queries": queries,
                "email_receiver": email_address,
            }

            # Add the filter to the payload only if selected_stages is not empty
            if selected_stages:
                data_to_send["filter"] = {
                    "Account Stage": {"$in": selected_stages}
                }

            # Sending the POST request to FastAPI
            response = requests.post(endpoint, json=data_to_send)

            # Handling the response
            if response.status_code == 200:
                st.info("Your request has been processed successfully.")
            else:
                st.error("Data transmission failed. Please try again later.")
        else:
            st.error("Please fill out all fields.")

if __name__ == "__main__":
    logo_url = "https://i.imgur.com/WYnv26e.jpeg"  # Replace this with your image's direct URL
    st.markdown(
        f"""
        <style>
        .logo {{
            position: fixed;
            bottom: 5px;
            right: 5px;
            width: 100px;  # Adjust width as needed
        }}
        </style>
        <img src="{logo_url}" class="logo">
        """,
        unsafe_allow_html=True,
    )

    main()