Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
main <- develop (#401)
Dave Earleyca0e7cad9148
diff --git a/backend/app/DomainObjects/Enums/QuestionTypeEnum.php b/backend/app/DomainObjects/Enums/QuestionTypeEnum.phpindex 69678ab63..2340d0380 100644--- a/backend/app/DomainObjects/Enums/QuestionTypeEnum.php+++ b/backend/app/DomainObjects/Enums/QuestionTypeEnum.php@@ -16,4 +16,12 @@ enum QuestionTypeEnumcase DROPDOWN;case MULTI_SELECT_DROPDOWN;case DATE;++ public static function getMultipleChoiceTypes(): array+ {+ return [+ self::CHECKBOX,+ self::MULTI_SELECT_DROPDOWN,+ ];+ }}diff --git a/backend/app/DomainObjects/QuestionAndAnswerViewDomainObject.php b/backend/app/DomainObjects/QuestionAndAnswerViewDomainObject.phpindex 503b3e893..53938c8a1 100644--- a/backend/app/DomainObjects/QuestionAndAnswerViewDomainObject.php+++ b/backend/app/DomainObjects/QuestionAndAnswerViewDomainObject.php@@ -15,13 +15,18 @@ class QuestionAndAnswerViewDomainObject extends AbstractDomainObjectprivate int $question_id;private ?int $order_id;private string $title;+ private bool $question_required;+ private ?string $question_description = null;private ?string $first_name = null;private ?string $last_name = null;private array|string $answer;private string $belongs_to;private ?int $attendee_id = null;+ private ?string $attendee_public_id = null;private string $question_type;private int $event_id;+ private int $question_answer_id;+ private ?array $question_options = null;private ?AttendeeDomainObject $attendee = null;@@ -183,19 +188,86 @@ class QuestionAndAnswerViewDomainObject extends AbstractDomainObjectreturn $this;}+ public function getQuestionAnswerId(): int+ {+ return $this->question_answer_id;+ }++ public function setQuestionAnswerId(int $question_answer_id): QuestionAndAnswerViewDomainObject+ {+ $this->question_answer_id = $question_answer_id;++ return $this;+ }++ public function getQuestionDescription(): ?string+ {+ return $this->question_description;+ }++ public function setQuestionDescription(?string $question_description): QuestionAndAnswerViewDomainObject+ {+ $this->question_description = $question_description;++ return $this;+ }++ public function getQuestionRequired(): bool+ {+ return $this->question_required;+ }++ public function setQuestionRequired(bool $question_required): QuestionAndAnswerViewDomainObject+ {+ $this->question_required = $question_required;++ return $this;+ }++ public function getQuestionOptions(): ?array+ {+ return $this->question_options;+ }++ public function setQuestionOptions(?array $question_options): QuestionAndAnswerViewDomainObject+ {+ $this->question_options = $question_options;++ return $this;+ }++ public function getAttendeePublicId(): ?string+ {+ return $this->attendee_public_id;+ }++ public function setAttendeePublicId(?string $attendee_public_id): QuestionAndAnswerViewDomainObject+ {+ $this->attendee_public_id = $attendee_public_id;++ return $this;+ }+public function toArray(): array{return ['question_id' => $this->question_id ?? null,'order_id' => $this->order_id ?? null,'title' => $this->title ?? null,+ 'question_description' => $this->question_description ?? null,+ 'question_required' => $this->question_required ?? null,'last_name' => $this->last_name ?? null,'answer' => $this->answer ?? null,'belongs_to' => $this->belongs_to ?? null,'attendee_id' => $this->attendee_id ?? null,+ 'attendee_public_id' => $this->attendee_public_id ?? null,'question_type' => $this->question_type ?? null,'first_name' => $this->first_name ?? null,'event_id' => $this->event_id ?? null,+ 'product_id' => $this->product_id ?? null,+ 'product_title' => $this->product_title ?? null,+ 'question_answer_id' => $this->question_answer_id ?? null,+ 'question_options' => $this->question_options ?? null,];}}diff --git a/backend/app/DomainObjects/QuestionAnswerDomainObject.php b/backend/app/DomainObjects/QuestionAnswerDomainObject.phpindex 150156938..8f2e241c9 100644--- a/backend/app/DomainObjects/QuestionAnswerDomainObject.php+++ b/backend/app/DomainObjects/QuestionAnswerDomainObject.php@@ -2,6 +2,35 @@namespace HiEvents\DomainObjects;+use HiEvents\DomainObjects\Generated\OrderDomainObjectAbstract;+class QuestionAnswerDomainObject extends Generated\QuestionAnswerDomainObjectAbstract{+ private ?OrderDomainObjectAbstract $order = null;++ private ?QuestionDomainObject $question = null;++ public function setOrder(?OrderDomainObjectAbstract $order): QuestionAnswerDomainObject+ {+ $this->order = $order;++ return $this;+ }++ public function getOrder(): ?OrderDomainObjectAbstract+ {+ return $this->order;+ }++ public function setQuestion(?QuestionDomainObject $question): QuestionAnswerDomainObject+ {+ $this->question = $question;++ return $this;+ }++ public function getQuestion(): ?QuestionDomainObject+ {+ return $this->question;+ }}diff --git a/backend/app/DomainObjects/QuestionDomainObject.php b/backend/app/DomainObjects/QuestionDomainObject.phpindex 5b544cc98..7d84e3a25 100644--- a/backend/app/DomainObjects/QuestionDomainObject.php+++ b/backend/app/DomainObjects/QuestionDomainObject.php@@ -40,4 +40,20 @@ class QuestionDomainObject extends Generated\QuestionDomainObjectAbstractreturn $this;}+ public function isAnswerValid(mixed $answer): bool+ {+ if (!isset($answer)) {+ return false;+ }++ if (!$this->isPreDefinedChoice()) {+ return true;+ }++ if (is_string($answer)) {+ return in_array($answer, $this->getOptions(), true);+ }++ return array_diff((array)$answer, $this->getOptions()) === [];+ }}diff --git a/backend/app/Http/Actions/Auth/LoginAction.php b/backend/app/Http/Actions/Auth/LoginAction.phpindex e5f3b1782..3f0e0efd6 100644--- a/backend/app/Http/Actions/Auth/LoginAction.php+++ b/backend/app/Http/Actions/Auth/LoginAction.php@@ -26,7 +26,7 @@ class LoginAction extends BaseAuthAction$loginResponse = $this->loginHandler->handle(new LoginCredentialsDTO(email: strtolower($request->validated('email')),password: $request->validated('password'),- accountId: $request->validated('account_id'),+ accountId: (int)$request->validated('account_id'),));} catch (UnauthorizedException $e) {return $this->errorResponse(diff --git a/backend/app/Http/Actions/Auth/RefreshTokenAction.php b/backend/app/Http/Actions/Auth/RefreshTokenAction.phpindex 7f40752a3..c21f85011 100644--- a/backend/app/Http/Actions/Auth/RefreshTokenAction.php+++ b/backend/app/Http/Actions/Auth/RefreshTokenAction.php@@ -8,6 +8,6 @@ class RefreshTokenAction extends BaseAuthAction{public function __invoke(): JsonResponse{- return $this->respondWithToken(auth()->refresh(), auth()->user()->accounts);+ return $this->respondWithToken(auth()->refresh(), $this->getAuthenticatedUser()->accounts ?? collect());}}diff --git a/backend/app/Http/Actions/Orders/GetOrderAction.php b/backend/app/Http/Actions/Orders/GetOrderAction.phpindex b72c5581e..0d399caca 100644--- a/backend/app/Http/Actions/Orders/GetOrderAction.php+++ b/backend/app/Http/Actions/Orders/GetOrderAction.php@@ -7,6 +7,8 @@ use HiEvents\DomainObjects\EventDomainObject;use HiEvents\DomainObjects\OrderItemDomainObject;use HiEvents\DomainObjects\QuestionAndAnswerViewDomainObject;use HiEvents\Http\Actions\BaseAction;+use HiEvents\Repository\Eloquent\Value\OrderAndDirection;+use HiEvents\Repository\Eloquent\Value\Relationship;use HiEvents\Repository\Interfaces\OrderRepositoryInterface;use HiEvents\Resources\Order\OrderResource;use Illuminate\Http\JsonResponse;@@ -27,7 +29,9 @@ class GetOrderAction extends BaseAction$order = $this->orderRepository->loadRelation(OrderItemDomainObject::class)->loadRelation(AttendeeDomainObject::class)- ->loadRelation(QuestionAndAnswerViewDomainObject::class)+ ->loadRelation(new Relationship(domainObject: QuestionAndAnswerViewDomainObject::class, orderAndDirections: [+ new OrderAndDirection(order: 'question_id'),+ ]))->findById($orderId);return $this->resourceResponse(OrderResource::class, $order);diff --git a/backend/app/Http/Actions/Questions/EditQuestionAnswerAction.php b/backend/app/Http/Actions/Questions/EditQuestionAnswerAction.phpnew file mode 100644index 000000000..61bc908be--- /dev/null+++ b/backend/app/Http/Actions/Questions/EditQuestionAnswerAction.php@@ -0,0 +1,43 @@+<?php++namespace HiEvents\Http\Actions\Questions;++use HiEvents\DomainObjects\EventDomainObject;+use HiEvents\Http\Actions\BaseAction;+use HiEvents\Http\Request\Questions\EditQuestionAnswerRequest;+use HiEvents\Services\Application\Handlers\Question\DTO\EditQuestionAnswerDTO;+use HiEvents\Services\Application\Handlers\Question\EditQuestionAnswerHandler;+use HiEvents\Services\Domain\Question\Exception\InvalidAnswerException;+use Illuminate\Http\Response;+use Illuminate\Validation\ValidationException;++class EditQuestionAnswerAction extends BaseAction+{+ public function __construct(+ private readonly EditQuestionAnswerHandler $editQuestionAnswerHandler,+ )+ {+ }++ public function __invoke(+ int $eventId,+ int $questionId,+ int $questionAnswerId,+ EditQuestionAnswerRequest $request,+ ): Response+ {+ $this->isActionAuthorized($eventId, EventDomainObject::class);++ try {+ $this->editQuestionAnswerHandler->handle(new EditQuestionAnswerDTO(+ questionAnswerId: $questionAnswerId,+ eventId: $eventId,+ answer: $request->validated('answer'),+ ));+ } catch (InvalidAnswerException $e) {+ throw ValidationException::withMessages(['answer.answer' => $e->getMessage()]);+ }++ return $this->noContentResponse();+ }+}diff --git a/backend/app/Http/Actions/Users/DeactivateUsersAction.php b/backend/app/Http/Actions/Users/DeactivateUsersAction.phpdeleted file mode 100644index fcdc029a6..000000000--- a/backend/app/Http/Actions/Users/DeactivateUsersAction.php+++ /dev/null@@ -1,39 +0,0 @@-<?php--namespace HiEvents\Http\Actions\Users;--use HiEvents\DomainObjects\Enums\Role;-use HiEvents\DomainObjects\Status\UserStatus;-use HiEvents\DomainObjects\UserDomainObject;-use HiEvents\Http\Actions\BaseAction;-use HiEvents\Repository\Interfaces\UserRepositoryInterface;-use Illuminate\Http\Response;--class DeactivateUsersAction extends BaseAction-{- private UserRepositoryInterface $userRepository;-- public function __construct(UserRepositoryInterface $userRepository)- {- $this->userRepository = $userRepository;- }-- public function __invoke(int $userId): Response- {- $this->isActionAuthorized($userId, UserDomainObject::class, Role::ADMIN);-- $authUser = $this->getAuthenticatedUser();-- $this->userRepository->updateWhere(- attributes: [- 'status' => UserStatus::INACTIVE->name,- ],- where: [- 'id' => $authUser->getId(),- 'account_id' => $this->getAuthenticatedAccountId(),- ]- );-- return $this->deletedResponse();- }-}diff --git a/backend/app/Http/Request/Questions/EditQuestionAnswerRequest.php b/backend/app/Http/Request/Questions/EditQuestionAnswerRequest.phpnew file mode 100644index 000000000..3949c2f61--- /dev/null+++ b/backend/app/Http/Request/Questions/EditQuestionAnswerRequest.php@@ -0,0 +1,22 @@+<?php++namespace HiEvents\Http\Request\Questions;++use HiEvents\Http\Request\BaseRequest;++class EditQuestionAnswerRequest extends BaseRequest+{+ public function rules(): array+ {+ return [+ 'answer' => [+ 'nullable',+ function ($attribute, $value, $fail) {+ if (!is_string($value) && !is_array($value)) {+ $fail("The {$attribute} must be a string or an array.");+ }+ }+ ],+ ];+ }+}diff --git a/backend/app/Models/QuestionAndAnswerView.php b/backend/app/Models/QuestionAndAnswerView.phpindex e5634138f..ff7971a45 100644--- a/backend/app/Models/QuestionAndAnswerView.php+++ b/backend/app/Models/QuestionAndAnswerView.php@@ -14,6 +14,7 @@ class QuestionAndAnswerView extends Modelprotected $casts = ['answer' => 'array',+ 'question_options' => 'array',];public function attendee(): BelongsTodiff --git a/backend/app/Models/QuestionAnswer.php b/backend/app/Models/QuestionAnswer.phpindex c9c4de131..28d722c76 100644--- a/backend/app/Models/QuestionAnswer.php+++ b/backend/app/Models/QuestionAnswer.php@@ -3,6 +3,7 @@namespace HiEvents\Models;use HiEvents\DomainObjects\Generated\QuestionAnswerDomainObjectAbstract;+use Illuminate\Database\Eloquent\Relations\BelongsTo;class QuestionAnswer extends BaseModel{@@ -23,4 +24,14 @@ class QuestionAnswer extends BaseModelQuestionAnswerDomainObjectAbstract::ANSWER,];}++ public function order(): BelongsTo+ {+ return $this->belongsTo(Order::class);+ }++ public function question(): BelongsTo+ {+ return $this->belongsTo(Question::class);+ }}diff --git a/backend/app/Repository/Interfaces/RepositoryInterface.php b/backend/app/Repository/Interfaces/RepositoryInterface.phpindex 0426e1528..0b5930bc7 100644--- a/backend/app/Repository/Interfaces/RepositoryInterface.php+++ b/backend/app/Repository/Interfaces/RepositoryInterface.php@@ -5,6 +5,7 @@ namespace HiEvents\Repository\Interfaces;use Exception;use HiEvents\DomainObjects\Interfaces\DomainObjectInterface;use HiEvents\Repository\Eloquent\Value\OrderAndDirection;+use HiEvents\Repository\Eloquent\Value\Relationship;use Illuminate\Contracts\Pagination\Paginator;use Illuminate\Database\Eloquent\Relations\Relation;use Illuminate\Pagination\LengthAwarePaginator;@@ -198,4 +199,6 @@ interface RepositoryInterfacepublic function incrementEach(array $columns, array $additionalUpdates = [], ?array $where = null);public function includeDeleted(): static;++ public function loadRelation(string|Relationship $relationship): static;}diff --git a/backend/app/Resources/Question/QuestionAnswerViewResource.php b/backend/app/Resources/Question/QuestionAnswerViewResource.phpindex 7c3fae4fe..d5b565c26 100644--- a/backend/app/Resources/Question/QuestionAnswerViewResource.php+++ b/backend/app/Resources/Question/QuestionAnswerViewResource.php@@ -20,6 +20,8 @@ class QuestionAnswerViewResource extends JsonResource'product_title' => $this->getProductTitle(),'question_id' => $this->getQuestionId(),'title' => $this->getTitle(),+ 'question_required' => $this->getQuestionRequired(),+ 'question_description' => $this->getQuestionDescription(),'answer' => $this->getAnswer(),'text_answer' => app(QuestionAnswerFormatter::class)->getAnswerAsText($this->getAnswer(),@@ -28,6 +30,9 @@ class QuestionAnswerViewResource extends JsonResource'order_id' => $this->getOrderId(),'belongs_to' => $this->getBelongsTo(),'question_type' => $this->getQuestionType(),+ 'event_id' => $this->getEventId(),+ 'question_answer_id' => $this->getQuestionAnswerId(),+ 'question_options' => $this->getQuestionOptions(),$this->mergeWhen($this->getAttendeeId() !== null,@@ -35,6 +40,7 @@ class QuestionAnswerViewResource extends JsonResource'attendee_id' => $this->getAttendeeId(),'first_name' => $this->getFirstName(),'last_name' => $this->getLastName(),+ 'attendee_public_id' => $this->getAttendeePublicId(),]),];diff --git a/backend/app/Services/Application/Handlers/Question/DTO/EditQuestionAnswerDTO.php b/backend/app/Services/Application/Handlers/Question/DTO/EditQuestionAnswerDTO.phpnew file mode 100644index 000000000..2f94eb76c--- /dev/null+++ b/backend/app/Services/Application/Handlers/Question/DTO/EditQuestionAnswerDTO.php@@ -0,0 +1,16 @@+<?php++namespace HiEvents\Services\Application\Handlers\Question\DTO;++use HiEvents\DataTransferObjects\BaseDTO;++class EditQuestionAnswerDTO extends BaseDTO+{+ public function __construct(+ public int $questionAnswerId,+ public int $eventId,+ public null|array|string $answer,+ )+ {+ }+}diff --git a/backend/app/Services/Application/Handlers/Question/EditQuestionAnswerHandler.php b/backend/app/Services/Application/Handlers/Question/EditQuestionAnswerHandler.phpnew file mode 100644index 000000000..b263bae71--- /dev/null+++ b/backend/app/Services/Application/Handlers/Question/EditQuestionAnswerHandler.php@@ -0,0 +1,30 @@+<?php++namespace HiEvents\Services\Application\Handlers\Question;++use HiEvents\Services\Application\Handlers\Question\DTO\EditQuestionAnswerDTO;+use HiEvents\Services\Domain\Question\EditQuestionAnswerService;+use HiEvents\Services\Domain\Question\Exception\InvalidAnswerException;+use JsonException;++class EditQuestionAnswerHandler+{+ public function __construct(+ private readonly EditQuestionAnswerService $editQuestionAnswerService,+ )+ {+ }++ /**+ * @throws InvalidAnswerException+ * @throws JsonException+ */+ public function handle(EditQuestionAnswerDTO $editQuestionAnswerDTO): void+ {+ $this->editQuestionAnswerService->editQuestionAnswer(+ eventId: $editQuestionAnswerDTO->eventId,+ questionAnswerId: $editQuestionAnswerDTO->questionAnswerId,+ answer: $editQuestionAnswerDTO->answer,+ );+ }+}diff --git a/backend/app/Services/Domain/Question/EditQuestionAnswerService.php b/backend/app/Services/Domain/Question/EditQuestionAnswerService.phpnew file mode 100644index 000000000..899f97928--- /dev/null+++ b/backend/app/Services/Domain/Question/EditQuestionAnswerService.php@@ -0,0 +1,66 @@+<?php++namespace HiEvents\Services\Domain\Question;++use HiEvents\DomainObjects\OrderDomainObject;+use HiEvents\DomainObjects\QuestionDomainObject;+use HiEvents\Repository\Eloquent\Value\Relationship;+use HiEvents\Repository\Interfaces\QuestionAnswerRepositoryInterface;+use HiEvents\Services\Domain\Question\Exception\InvalidAnswerException;+use Psr\Log\LoggerInterface;+use Symfony\Component\Routing\Exception\ResourceNotFoundException;++class EditQuestionAnswerService+{+ public function __construct(+ private readonly QuestionAnswerRepositoryInterface $questionAnswerRepository,+ private readonly LoggerInterface $logger,+ )+ {+ }++ /**+ * @throws InvalidAnswerException+ * @throws \JsonException+ */+ public function editQuestionAnswer(int $eventId, int $questionAnswerId, null|string|array $answer): void+ {+ $questionAnswer = $this->questionAnswerRepository+ ->loadRelation(new Relationship(domainObject: OrderDomainObject::class, name: 'order'))+ ->loadRelation(new Relationship(domainObject: QuestionDomainObject::class, name: 'question'))+ ->findById($questionAnswerId);++ /** @var QuestionDomainObject $question */+ $question = $questionAnswer->getQuestion();+ /** @var OrderDomainObject $order */+ $order = $questionAnswer->getOrder();++ if ($order->getEventId() !== $eventId) {+ $this->logger->error('Question answer does not belong to the event', [+ 'event_id' => $eventId,+ 'question_answer_id' => $questionAnswerId,+ ]);++ throw new ResourceNotFoundException('Question answer does not belong to the event');+ }++ if (!$question->isAnswerValid($answer)) {+ $this->logger->error('Invalid answer', [+ 'question_id' => $question->getId(),+ 'answer' => $answer,+ ]);++ throw new InvalidAnswerException('Please provide a valid answer');+ }++ $this->questionAnswerRepository->updateWhere(+ attributes: [+ 'answer' => json_encode($answer, JSON_THROW_ON_ERROR),+ ],+ where: [+ 'id' => $questionAnswerId,+ 'order_id' => $order->getId(),+ ],+ );+ }+}diff --git a/backend/app/Services/Domain/Question/Exception/InvalidAnswerException.php b/backend/app/Services/Domain/Question/Exception/InvalidAnswerException.phpnew file mode 100644index 000000000..5233e65b2--- /dev/null+++ b/backend/app/Services/Domain/Question/Exception/InvalidAnswerException.php@@ -0,0 +1,10 @@+<?php++namespace HiEvents\Services\Domain\Question\Exception;++use Exception;++class InvalidAnswerException extends Exception+{++}diff --git a/backend/app/Validators/Rules/BaseQuestionRule.php b/backend/app/Validators/Rules/BaseQuestionRule.phpindex f30ce6e0f..333d07d6e 100644--- a/backend/app/Validators/Rules/BaseQuestionRule.php+++ b/backend/app/Validators/Rules/BaseQuestionRule.php@@ -85,23 +85,6 @@ abstract class BaseQuestionRule implements ValidationRule, DataAwareRule, Validareturn $productPrice->getProductId();}- protected function isAnswerValid(QuestionDomainObject $questionDomainObject, mixed $response): bool- {- if (!$questionDomainObject->isPreDefinedChoice()) {- return true;- }-- if (!isset($response['answer'])) {- return false;- }-- if (is_string($response['answer'])) {- return in_array($response['answer'], $questionDomainObject->getOptions(), true);- }-- return array_diff((array)$response['answer'], $questionDomainObject->getOptions()) === [];- }-protected function getQuestionDomainObject(?int $questionId): ?QuestionDomainObject{if ($questionId === null) {diff --git a/backend/app/Validators/Rules/OrderQuestionRule.php b/backend/app/Validators/Rules/OrderQuestionRule.phpindex 7d80557a2..303247849 100644--- a/backend/app/Validators/Rules/OrderQuestionRule.php+++ b/backend/app/Validators/Rules/OrderQuestionRule.php@@ -32,6 +32,7 @@ class OrderQuestionRule extends BaseQuestionRule$questionDomainObject = $this->getQuestionDomainObject($orderQuestion['question_id']);$key = 'order.questions.' . $index . '.response';$response = $orderQuestion['response'] ?? null;+ $answer = $response['answer'] ?? $response;if (!$questionDomainObject) {$validationMessages[$key . '.answer'][] = 'This question is outdated. Please reload the page.';@@ -46,7 +47,7 @@ class OrderQuestionRule extends BaseQuestionRule$validationMessages = $this->validateRequiredFields($questionDomainObject, $response, $key, $validationMessages);}- if (!$this->isAnswerValid($questionDomainObject, $response)) {+ if (!$questionDomainObject->isAnswerValid($answer)) {$validationMessages[$key . '.answer'][] = 'Please select an option';}diff --git a/backend/app/Validators/Rules/ProductQuestionRule.php b/backend/app/Validators/Rules/ProductQuestionRule.phpindex 534dd92ef..56479d954 100644--- a/backend/app/Validators/Rules/ProductQuestionRule.php+++ b/backend/app/Validators/Rules/ProductQuestionRule.php@@ -59,6 +59,7 @@ class ProductQuestionRule extends BaseQuestionRule$questionDomainObject = $this->getQuestionDomainObject($question['question_id'] ?? null);$key = 'products.' . $productIndex . '.questions.' . $questionIndex . '.response';$response = empty($question['response']) ? null : $question['response'];+ $answer = $response['answer'] ?? $response;if (!$questionDomainObject) {$validationMessages[$key . '.answer'][] = __('This question is outdated. Please reload the page.');@@ -73,7 +74,7 @@ class ProductQuestionRule extends BaseQuestionRule$validationMessages = $this->validateRequiredFields($questionDomainObject, $response, $key, $validationMessages);}- if (!$this->isAnswerValid($questionDomainObject, $response)) {+ if (!$questionDomainObject->isAnswerValid($answer)) {$validationMessages[$key . '.answer'][] = __('Please select an option');}diff --git a/backend/config/timezones.php b/backend/config/timezones.phpindex 54a80be57..c15cba5dc 100644--- a/backend/config/timezones.php+++ b/backend/config/timezones.php@@ -12,7 +12,86 @@ return ['Asia/Macao' => 'Asia/Macau','Pacific/Samoa' => 'Pacific/Pago_Pago','Pacific/Yap' => 'Pacific/Chuuk',- 'Etc/GMT+0' => 'Etc/GMT','Etc/Greenwich' => 'Etc/GMT',++ 'Etc/GMT+1' => 'Atlantic/Azores', // UTC-1+ 'Etc/GMT+2' => 'Atlantic/South_Georgia', // UTC-2+ 'Etc/GMT+3' => 'America/Argentina/Buenos_Aires', // UTC-3+ 'Etc/GMT+4' => 'America/La_Paz', // UTC-4+ 'Etc/GMT+5' => 'America/New_York', // UTC-5+ 'Etc/GMT+6' => 'America/Chicago', // UTC-6+ 'Etc/GMT+7' => 'America/Denver', // UTC-7+ 'Etc/GMT+8' => 'America/Los_Angeles', // UTC-8+ 'Etc/GMT+9' => 'America/Anchorage', // UTC-9+ 'Etc/GMT+10' => 'Pacific/Honolulu', // UTC-10+ 'Etc/GMT+11' => 'Pacific/Pago_Pago', // UTC-11+ 'Etc/GMT-1' => 'Europe/Paris', // UTC+1+ 'Etc/GMT-2' => 'Europe/Athens', // UTC+2+ 'Etc/GMT-3' => 'Europe/Moscow', // UTC+3+ 'Etc/GMT-4' => 'Asia/Dubai', // UTC+4+ 'Etc/GMT-5' => 'Asia/Karachi', // UTC+5+ 'Etc/GMT-6' => 'Asia/Dhaka', // UTC+6+ 'Etc/GMT-7' => 'Asia/Bangkok', // UTC+7+ 'Etc/GMT-8' => 'Asia/Singapore', // UTC+8+ 'Etc/GMT-9' => 'Asia/Tokyo', // UTC+9+ 'Etc/GMT-10' => 'Pacific/Port_Moresby', // UTC+10+ 'Etc/GMT-11' => 'Pacific/Noumea', // UTC+11+ 'Etc/GMT-12' => 'Pacific/Fiji', // UTC+12++ 'Africa/Timbuktu' => 'Africa/Bamako',+ 'America/Argentina/ComodRivadavia' => 'America/Argentina/Catamarca',+ 'America/Atka' => 'America/Adak',+ 'America/Ensenada' => 'America/Tijuana',+ 'America/Fort_Wayne' => 'America/Indiana/Indianapolis',+ 'America/Knox_IN' => 'America/Indiana/Knox',+ 'America/Louisville' => 'America/Kentucky/Louisville',+ 'America/Montreal' => 'America/Toronto',+ 'America/Shiprock' => 'America/Denver',+ 'Asia/Ashkhabad' => 'Asia/Ashgabat',+ 'Asia/Chungking' => 'Asia/Shanghai',+ 'Asia/Dacca' => 'Asia/Dhaka',+ 'Asia/Harbin' => 'Asia/Shanghai',+ 'Asia/Istanbul' => 'Europe/Istanbul',+ 'Asia/Kashgar' => 'Asia/Urumqi',+ 'Asia/Tel_Aviv' => 'Asia/Jerusalem',+ 'Australia/ACT' => 'Australia/Sydney',+ 'Australia/Canberra' => 'Australia/Sydney',+ 'Australia/LHI' => 'Australia/Lord_Howe',+ 'Australia/NSW' => 'Australia/Sydney',+ 'Australia/North' => 'Australia/Darwin',+ 'Australia/Queensland' => 'Australia/Brisbane',+ 'Australia/South' => 'Australia/Adelaide',+ 'Australia/Tasmania' => 'Australia/Hobart',+ 'Australia/Victoria' => 'Australia/Melbourne',+ 'Australia/West' => 'Australia/Perth',+ 'Australia/Yancowinna' => 'Australia/Broken_Hill',+ 'Brazil/Acre' => 'America/Rio_Branco',+ 'Brazil/DeNoronha' => 'America/Noronha',+ 'Brazil/East' => 'America/Sao_Paulo',+ 'Brazil/West' => 'America/Manaus',+ 'Canada/Atlantic' => 'America/Halifax',+ 'Canada/Central' => 'America/Winnipeg',+ 'Canada/Eastern' => 'America/Toronto',+ 'Canada/Mountain' => 'America/Edmonton',+ 'Canada/Newfoundland' => 'America/St_Johns',+ 'Canada/Pacific' => 'America/Vancouver',+ 'Canada/Saskatchewan' => 'America/Regina',+ 'Canada/Yukon' => 'America/Whitehorse',+ 'Chile/Continental' => 'America/Santiago',+ 'Chile/EasterIsland' => 'Pacific/Easter',+ 'Cuba' => 'America/Havana',+ 'Egypt' => 'Africa/Cairo',+ 'Eire' => 'Europe/Dublin',+ 'GB' => 'Europe/London',+ 'GB-Eire' => 'Europe/London',+ 'Hongkong' => 'Asia/Hong_Kong',+ 'Iceland' => 'Atlantic/Reykjavik',+ 'Iran' => 'Asia/Tehran',+ 'Israel' => 'Asia/Jerusalem',+ 'Jamaica' => 'America/Jamaica',+ 'Japan' => 'Asia/Tokyo',+ 'Kwajalein' => 'Pacific/Kwajalein',+ 'Libya' => 'Africa/Tripoli',+ 'Mexico/BajaNorte' => 'America/Tijuana',],];diff --git a/backend/database/migrations/2025_02_28_112829_update_question_and_answers_view.php b/backend/database/migrations/2025_02_28_112829_update_question_and_answers_view.phpnew file mode 100644index 000000000..42caa1376--- /dev/null+++ b/backend/database/migrations/2025_02_28_112829_update_question_and_answers_view.php@@ -0,0 +1,62 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Support\Facades\DB;++return new class extends Migration {+ public function up(): void+ {+ DB::statement('DROP VIEW IF EXISTS question_and_answer_views');++ DB::statement("+ CREATE VIEW question_and_answer_views AS+ SELECT+ qa.id AS question_answer_id,+ p.id AS product_id,+ p.title AS product_title,+ q.id AS question_id,+ q.event_id,+ q.belongs_to,+ q.type AS question_type,+ a.first_name,+ a.last_name,+ a.id AS attendee_id,+ a.public_id AS attendee_public_id,+ qa.order_id,+ q.title,+ q.description AS question_description,+ q.required AS question_required,+ q.options AS question_options,+ qa.answer+ FROM question_answers qa+ LEFT JOIN attendees a ON a.id = qa.attendee_id+ LEFT JOIN products p ON p.id = qa.product_id+ JOIN questions q ON q.id = qa.question_id;+ ");+ }++ public function down(): void+ {+ DB::statement('DROP VIEW IF EXISTS question_and_answer_views');++ DB::statement("+ CREATE VIEW question_and_answer_views AS+ SELECT p.id AS product_id,+ p.title AS product_title,+ q.id AS question_id,+ q.event_id,+ q.belongs_to,+ q.type AS question_type,+ a.first_name,+ a.last_name,+ a.id AS attendee_id,+ qa.order_id,+ q.title,+ qa.answer+ FROM question_answers qa+ LEFT JOIN attendees a ON a.id = qa.attendee_id+ LEFT JOIN products p ON p.id = qa.product_id+ JOIN questions q ON q.id = qa.question_id;+ ");+ }+};diff --git a/backend/database/migrations/schema.sql b/backend/database/migrations/schema.sqlindex 4b20e570d..7ae79c6e8 100644--- a/backend/database/migrations/schema.sql+++ b/backend/database/migrations/schema.sql@@ -1,3 +1,5 @@+-- DO NOT MODIFY THIS FILE. Create a new migration file instead.+create table if not exists migrations(id serial,@@ -782,7 +784,8 @@ SELECT q.id AS question_id,a.id AS attendee_id,qa.order_id,q.title,- qa.answer+ qa.answer,+ qa.id as question_answer_idFROM question_answers qaLEFT JOIN attendees a ON a.id = qa.attendee_idJOIN orders o ON qa.order_id = o.iddiff --git a/backend/routes/api.php b/backend/routes/api.phpindex 2d951cebe..29e576215 100644--- a/backend/routes/api.php+++ b/backend/routes/api.php@@ -97,6 +97,7 @@ use HiEvents\Http\Actions\PromoCodes\UpdatePromoCodeAction;use HiEvents\Http\Actions\Questions\CreateQuestionAction;use HiEvents\Http\Actions\Questions\DeleteQuestionAction;use HiEvents\Http\Actions\Questions\EditQuestionAction;+use HiEvents\Http\Actions\Questions\EditQuestionAnswerAction;use HiEvents\Http\Actions\Questions\GetQuestionAction;use HiEvents\Http\Actions\Questions\GetQuestionsAction;use HiEvents\Http\Actions\Questions\GetQuestionsPublicAction;@@ -110,7 +111,6 @@ use HiEvents\Http\Actions\Users\CancelEmailChangeAction;use HiEvents\Http\Actions\Users\ConfirmEmailAddressAction;use HiEvents\Http\Actions\Users\ConfirmEmailChangeAction;use HiEvents\Http\Actions\Users\CreateUserAction;-use HiEvents\Http\Actions\Users\DeactivateUsersAction;use HiEvents\Http\Actions\Users\DeleteInvitationAction;use HiEvents\Http\Actions\Users\GetMeAction;use HiEvents\Http\Actions\Users\GetUserAction;@@ -164,7 +164,6 @@ $router->middleware(['auth:api'])->group($router->get('/users', GetUsersAction::class);$router->get('/users/{user_id}', GetUserAction::class);$router->put('/users/{user_id}', UpdateUserAction::class);- $router->delete('/users/{user_id}', DeactivateUsersAction::class);$router->post('/users/{user_id}/email-change/{token}', ConfirmEmailChangeAction::class);$router->post('/users/{user_id}/invitation', ResendInvitationAction::class);$router->delete('/users/{user_id}/invitation', DeleteInvitationAction::class);@@ -248,6 +247,7 @@ $router->middleware(['auth:api'])->group($router->get('/events/{event_id}/questions', GetQuestionsAction::class);$router->post('/events/{event_id}/questions/export', ExportOrdersAction::class);$router->post('/events/{event_id}/questions/sort', SortQuestionsAction::class);+ $router->put('/events/{event_id}/questions/{question_id}/answer/{answer_id}', EditQuestionAnswerAction::class);// Images$router->post('/events/{event_id}/images', CreateEventImageAction::class);diff --git a/backend/vapor.yml b/backend/vapor.ymlindex d1872bbcc..4f9f176f5 100644--- a/backend/vapor.yml+++ b/backend/vapor.yml@@ -1,15 +1,15 @@-id: 68983+id: 69938name: HiEventsenvironments:production:gateway-version: 2.0domain: api.hi.events- memory: 1408+ memory: 2048cli-memory: 512runtime: 'php-8.3:al2'warm: 3- cache: hievents-redis-prod- database: hievents-db-prod+ cache: hievents-redis+ database: hievents-postgresqueues:- hievents-queue-prod- hievents-webhook-queue-prod@@ -28,8 +28,8 @@ environments:cli-memory: 512runtime: 'php-8.3:al2'warm: 3- cache: hievents-redis-prod- database: hievents-db-prod+ cache: hievents-redis+ database: hievents-postgresqueue:- hievents-queue-prod- hievents-webhook-queue-stagingdiff --git a/frontend/src/api/question.client.ts b/frontend/src/api/question.client.tsindex 10e4f8ce5..f921ad8b8 100644--- a/frontend/src/api/question.client.ts+++ b/frontend/src/api/question.client.ts@@ -32,7 +32,12 @@ export const questionClient = {},sortQuestions: async (eventId: IdParam, questionsSort: SortableItem[]) => {return await api.post(`/events/${eventId}/questions/sort`, questionsSort);- }+ },+ updateAnswerQuestion: async (eventId: IdParam, questionId: IdParam, answerId: IdParam, answer: string | string[]) => {+ await api.put(`/events/${eventId}/questions/${questionId}/answer/${answerId}`, {+ 'answer': answer,+ });+ },}export const questionClientPublic = {diff --git a/frontend/src/components/common/AttendeeList/AttendeeList.module.scss b/frontend/src/components/common/AttendeeList/AttendeeList.module.scssindex 622146ad4..367b11820 100644--- a/frontend/src/components/common/AttendeeList/AttendeeList.module.scss+++ b/frontend/src/components/common/AttendeeList/AttendeeList.module.scss@@ -12,7 +12,7 @@.attendee {display: flex;- align-items: center;+ flex-direction: column;padding: 0.875rem;background: var(--mantine-color-gray-0);border: 1px solid var(--mantine-color-gray-2);@@ -58,3 +58,32 @@background: var(--tk-color-gray);font-weight: 500;}++/* Added styles for answers display */+.answersContainer {+ margin-top: 0.75rem;+ padding-top: 0.75rem;+ padding-left: .4rem;+ border-top: 1px solid var(--mantine-color-gray-2);+}++.questionAnswer {+ margin-bottom: 0.75rem;++ &:last-child {+ margin-bottom: 0;+ }+}++.questionTitle {+ display: flex;+ gap: 0.5rem;+ margin-bottom: 0.25rem;+ align-items: flex-start;+}++.answer {+ color: var(--mantine-color-gray-7);+ padding-left: 1.5rem;+ font-size: var(--mantine-font-size-sm);+}diff --git a/frontend/src/components/common/AttendeeList/index.tsx b/frontend/src/components/common/AttendeeList/index.tsxindex b93a033d5..6a8ebc11b 100644--- a/frontend/src/components/common/AttendeeList/index.tsx+++ b/frontend/src/components/common/AttendeeList/index.tsx@@ -1,19 +1,21 @@-import { ActionIcon, Avatar, Tooltip, Text, Group } from "@mantine/core";-import { getInitials } from "../../../utilites/helpers.ts";-import { NavLink } from "react-router";-import { IconExternalLink, IconUsers } from "@tabler/icons-react";+import {ActionIcon, Avatar, Collapse, Group, Text, Tooltip} from "@mantine/core";+import {getInitials} from "../../../utilites/helpers.ts";+import {NavLink} from "react-router";+import {IconChevronUp, IconExternalLink, IconMessageCircle2} from "@tabler/icons-react";import classes from './AttendeeList.module.scss';-import { Order, Product } from "../../../types.ts";-import { t } from "@lingui/macro";+import {IdParam, Order, Product, QuestionAnswer} from "../../../types.ts";+import {t} from "@lingui/macro";+import {useState} from "react";+import {QuestionList} from "../QuestionAndAnswerList";interface AttendeeListProps {order: Order;products: Product[];+ questionAnswers?: QuestionAnswer[];+ refetchOrder?: () => void;}-export const AttendeeList = ({ order, products }: AttendeeListProps) => {- const attendeeCount = order.attendees?.length || 0;-+export const AttendeeList = ({order, products, refetchOrder, questionAnswers = []}: AttendeeListProps) => {if (!order.attendees?.length) {return (<div className={classes.container}>@@ -24,12 +26,35 @@ export const AttendeeList = ({ order, products }: AttendeeListProps) => {);}+ const [expandedAttendees, setExpandedAttendees] = useState<IdParam[]>([]);++ const hasQuestions = (attendeeId: IdParam) => {+ return questionAnswers.some(qa => qa.attendee_id === attendeeId);+ };++ const getAttendeeQuestions = (attendeeId: IdParam) => {+ return questionAnswers.filter(qa => qa.attendee_id === attendeeId);+ };++ const toggleExpanded = (attendeeId: IdParam) => {+ setExpandedAttendees(prev =>+ prev.includes(attendeeId)+ ? prev.filter(id => id !== attendeeId)+ : [...prev, attendeeId]+ );+ };++ const isExpanded = (attendeeId: IdParam) => {+ return expandedAttendees.includes(attendeeId);+ };+return (<div className={classes.container}><div className={classes.attendeeList}>{order.attendees.map(attendee => {const product = products?.find(p => p.id === attendee.product_id);const fullName = `${attendee.first_name} ${attendee.last_name}`;+ const attendeeHasQuestions = hasQuestions(attendee.id);return (<div key={attendee.id} className={classes.attendee}>@@ -53,23 +78,56 @@ export const AttendeeList = ({ order, products }: AttendeeListProps) => {)}</div>- <Tooltip- label={t`View Attendee Details`}- position="bottom"- withArrow- >- <NavLink to={`../attendees?query=${attendee.public_id}`}>- <ActionIcon- variant="subtle"- radius="xl"- size="sm"- className={classes.actionButton}+ <Group gap="xs">+ {attendeeHasQuestions && (+ <Tooltip+ label={isExpanded(attendee.id) ? t`Hide Answers` : t`View Answers`}+ position="bottom"+ withArrow>- <IconExternalLink size={16} stroke={1.5} />- </ActionIcon>- </NavLink>- </Tooltip>+ <ActionIcon+ variant="subtle"+ radius="xl"+ size="sm"+ className={classes.actionButton}+ onClick={() => toggleExpanded(attendee.id)}+ >+ {isExpanded(attendee.id)+ ? <IconChevronUp size={16} stroke={1.5}/>+ : <IconMessageCircle2 size={16} stroke={1.5}/>}+ </ActionIcon>+ </Tooltip>+ )}++ <Tooltip+ label={t`View Attendee Details`}+ position="bottom"+ withArrow+ >+ <NavLink to={`../attendees?query=${attendee.public_id}`}>+ <ActionIcon+ variant="subtle"+ radius="xl"+ size="sm"+ className={classes.actionButton}+ >+ <IconExternalLink size={16} stroke={1.5}/>+ </ActionIcon>+ </NavLink>+ </Tooltip>+ </Group></div>++ {/* Collapsible answers section */}+ <Collapse in={isExpanded(attendee.id)}>+ <div className={classes.answersContainer}>+ <QuestionList+ compact+ questions={getAttendeeQuestions(attendee.id)}+ onEditAnswer={refetchOrder}+ />+ </div>+ </Collapse></div>);})}diff --git a/frontend/src/components/common/QuestionAndAnswerList/QuestionAndAnswerList.module.scss b/frontend/src/components/common/QuestionAndAnswerList/QuestionAndAnswerList.module.scssindex ea556c5b9..9acae80f4 100644--- a/frontend/src/components/common/QuestionAndAnswerList/QuestionAndAnswerList.module.scss+++ b/frontend/src/components/common/QuestionAndAnswerList/QuestionAndAnswerList.module.scss@@ -1,77 +1,135 @@+/* QuestionAndAnswerList.module.scss */.container {display: flex;flex-direction: column;- gap: 2rem;+ gap: 1.5rem;}.section {display: flex;flex-direction: column;- gap: 5px;+ gap: 0.75rem;}.sectionHeader {- display: flex;- align-items: center;- gap: 0.5rem;- padding-bottom: 0.75rem;+ padding-bottom: 0.5rem;+ border-bottom: 1px solid var(--mantine-color-gray-2);}.questionsList {display: flex;flex-direction: column;- gap: 1rem;+ gap: 0.75rem;}.questionCard {- padding: 1rem;- border-radius: var(--mantine-radius-sm);- background: var(--mantine-color-gray-0);+ padding: 0.75rem;+ background: #ffffff;border: 1px solid var(--mantine-color-gray-2);- transition: all 0.2s ease;+ border-radius: var(--mantine-radius-sm);+}++.questionCompact {+ padding: 0.5rem 0;+ border-bottom: 1px solid var(--mantine-color-gray-1);- &:hover {- border-color: var(--mantine-color-gray-3);+ &:last-child {+ border-bottom: none;}}.productTitle {color: var(--mantine-color-gray-6);margin-bottom: 0.5rem;+ font-size: var(--mantine-font-size-xs);}.questionTitle {display: flex;gap: 0.5rem;+ margin-bottom: 0.375rem;align-items: flex-start;- margin-bottom: 0.75rem;+}- svg {- margin-top: 0;- }+.answerContainer {+ display: flex;+ align-items: flex-start;+ gap: 0.5rem;}.answer {- color: var(--mantine-color-dark-9);- line-height: 1.5;- padding: 0.5rem 0;+ flex: 1;+ color: var(--mantine-color-dark-6);+ word-break: break-word;+}++.editContainer {+ padding: 0.5rem;+ background: var(--mantine-color-gray-0);+ border: 1px solid var(--mantine-color-gray-2);+ border-radius: var(--mantine-radius-sm);+}++.editActions {+ margin-top: 0.5rem;}.attendeeInfo {display: flex;align-items: center;gap: 0.5rem;- margin-top: 0.75rem;- padding-top: 0.75rem;- border-top: 1px solid var(--mantine-color-gray-2);+ margin-top: 0.625rem;+ padding-top: 0.625rem;+ border-top: 1px solid var(--mantine-color-gray-1);+ color: var(--mantine-color-gray-6);}.emptyState {+ padding: 1.5rem;+ text-align: center;+}++.questionText {+ color: #333;+ border-bottom: 1px solid #f0f0f0;+ padding-bottom: 4px;+}++/* New styles for attendee-focused layout */+.attendeeQuestionsList {display: flex;- align-items: center;- justify-content: center;- padding: 2rem;- background: var(--mantine-color-gray-0);+ flex-direction: column;+ gap: 0.75rem;+}++.attendeeSection {+ border: 1px solid var(--mantine-color-gray-3);border-radius: var(--mantine-radius-sm);- color: var(--mantine-color-gray-6);+ overflow: hidden;+ background: var(--mantine-color-gray-0);+}++.attendeeHeader {+ display: flex;+ justify-content: space-between;+ align-items: center;+ padding: 0.5rem 0.75rem;+ background-color: var(--mantine-color-gray-1);+ border-bottom: 1px solid var(--mantine-color-gray-3);+}++.attendeeQuestions {+ padding: 0.5rem;+ display: flex;+ flex-direction: column;+ gap: 0.5rem;+}++/* In compact mode, adjust spacing in attendee sections */+.questionCompact:first-child {+ padding-top: 0.25rem;+}++.questionCompact:last-child {+ padding-bottom: 0.25rem;}diff --git a/frontend/src/components/common/QuestionAndAnswerList/index.tsx b/frontend/src/components/common/QuestionAndAnswerList/index.tsxindex 090f88c1f..ae482bdb3 100644--- a/frontend/src/components/common/QuestionAndAnswerList/index.tsx+++ b/frontend/src/components/common/QuestionAndAnswerList/index.tsx@@ -1,16 +1,331 @@-import {QuestionAnswer} from "../../../types.ts";-import {ActionIcon, Group, Text, Tooltip} from '@mantine/core';+import {IdParam, QuestionAnswer} from "../../../types.ts";+import {ActionIcon, Button, Group, Text, Tooltip} from '@mantine/core';import {t} from "@lingui/macro";-import {NavLink} from "react-router";-import {IconExternalLink, IconMessageCircle2, IconPackage, IconShoppingCart, IconUser} from "@tabler/icons-react";+import {+ IconEdit,+ IconExternalLink,+ IconPackage,+ IconShoppingCart,+ IconUser+} from "@tabler/icons-react";+import {NavLink, useParams} from "react-router";import classes from './QuestionAndAnswerList.module.scss';+import {useEditQuestionAnswer} from "../../../mutations/useEditQuestionAnswer.ts";+import {QuestionInput} from "../CheckoutQuestion";+import {useForm} from "@mantine/form";+import {useState} from "react";+import {showError, showSuccess} from "../../../utilites/notifications.tsx";+import {formatAnswer} from "../../../utilites/questionHelper.ts";+import {useFormErrorResponseHandler} from "../../../hooks/useFormErrorResponseHandler.tsx";interface QuestionAndAnswerListProps {questionAnswers: QuestionAnswer[];belongsToFilter?: string[];+ onEditAnswer?: () => void;}-export const QuestionAndAnswerList = ({questionAnswers, belongsToFilter}: QuestionAndAnswerListProps) => {+interface QuestionListProps {+ questions: QuestionAnswer[];+ onEditAnswer?: () => void;+ compact?: boolean;+}++interface AttendeeQuestionsListProps {+ attendeeQuestions: QuestionAnswer[];+ onEditAnswer?: () => void;+ compact?: boolean;+}++interface QuestionItemProps {+ qa: QuestionAnswer;+ isEditing: boolean;+ toggleEditMode: (id: IdParam) => void;+ onEditAnswer?: () => void;+ compact?: boolean;+ eventId?: string;+ hideAttendeeInfo?: boolean;+}++// Separated QuestionItem component to isolate form initialization+const QuestionItem = ({ qa, isEditing, toggleEditMode, onEditAnswer, compact = false, eventId, hideAttendeeInfo = false }: QuestionItemProps) => {+ const errorHandler = useFormErrorResponseHandler();+ const updateAnswerMutation = useEditQuestionAnswer();++ // Form initialization is now isolated in this component+ const initialValues = qa.question_type === 'ADDRESS' ? {+ answer: qa.answer,+ } : {+ answer: {+ answer: qa.answer,+ },+ };++ const questionForm = useForm({+ initialValues: initialValues,+ transformValues: (values) => {+ // Make sure we're handling the transformation consistently+ // For ADDRESS type, just pass the answer directly+ // For other types, extract the nested answer value+ // Also add null/undefined checks+ let transformedAnswer;+ if (qa.question_type === 'ADDRESS') {+ transformedAnswer = values.answer;+ } else {+ // Handle both possible structures to be safe+ transformedAnswer = values.answer && typeof values.answer === 'object' && 'answer' in values.answer+ ? values.answer.answer+ : values.answer;+ }++ return {+ answer: transformedAnswer+ };+ },+ });++ const handleSubmit = (values: { answer: any }) => {+ // Don't transform the answer - the form's transformValues has already done this+ // The values parameter here is already the result of the transformValues function+ updateAnswerMutation.mutate({+ questionId: qa.question_id,+ answer: values.answer,+ answerId: qa.question_answer_id,+ eventId: eventId,+ }, {+ onSuccess: () => {+ toggleEditMode(qa.question_id);+ showSuccess(t`Answer updated successfully.`);+ onEditAnswer?.();+ },+ onError: (error) => {+ errorHandler(questionForm, error);+ showError(t`Failed to update answer.`);+ }+ });+ };++ return (+ <div className={compact ? classes.questionCompact : classes.questionCard}>+ {qa.product_title && !compact && (+ <Text size="sm" className={classes.productTitle}>+ {qa.product_title}+ </Text>+ )}++ <div className={classes.questionTitle}>+ <Text size="sm" fw={600} className={classes.questionText}>+ {qa.title}+ </Text>+ </div>++ {isEditing ? (+ <form onSubmit={questionForm.onSubmit(handleSubmit)}>+ <div className={classes.editContainer}>+ <QuestionInput+ question={{+ id: qa.question_id,+ title: qa.title,+ type: qa.question_type,+ options: qa.question_options,+ required: qa.question_required,+ }}+ name="answer"+ form={questionForm}+ />+ <Group gap="xs" className={classes.editActions}>+ <Button+ type="submit"+ variant="light"+ size="xs"+ loading={updateAnswerMutation.isPending}+ >+ {t`Save`}+ </Button>+ <Button+ variant="subtle"+ size="xs"+ onClick={() => toggleEditMode(qa.question_id)}+ >+ {t`Cancel`}+ </Button>+ </Group>+ </div>+ </form>+ ) : (+ <div className={classes.answerContainer}>+ <Text size="sm" className={classes.answer} style={{whiteSpace: 'pre-line'}}>+ {formatAnswer(qa.answer)}+ </Text>+ <Tooltip label={t`Edit Answer`} position="bottom" withArrow>+ <ActionIcon+ variant="subtle"+ radius="xl"+ size="sm"+ onClick={() => toggleEditMode(qa.question_id)}+ >+ <IconEdit size={16}/>+ </ActionIcon>+ </Tooltip>+ </div>+ )}++ {qa.attendee_id && !compact && !hideAttendeeInfo && (+ <div className={classes.attendeeInfo}>+ <IconUser size={14} stroke={1.5}/>+ <Text size="sm" span>+ {qa.first_name+ ? `${qa.first_name} ${qa.last_name}`+ : t`N/A`}+ </Text>+ <Tooltip+ label={t`Navigate to Attendee`}+ position="bottom"+ withArrow+ >+ <NavLink to={`../attendees?query=${qa.attendee_public_id}`}>+ <ActionIcon+ variant="subtle"+ radius="xl"+ size="xs"+ >+ <IconExternalLink size={12}/>+ </ActionIcon>+ </NavLink>+ </Tooltip>+ </div>+ )}+ </div>+ );+};++export const QuestionList = ({questions, onEditAnswer, compact = false}: QuestionListProps) => {+ const {eventId} = useParams();+ const [editingQuestionIds, setEditingQuestionIds] = useState<IdParam[]>([]);++ const toggleEditMode = (questionId: IdParam) => {+ setEditingQuestionIds(prev =>+ prev.includes(questionId)+ ? prev.filter(id => id !== questionId)+ : [...prev, questionId]+ );+ };++ const isEditing = (questionId: IdParam) => {+ return editingQuestionIds.includes(questionId);+ };++ if (!questions.length) {+ return null;+ }++ return (+ <div className={classes.questionsList}>+ {questions.map((qa, index) => (+ <QuestionItem+ key={`${qa.question_id}-${index}`}+ qa={qa}+ isEditing={isEditing(qa.question_id)}+ toggleEditMode={toggleEditMode}+ onEditAnswer={onEditAnswer}+ compact={compact}+ eventId={eventId}+ />+ ))}+ </div>+ );+};++// New component to group questions by attendee+export const AttendeeQuestionsList = ({attendeeQuestions, onEditAnswer, compact = false}: AttendeeQuestionsListProps) => {+ const {eventId} = useParams();+ const [editingQuestionIds, setEditingQuestionIds] = useState<IdParam[]>([]);++ const toggleEditMode = (questionId: IdParam) => {+ setEditingQuestionIds(prev =>+ prev.includes(questionId)+ ? prev.filter(id => id !== questionId)+ : [...prev, questionId]+ );+ };++ const isEditing = (questionId: IdParam) => {+ return editingQuestionIds.includes(questionId);+ };++ if (!attendeeQuestions.length) {+ return null;+ }++ // Group questions by attendee+ const groupedByAttendee: Record<string, QuestionAnswer[]> = {};++ attendeeQuestions.forEach(qa => {+ const attendeeKey = qa.attendee_id || 'unknown';+ if (!groupedByAttendee[attendeeKey]) {+ groupedByAttendee[attendeeKey] = [];+ }+ groupedByAttendee[attendeeKey].push(qa);+ });++ return (+ <div className={classes.attendeeQuestionsList}>+ {Object.entries(groupedByAttendee).map(([attendeeId, questions]) => {+ const attendeeInfo = questions[0]; // Take first question to get attendee info++ return (+ <div key={attendeeId} className={classes.attendeeSection}>+ {/* Attendee header with name and link */}+ <div className={classes.attendeeHeader}>+ <Group gap="xs">+ <IconUser size={16} stroke={1.5}/>+ <Text size="sm" fw={600}>+ {attendeeInfo.first_name+ ? `${attendeeInfo.first_name} ${attendeeInfo.last_name}`+ : t`Unknown Attendee`}+ </Text>+ </Group>+ {attendeeInfo.attendee_public_id && (+ <Tooltip+ label={t`Navigate to Attendee`}+ position="bottom"+ withArrow+ >+ <NavLink to={`../attendees?query=${attendeeInfo.attendee_public_id}`}>+ <ActionIcon+ variant="subtle"+ radius="xl"+ size="xs"+ >+ <IconExternalLink size={14}/>+ </ActionIcon>+ </NavLink>+ </Tooltip>+ )}+ </div>++ {/* Questions for this attendee */}+ <div className={classes.attendeeQuestions}>+ {questions.map((qa, index) => (+ <QuestionItem+ key={`${qa.question_id}-${index}`}+ qa={qa}+ isEditing={isEditing(qa.question_id)}+ toggleEditMode={toggleEditMode}+ onEditAnswer={onEditAnswer}+ compact={compact}+ eventId={eventId}+ hideAttendeeInfo={true} // Hide attendee info since we're showing it in the header+ />+ ))}+ </div>+ </div>+ );+ })}+ </div>+ );+};++export const QuestionAndAnswerList = ({questionAnswers, belongsToFilter, onEditAnswer}: QuestionAndAnswerListProps) => {const filteredQuestions = belongsToFilter?.length? questionAnswers.filter(qa => belongsToFilter.includes(qa.belongs_to)): questionAnswers;@@ -19,7 +334,7 @@ export const QuestionAndAnswerList = ({questionAnswers, belongsToFilter}: Questiconst attendeeQuestions = filteredQuestions.filter(qa => qa.belongs_to === 'PRODUCT' && qa.attendee_id);const orderQuestions = filteredQuestions.filter(qa => qa.belongs_to === 'ORDER');- const renderSection = (title: string, questions: QuestionAnswer[]) => {+ const renderSection = (title: string, questions: QuestionAnswer[], isAttendeeSection = false) => {const getIcon = () => {switch (title) {case 'Attendee Answers':@@ -33,6 +348,10 @@ export const QuestionAndAnswerList = ({questionAnswers, belongsToFilter}: Questi}};+ if (questions.length === 0) {+ return null;+ }+return (<div className={classes.section}><Group justify="space-between" className={classes.sectionHeader}>@@ -45,65 +364,16 @@ export const QuestionAndAnswerList = ({questionAnswers, belongsToFilter}: Questi</Text></Group>- {questions.length > 0 ? (- <div className={classes.questionsList}>- {questions.map((qa, index) => (- <div key={index} className={classes.questionCard}>- {qa.product_title && (- <Text size="sm" className={classes.productTitle}>- {qa.product_title}- </Text>- )}-- <div className={classes.questionTitle}>- <IconMessageCircle2- size={16}- stroke={1.5}- style={{marginTop: 3}}- />- <Text size="sm" fw={500}>- {qa.title}- </Text>- </div>-- <Text size="sm" className={classes.answer}>- {Array.isArray(qa.answer) ? qa.answer.join(", ") : qa.answer}- </Text>-- {qa.attendee_id && (- <div className={classes.attendeeInfo}>- <IconUser size={14} stroke={1.5}/>- <Text size="sm" span>- {qa.first_name- ? `${qa.first_name} ${qa.last_name}`- : t`N/A`}- </Text>- <Tooltip- label={t`Navigate to Attendee`}- position="bottom"- withArrow- >- <NavLink to={`../attendees?query=${qa.first_name + ' ' + qa.last_name}`}>- <ActionIcon- variant="subtle"- radius="xl"- size="xs"- >- <IconExternalLink size={12}/>- </ActionIcon>- </NavLink>- </Tooltip>- </div>- )}- </div>- ))}- </div>+ {isAttendeeSection ? (+ <AttendeeQuestionsList+ attendeeQuestions={questions}+ onEditAnswer={onEditAnswer}+ />) : (- <div className={classes.emptyState}>- <Text size="sm" c="dimmed">- {t`No ${title.toLowerCase()} available.`}- </Text>- </div>+ <QuestionList+ questions={questions}+ onEditAnswer={onEditAnswer}+ />)}</div>);@@ -111,9 +381,9 @@ export const QuestionAndAnswerList = ({questionAnswers, belongsToFilter}: Questireturn (<div className={classes.container}>- {orderQuestions.length > 0 && renderSection('Order Answers', orderQuestions)}- {attendeeQuestions.length > 0 && renderSection('Attendee Answers', attendeeQuestions)}- {productQuestions.length > 0 && renderSection('Product Answers', productQuestions)}+ {renderSection('Order Answers', orderQuestions)}+ {renderSection('Attendee Answers', attendeeQuestions, true)}+ {renderSection('Product Answers', productQuestions)}</div>);};diff --git a/frontend/src/components/layouts/EventHomepage/EventHomepage.module.scss b/frontend/src/components/layouts/EventHomepage/EventHomepage.module.scssindex d41eb9738..73d5d28a9 100644--- a/frontend/src/components/layouts/EventHomepage/EventHomepage.module.scss+++ b/frontend/src/components/layouts/EventHomepage/EventHomepage.module.scss@@ -64,6 +64,7 @@@include respond-below(md) {min-height: 100vh;justify-content: space-between;+ padding: 20px;}a {diff --git a/frontend/src/components/layouts/EventHomepage/EventInformation/EventInformation.module.scss b/frontend/src/components/layouts/EventHomepage/EventInformation/EventInformation.module.scssindex eb3e1519c..6b6ea5ab8 100644--- a/frontend/src/components/layouts/EventHomepage/EventInformation/EventInformation.module.scss+++ b/frontend/src/components/layouts/EventHomepage/EventInformation/EventInformation.module.scss@@ -43,6 +43,7 @@place-self: flex-start;margin-right: 10px;color: var(--homepage-secondary-color, var(--tk-primary));+ min-width: 20px;}}diff --git a/frontend/src/components/layouts/EventHomepage/EventInformation/index.tsx b/frontend/src/components/layouts/EventHomepage/EventInformation/index.tsxindex 0d635eb0c..ef21671e1 100644--- a/frontend/src/components/layouts/EventHomepage/EventInformation/index.tsx+++ b/frontend/src/components/layouts/EventHomepage/EventInformation/index.tsx@@ -1,6 +1,5 @@import {IconCalendar, IconExternalLink, IconMapPin} from "@tabler/icons-react";import classes from "./EventInformation.module.scss";-import {prettyDate} from "../../../../utilites/dates.ts";import {formatAddress} from "../../../../utilites/formatAddress.tsx";import {t} from "@lingui/macro";import {Button} from "@mantine/core";@@ -22,8 +21,8 @@ export const EventInformation: FC<{return (<><div className={classes.preHeading}>- <div className={classes.date}>- {prettyDate(event.start_date, event.timezone)}+ <div className={classes.organizer}>+ {event.organizer?.name}</div><div className={classes.shareButtons}><ShareComponent@@ -37,7 +36,6 @@ export const EventInformation: FC<{<h1 className={classes.eventTitle}>{event.title}</h1><div className={classes.eventInfo}><div className={classes.eventDetail}>- <h2>{t`Date & Time`}</h2><div className={classes.details}><IconCalendar size={20}/><div>@@ -48,9 +46,8 @@ export const EventInformation: FC<{{event.settings?.location_details && (<div className={classes.eventDetail}>- <h2>{t`Location`}</h2><div className={classes.details}>- <IconMapPin size={25}/>+ <IconMapPin size={20}/><div className={classes.detail}><b>{event.settings?.location_details?.venue_name}</b><div>{formatAddress(event.settings?.location_details)}</div>diff --git a/frontend/src/components/modals/ManageAttendeeModal/index.tsx b/frontend/src/components/modals/ManageAttendeeModal/index.tsxindex fa1aa0a32..6685cfd90 100644--- a/frontend/src/components/modals/ManageAttendeeModal/index.tsx+++ b/frontend/src/components/modals/ManageAttendeeModal/index.tsx@@ -12,7 +12,7 @@ import {IconEdit, IconNotebook, IconQuestionMark, IconReceipt, IconTicket, IconUimport {LoadingMask} from "../../common/LoadingMask";import {AttendeeDetails} from "../../common/AttendeeDetails";import {OrderDetails} from "../../common/OrderDetails";-import {QuestionAndAnswerList} from "../../common/QuestionAndAnswerList";+import {QuestionAndAnswerList, QuestionList} from "../../common/QuestionAndAnswerList";import {AttendeeTicket} from "../../common/AttendeeTicket";import {getInitials} from "../../../utilites/helpers.ts";import {t} from "@lingui/macro";@@ -34,7 +34,7 @@ interface ManageAttendeeModalProps extends GenericModalProps {export const ManageAttendeeModal = ({onClose, attendeeId}: ManageAttendeeModalProps) => {const {eventId} = useParams();- const {data: attendee} = useGetAttendee(eventId, attendeeId);+ const {data: attendee, refetch: refetchAttendee} = useGetAttendee(eventId, attendeeId);const {data: order} = useGetOrder(eventId, attendee?.order_id);const {data: event} = useGetEvent(eventId);const errorHandler = useFormErrorResponseHandler();@@ -184,7 +184,10 @@ export const ManageAttendeeModal = ({onClose, attendeeId}: ManageAttendeeModalPrtitle: t`Questions & Answers`,count: hasQuestions ? attendee?.question_answers?.length : undefined,content: hasQuestions ? (- <QuestionAndAnswerList questionAnswers={attendee.question_answers as QuestionAnswer[]}/>+ <QuestionList+ onEditAnswer={refetchAttendee}+ questions={attendee.question_answers as QuestionAnswer[]}+ />) : (<Text c="dimmed" ta="center" py="xl">{t`No questions answered by this attendee.`}diff --git a/frontend/src/components/modals/ManageOrderModal/index.tsx b/frontend/src/components/modals/ManageOrderModal/index.tsxindex c7131c5e9..0dc057351 100644--- a/frontend/src/components/modals/ManageOrderModal/index.tsx+++ b/frontend/src/components/modals/ManageOrderModal/index.tsx@@ -3,7 +3,6 @@ import {useParams} from "react-router";import {useGetEvent} from "../../../queries/useGetEvent.ts";import {useGetOrder} from "../../../queries/useGetOrder.ts";import {OrderSummary} from "../../common/OrderSummary";-import {Modal} from "../../common/Modal";import {AttendeeList} from "../../common/AttendeeList";import {OrderDetails} from "../../common/OrderDetails";import {t} from "@lingui/macro";@@ -30,7 +29,7 @@ interface ManageOrderModalProps {export const ManageOrderModal = ({onClose, orderId}: GenericModalProps & ManageOrderModalProps) => {const {eventId} = useParams();- const {data: order} = useGetOrder(eventId, orderId);+ const {data: order, refetch: refetchOrder} = useGetOrder(eventId, orderId);const {data: event, data: {product_categories: productCategories} = {}} = useGetEvent(eventId);const products = productCategories?.flatMap(category => category.products);const orderHasQuestions = order?.question_answers && order.question_answers.length > 0;@@ -112,7 +111,9 @@ export const ManageOrderModal = ({onClose, orderId}: GenericModalProps & ManageOtitle: t`Questions & Answers`,count: orderHasQuestions ? order.question_answers.length : undefined,content: orderHasQuestions ? (- <QuestionAndAnswerList questionAnswers={order.question_answers as QuestionAnswer[]}/>+ <QuestionAndAnswerList+ onEditAnswer={refetchOrder}+ questionAnswers={order.question_answers as QuestionAnswer[]}/>) : (<Text c="dimmed" ta="center" py="xl">{t`No questions have been asked for this order.`}@@ -125,7 +126,7 @@ export const ManageOrderModal = ({onClose, orderId}: GenericModalProps & ManageOtitle: t`Attendees`,count: orderHasAttendees ? order.attendees.length : undefined,content: orderHasAttendees ? (- <AttendeeList order={order} products={products as Product[]}/>+ <AttendeeList refetchOrder={refetchOrder} order={order} products={products as Product[]} questionAnswers={order.question_answers}/>) : (<Text c="dimmed" ta="center" py="xl">{t`No attendees have been added to this order.`}diff --git a/frontend/src/components/routes/product-widget/CollectInformation/index.tsx b/frontend/src/components/routes/product-widget/CollectInformation/index.tsxindex 1ae14f544..9d85bcaf1 100644--- a/frontend/src/components/routes/product-widget/CollectInformation/index.tsx+++ b/frontend/src/components/routes/product-widget/CollectInformation/index.tsx@@ -8,7 +8,7 @@ import {useGetOrderPublic} from "../../../../queries/useGetOrderPublic.ts";import {useGetEventPublic} from "../../../../queries/useGetEventPublic.ts";import {useGetEventQuestionsPublic} from "../../../../queries/useGetEventQuestionsPublic.ts";import {CheckoutOrderQuestions, CheckoutProductQuestions} from "../../../common/CheckoutQuestion";-import {Event, Order, Question} from "../../../../types.ts";+import {Event, IdParam, Order, Question} from "../../../../types.ts";import {useEffect} from "react";import {t} from "@lingui/macro";import {InputGroup} from "../../../common/InputGroup";@@ -80,20 +80,33 @@ export const CollectInformation = () => {});const copyDetailsToAllAttendees = () => {- const updatedProducts = form.values.products.map((product) => {- return {- ...product,- first_name: form.values.order.first_name,- last_name: form.values.order.last_name,- email: form.values.order.email,- };+ if (!products) {+ return;+ }++ const attendeeProductIds = new Set<IdParam>(+ products+ .filter(product => product && product.product_type === 'TICKET')+ .map(product => product.id)+ );++ const updatedProducts = form.values.products.map(product => {+ if (attendeeProductIds.has(product.product_id)) {+ return {+ ...product,+ first_name: form.values.order.first_name,+ last_name: form.values.order.last_name,+ email: form.values.order.email,+ };+ }+ return product;});form.setValues({...form.values,products: updatedProducts,});- }+ };const mutation = useMutation({mutationFn: (orderData: FinaliseOrderPayload) => orderClientPublic.finaliseOrder(Number(eventId), String(orderShortId), orderData),diff --git a/frontend/src/components/routes/product-widget/SelectProducts/index.tsx b/frontend/src/components/routes/product-widget/SelectProducts/index.tsxindex c57d39a8b..c22a2c60c 100644--- a/frontend/src/components/routes/product-widget/SelectProducts/index.tsx+++ b/frontend/src/components/routes/product-widget/SelectProducts/index.tsx@@ -451,24 +451,34 @@ const SelectProducts = (props: SelectProductsProps) => {</ActionIcon></div>)}++ {(showPromoCodeInput && !form.values.promo_code) && (+ <Group className={'hi-promo-code-input-wrapper'} wrap={'nowrap'} gap={'20px'}>+ {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}+ {/*@ts-ignore*/}+ <TextInput autoFocus classNames={{input: 'hi-promo-code-input'}} onKeyDown={(event) => {+ if (event.key === 'Enter') {+ event.preventDefault();+ handleApplyPromoCode();+ }+ }} mb={0} ref={promoRef}/>+ <Button disabled={promoCodeEventRefetchMutation.isPending}+ className={'hi-apply-promo-code-button'} variant={'outline'}+ onClick={handleApplyPromoCode}>+ {t`Apply Promo Code`}+ </Button>+ <ActionIcon+ className={'hi-close-promo-code-input-button'}+ variant="transparent"+ aria-label={t`close`}+ title={t`Close`}+ onClick={() => setShowPromoCodeInput(false)}+ >+ <IconX stroke={1.5} size={20}/>+ </ActionIcon>+ </Group>+ )}</div>- {(showPromoCodeInput && !form.values.promo_code) && (- <Group className={'hi-promo-code-input-wrapper'} wrap={'nowrap'} gap={'20px'}>- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}- {/*@ts-ignore*/}- <TextInput autoFocus classNames={{input: 'hi-promo-code-input'}} onKeyDown={(event) => {- if (event.key === 'Enter') {- event.preventDefault();- handleApplyPromoCode();- }- }} mb={0} ref={promoRef}/>- <Button disabled={promoCodeEventRefetchMutation.isPending}- className={'hi-apply-promo-code-button'} variant={'outline'}- onClick={handleApplyPromoCode}>- {t`Apply Promo Code`}- </Button>- </Group>- )}{/*** (c) Hi.Events Ltd 2025diff --git a/frontend/src/mutations/useEditQuestionAnswer.ts b/frontend/src/mutations/useEditQuestionAnswer.tsnew file mode 100644index 000000000..3ac331ed4--- /dev/null+++ b/frontend/src/mutations/useEditQuestionAnswer.ts@@ -0,0 +1,17 @@+import {useMutation} from "@tanstack/react-query";+import {IdParam} from '../types';+import {questionClient} from "../api/question.client.ts";++export const useEditQuestionAnswer = () => {+ return useMutation({+ mutationFn: ({eventId, questionId, answerId, answer}: {+ eventId: IdParam,+ questionId: IdParam,+ answerId: IdParam,+ answer: string | string[]+ }) => questionClient.updateAnswerQuestion(eventId, questionId, answerId, answer),+ onSuccess: (_, variables) => {+ return;+ }+ });+}diff --git a/frontend/src/styles/widget/default.scss b/frontend/src/styles/widget/default.scssindex 14ff30ddf..bf8d1c129 100644--- a/frontend/src/styles/widget/default.scss+++ b/frontend/src/styles/widget/default.scss@@ -177,6 +177,12 @@border: none;}+ .hi-close-promo-code-input-button {+ background-color: var(--widget-secondary-color, var(--tk-primary));+ color: var(--widget-secondary-text-color, var(--tk-color-white));+ border: none;+ }+.hi-promo-code-applied {display: flex;align-items: center;diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 83582e8a3..f6633234a 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -713,8 +713,13 @@ export interface QuestionAnswer {belongs_to: string;question_type: string;attendee_id?: number;+ attendee_public_id?: IdParam;first_name?: string;last_name?: string;+ question_answer_id?: IdParam;+ question_description?: string;+ question_required?: boolean;+ question_options?: string[];}export enum ReportTypes {diff --git a/frontend/src/utilites/formatAddress.tsx b/frontend/src/utilites/formatAddress.tsxindex 48ea354cc..12527c068 100644--- a/frontend/src/utilites/formatAddress.tsx+++ b/frontend/src/utilites/formatAddress.tsx@@ -11,4 +11,5 @@ export const formatAddress = (address: VenueAddress) => {];return addressLines.filter((line) => line).join(', ');-}\ No newline at end of file+}+diff --git a/frontend/src/utilites/questionHelper.ts b/frontend/src/utilites/questionHelper.tsnew file mode 100644index 000000000..cce02492b--- /dev/null+++ b/frontend/src/utilites/questionHelper.ts@@ -0,0 +1,32 @@+import {formatAddress} from "./formatAddress.tsx";++export const isAddress = (obj: any) => {+ if (!obj || typeof obj !== 'object') return false;++ const addressFields = [+ 'address_line_1',+ 'address_line_2',+ 'city',+ 'state_or_region',+ 'zip_or_postal_code',+ 'country'+ ];++ return addressFields.some(field => field in obj);+};++export const formatAnswer = (answer: any) => {+ if (answer === null || answer === undefined) return '';++ if (Array.isArray(answer)) {+ return answer.join(", ");+ } else if (typeof answer === 'object') {+ if (isAddress(answer)) {+ return formatAddress(answer);+ } else {+ return JSON.stringify(answer);+ }+ } else {+ return answer.toString();+ }+};