Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ custom_css = """
|
|
46 |
width: 100%; height: 100%;
|
47 |
background: rgba(0,0,0,0.6);
|
48 |
z-index: 9999;
|
49 |
-
display: none;
|
50 |
flex-direction: column;
|
51 |
justify-content: center;
|
52 |
align-items: center;
|
@@ -74,15 +74,23 @@ custom_css = """
|
|
74 |
#nps-close:hover {
|
75 |
color: black;
|
76 |
}
|
77 |
-
|
78 |
-
|
79 |
-
background
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
}
|
81 |
-
|
82 |
"""
|
83 |
|
84 |
|
85 |
|
|
|
86 |
with gr.Blocks() as interface:
|
87 |
# with gr.Tab("CURIOUS ABOUT THIS PRODUCT?"):
|
88 |
# gr.HTML(value=pricing_html)
|
@@ -146,6 +154,7 @@ with gr.Blocks() as interface:
|
|
146 |
|
147 |
selected_score = gr.Textbox(label="selected_score", visible=False)
|
148 |
nps_submit = gr.Button("Submit")
|
|
|
149 |
|
150 |
|
151 |
with gr.Group(visible=False) as results_group:
|
@@ -396,7 +405,7 @@ with gr.Blocks() as interface:
|
|
396 |
# "\n".join(log_lines)
|
397 |
# )
|
398 |
def submit_nps(email,nps_score):
|
399 |
-
if nps_score
|
400 |
return "❌ Please select a score before submitting."
|
401 |
log_submission_to_gsheet(email, [], nps_score)
|
402 |
return "✅ Thanks for submitting your feedback!"
|
@@ -1189,11 +1198,8 @@ with gr.Blocks() as interface:
|
|
1189 |
inputs=[raw_text, q1, q2, contact],
|
1190 |
outputs=[feedback_status]
|
1191 |
)
|
1192 |
-
nps_message = gr.Markdown(visible=True)
|
1193 |
-
#nps_button.click(fn=submit_nps, inputs=[user_email, nps_slider], outputs=nps_output)
|
1194 |
nps_submit.click(fn=submit_nps, inputs=[user_email, selected_score], outputs=[nps_message])
|
1195 |
-
|
1196 |
-
|
1197 |
|
1198 |
gr.HTML("""
|
1199 |
<style>
|
@@ -1279,42 +1285,35 @@ with gr.Blocks() as interface:
|
|
1279 |
with gr.Tab("PRICING"):
|
1280 |
gr.HTML(value=pricing_html)
|
1281 |
|
1282 |
-
interface.load(
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
if (closeBtn) {
|
1287 |
-
closeBtn.addEventListener('click', () => {
|
1288 |
const overlay = document.getElementById('nps-overlay');
|
1289 |
-
|
1290 |
-
|
1291 |
-
}
|
1292 |
-
|
1293 |
-
// Handle score button clicks
|
1294 |
-
document.querySelectorAll('.nps-btn').forEach(btn => {
|
1295 |
-
btn.addEventListener('click', () => {
|
1296 |
-
const score = btn.getAttribute('data-score');
|
1297 |
const hiddenInput = document.querySelector('textarea[aria-label="selected_score"]');
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
|
|
|
|
1301 |
}
|
1302 |
-
});
|
1303 |
-
});
|
1304 |
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
|
|
1315 |
}
|
1316 |
-
|
1317 |
-
|
1318 |
|
1319 |
|
1320 |
|
|
|
46 |
width: 100%; height: 100%;
|
47 |
background: rgba(0,0,0,0.6);
|
48 |
z-index: 9999;
|
49 |
+
display: none;
|
50 |
flex-direction: column;
|
51 |
justify-content: center;
|
52 |
align-items: center;
|
|
|
74 |
#nps-close:hover {
|
75 |
color: black;
|
76 |
}
|
77 |
+
.nps-btn {
|
78 |
+
border: 1px solid #ccc;
|
79 |
+
background: #f9f9f9;
|
80 |
+
padding: 6px 10px;
|
81 |
+
cursor: pointer;
|
82 |
+
border-radius: 6px;
|
83 |
+
}
|
84 |
+
.nps-btn.selected {
|
85 |
+
background: #007bff;
|
86 |
+
color: white;
|
87 |
+
border-color: #007bff;
|
88 |
}
|
|
|
89 |
"""
|
90 |
|
91 |
|
92 |
|
93 |
+
|
94 |
with gr.Blocks() as interface:
|
95 |
# with gr.Tab("CURIOUS ABOUT THIS PRODUCT?"):
|
96 |
# gr.HTML(value=pricing_html)
|
|
|
154 |
|
155 |
selected_score = gr.Textbox(label="selected_score", visible=False)
|
156 |
nps_submit = gr.Button("Submit")
|
157 |
+
nps_message = gr.Markdown(visible=True)
|
158 |
|
159 |
|
160 |
with gr.Group(visible=False) as results_group:
|
|
|
405 |
# "\n".join(log_lines)
|
406 |
# )
|
407 |
def submit_nps(email,nps_score):
|
408 |
+
if not nps_score.strip():
|
409 |
return "❌ Please select a score before submitting."
|
410 |
log_submission_to_gsheet(email, [], nps_score)
|
411 |
return "✅ Thanks for submitting your feedback!"
|
|
|
1198 |
inputs=[raw_text, q1, q2, contact],
|
1199 |
outputs=[feedback_status]
|
1200 |
)
|
|
|
|
|
1201 |
nps_submit.click(fn=submit_nps, inputs=[user_email, selected_score], outputs=[nps_message])
|
1202 |
+
|
|
|
1203 |
|
1204 |
gr.HTML("""
|
1205 |
<style>
|
|
|
1285 |
with gr.Tab("PRICING"):
|
1286 |
gr.HTML(value=pricing_html)
|
1287 |
|
1288 |
+
interface.load(
|
1289 |
+
js="""
|
1290 |
+
() => {
|
1291 |
+
setTimeout(() => {
|
|
|
|
|
1292 |
const overlay = document.getElementById('nps-overlay');
|
1293 |
+
const closeBtn = document.getElementById('nps-close');
|
1294 |
+
const buttons = document.querySelectorAll('.nps-btn');
|
|
|
|
|
|
|
|
|
|
|
|
|
1295 |
const hiddenInput = document.querySelector('textarea[aria-label="selected_score"]');
|
1296 |
+
|
1297 |
+
if (closeBtn) {
|
1298 |
+
closeBtn.onclick = () => {
|
1299 |
+
overlay.style.display = 'none';
|
1300 |
+
};
|
1301 |
}
|
|
|
|
|
1302 |
|
1303 |
+
buttons.forEach(btn => {
|
1304 |
+
btn.onclick = () => {
|
1305 |
+
buttons.forEach(b => b.classList.remove('selected'));
|
1306 |
+
btn.classList.add('selected');
|
1307 |
+
if (hiddenInput) {
|
1308 |
+
hiddenInput.value = btn.getAttribute('data-score');
|
1309 |
+
hiddenInput.dispatchEvent(new Event('input', { bubbles: true }));
|
1310 |
+
}
|
1311 |
+
};
|
1312 |
+
});
|
1313 |
+
}, 500);
|
1314 |
}
|
1315 |
+
"""
|
1316 |
+
)
|
1317 |
|
1318 |
|
1319 |
|