Now with the ability to actually create a badge. We still need to make this look nicer. Buttons should look more like button and consistent with the other areas of AE Events Badges. Also take a look at the trigger updated fields.
This commit is contained in:
@@ -259,7 +259,7 @@ export async function create_ae_obj__event_badge({
|
||||
|
||||
const result = await api.create_nested_obj({
|
||||
api_cfg,
|
||||
parent_type: 'event',
|
||||
parent_type: 'event_person',
|
||||
parent_id: event_id,
|
||||
child_type: 'event_badge',
|
||||
fields: data_kv,
|
||||
|
||||
@@ -83,9 +83,9 @@ async function handle_submit(event: Event) {
|
||||
error_msg = '';
|
||||
|
||||
// Step 1: Create event_person — the identity record for this attendee.
|
||||
// The V3 create endpoint returns { obj_id, obj_id_random } — both are the id_random
|
||||
// of the new record. We pass event_person_id_random to the badge so the backend resolves the FK.
|
||||
let new_person: { obj_id?: string; obj_id_random?: string } | null = null;
|
||||
// The V3 create endpoint returns { event_person_id }.
|
||||
// We pass event_person_id to the badge so the backend resolves the FK.
|
||||
let new_person: { event_person_id?: string; obj_id?: string; } | null = null;
|
||||
try {
|
||||
const person_data: key_val = { given_name, family_name, email };
|
||||
new_person = await events_func.create_ae_obj__event_person({
|
||||
@@ -100,7 +100,7 @@ async function handle_submit(event: Event) {
|
||||
return;
|
||||
}
|
||||
|
||||
const event_person_id = new_person?.obj_id || new_person?.obj_id_random;
|
||||
const event_person_id = new_person?.event_person_id || new_person?.obj_id;
|
||||
if (!event_person_id) {
|
||||
submit_status = 'error';
|
||||
error_msg = 'Attendee record created but returned no ID.';
|
||||
@@ -129,12 +129,12 @@ async function handle_submit(event: Event) {
|
||||
};
|
||||
const new_badge = await api.create_nested_obj({
|
||||
api_cfg: $ae_api,
|
||||
parent_type: 'event',
|
||||
parent_id: event_id,
|
||||
parent_type: 'event_person',
|
||||
parent_id: event_person_id,
|
||||
child_type: 'event_badge',
|
||||
fields: badge_data
|
||||
});
|
||||
if (new_badge?.obj_id) {
|
||||
if (new_badge?.event_badge_id) {
|
||||
submit_status = 'success';
|
||||
if (onsuccess) onsuccess(new_badge);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user