Fix: Remove event_id from body_params (was causing 8 parameters instead of 7) and add form_params for form display
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
dvirlabs 2026-05-14 11:53:17 +03:00
parent bd7064ab87
commit 6c5012929f
2 changed files with 14 additions and 3 deletions

View File

@ -169,12 +169,21 @@ TEMPLATES: Dict[str, Dict[str, Any]] = {
"event_date", # body {{5}} "event_date", # body {{5}}
"event_time", # body {{6}} "event_time", # body {{6}}
"guest_link", # body {{7}} "guest_link", # body {{7}}
"event_id", # button {{1}} - for dynamic URL (not in body text)
], ],
"button_type": "URL", "button_type": "URL",
"button_text": "הצבע על הזמנה", "button_text": "הצבע על הזמנה",
"button_url": "https://invy.dvirlabs.com/guest/{{1}}", "button_url": "https://invy.dvirlabs.com/guest/{{1}}",
"button_param_key": "event_id", "button_param_key": "event_id",
"form_params": [ # All params shown in form
"contact_name",
"groom_name",
"bride_name",
"venue",
"event_date",
"event_time",
"guest_link",
"event_id", # Button param - shown in form but NOT sent as body parameter
],
"fallbacks": { "fallbacks": {
"contact_name": "חבר", "contact_name": "חבר",
"groom_name": "החתן", "groom_name": "החתן",
@ -295,6 +304,7 @@ def list_templates_for_frontend(db: Session) -> list:
"button_text": tpl.get("button_text", ""), "button_text": tpl.get("button_text", ""),
"button_url": tpl.get("button_url", ""), "button_url": tpl.get("button_url", ""),
"button_param_key": tpl.get("button_param_key", ""), "button_param_key": tpl.get("button_param_key", ""),
"form_params": tpl.get("form_params", tpl["body_params"]), # All params for form display
"guest_name_key": tpl.get("guest_name_key", ""), "guest_name_key": tpl.get("guest_name_key", ""),
"url_button": tpl.get("url_button", None), "url_button": tpl.get("url_button", None),
} }

View File

@ -94,13 +94,14 @@ function WhatsAppInviteModal({ isOpen, onClose, selectedGuests = [], eventData =
// Unique param keys for this template (header + body, deduplicated, skip contact_name & guest_name_key & guest_link) // Unique param keys for this template (header + body, deduplicated, skip contact_name & guest_name_key & guest_link)
const paramKeys = useMemo(() => { const paramKeys = useMemo(() => {
if (!selectedTemplate) return [] if (!selectedTemplate) return []
const all = [ // Use form_params if available, otherwise fall back to body_params + header_params
const paramList = selectedTemplate.form_params || [
...(selectedTemplate.header_params || []), ...(selectedTemplate.header_params || []),
...(selectedTemplate.body_params || []), ...(selectedTemplate.body_params || []),
] ]
const seen = new Set() const seen = new Set()
const gnk = selectedTemplate.guest_name_key || '' const gnk = selectedTemplate.guest_name_key || ''
return all.filter(k => { return paramList.filter(k => {
if (k === 'contact_name' || k === gnk || k === 'guest_link' || seen.has(k)) return false if (k === 'contact_name' || k === gnk || k === 'guest_link' || seen.has(k)) return false
seen.add(k); return true seen.add(k); return true
}) })