Skip to content

Commit 691a1f8

Browse files
authored
Fix server error when checking in multiple offline payment attendees (#442)
1 parent f4ba792 commit 691a1f8

File tree

9 files changed

+65
-21
lines changed

9 files changed

+65
-21
lines changed

backend/app/DomainObjects/Generated/AttendeeCheckInDomainObjectAbstract.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ abstract class AttendeeCheckInDomainObjectAbstract extends \HiEvents\DomainObjec
1515
final public const PRODUCT_ID = 'product_id';
1616
final public const ATTENDEE_ID = 'attendee_id';
1717
final public const EVENT_ID = 'event_id';
18+
final public const ORDER_ID = 'order_id';
1819
final public const SHORT_ID = 'short_id';
1920
final public const IP_ADDRESS = 'ip_address';
2021
final public const DELETED_AT = 'deleted_at';
@@ -26,6 +27,7 @@ abstract class AttendeeCheckInDomainObjectAbstract extends \HiEvents\DomainObjec
2627
protected int $product_id;
2728
protected int $attendee_id;
2829
protected int $event_id;
30+
protected ?int $order_id = null;
2931
protected string $short_id;
3032
protected string $ip_address;
3133
protected ?string $deleted_at = null;
@@ -40,6 +42,7 @@ public function toArray(): array
4042
'product_id' => $this->product_id ?? null,
4143
'attendee_id' => $this->attendee_id ?? null,
4244
'event_id' => $this->event_id ?? null,
45+
'order_id' => $this->order_id ?? null,
4346
'short_id' => $this->short_id ?? null,
4447
'ip_address' => $this->ip_address ?? null,
4548
'deleted_at' => $this->deleted_at ?? null,
@@ -103,6 +106,17 @@ public function getEventId(): int
103106
return $this->event_id;
104107
}
105108

109+
public function setOrderId(?int $order_id): self
110+
{
111+
$this->order_id = $order_id;
112+
return $this;
113+
}
114+
115+
public function getOrderId(): ?int
116+
{
117+
return $this->order_id;
118+
}
119+
106120
public function setShortId(string $short_id): self
107121
{
108122
$this->short_id = $short_id;

backend/app/DomainObjects/Generated/PersonalAccessTokenDomainObjectAbstract.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ abstract class PersonalAccessTokenDomainObjectAbstract extends \HiEvents\DomainO
1111
final public const SINGULAR_NAME = 'personal_access_token';
1212
final public const PLURAL_NAME = 'personal_access_tokens';
1313
final public const ID = 'id';
14-
final public const ACCOUNT_ID = 'account_id';
1514
final public const TOKENABLE_TYPE = 'tokenable_type';
1615
final public const TOKENABLE_ID = 'tokenable_id';
1716
final public const NAME = 'name';
@@ -23,7 +22,6 @@ abstract class PersonalAccessTokenDomainObjectAbstract extends \HiEvents\DomainO
2322
final public const UPDATED_AT = 'updated_at';
2423

2524
protected int $id;
26-
protected int $account_id;
2725
protected string $tokenable_type;
2826
protected int $tokenable_id;
2927
protected string $name;
@@ -38,7 +36,6 @@ public function toArray(): array
3836
{
3937
return [
4038
'id' => $this->id ?? null,
41-
'account_id' => $this->account_id ?? null,
4239
'tokenable_type' => $this->tokenable_type ?? null,
4340
'tokenable_id' => $this->tokenable_id ?? null,
4441
'name' => $this->name ?? null,
@@ -62,17 +59,6 @@ public function getId(): int
6259
return $this->id;
6360
}
6461

65-
public function setAccountId(int $account_id): self
66-
{
67-
$this->account_id = $account_id;
68-
return $this;
69-
}
70-
71-
public function getAccountId(): int
72-
{
73-
return $this->account_id;
74-
}
75-
7662
public function setTokenableType(string $tokenable_type): self
7763
{
7864
$this->tokenable_type = $tokenable_type;

backend/app/Resources/Attendee/AttendeeWithCheckInPublicResource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function toArray(Request $request): array
2424
'product_price_id' => $this->getProductPriceId(),
2525
'status' => $this->getStatus(),
2626
'locale' => $this->getLocale(),
27+
'order_id' => $this->getOrderId(),
2728
$this->mergeWhen($this->getCheckIn() !== null, [
2829
'check_in' => new AttendeeCheckInPublicResource($this->getCheckIn()),
2930
]),

backend/app/Resources/CheckInList/AttendeeCheckInPublicResource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function toArray($request): array
1818
'check_in_list_id' => $this->getCheckInListId(),
1919
'attendee_id' => $this->getAttendeeId(),
2020
'checked_in_at' => $this->getCreatedAt(),
21+
'order_id' => $this->getOrderId(),
2122
];
2223
}
2324
}

backend/app/Services/Domain/CheckInList/CreateAttendeeCheckInService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Exception;
66
use HiEvents\DataTransferObjects\ErrorBagDTO;
7+
use HiEvents\DomainObjects\AttendeeCheckInDomainObject;
78
use HiEvents\DomainObjects\AttendeeDomainObject;
89
use HiEvents\DomainObjects\CheckInListDomainObject;
910
use HiEvents\DomainObjects\Enums\AttendeeCheckInActionType;
@@ -250,9 +251,10 @@ private function createCheckIn(
250251
AttendeeDomainObject $attendee,
251252
CheckInListDomainObject $checkInList,
252253
string $checkInUserIpAddress
253-
): object
254+
): AttendeeCheckInDomainObject
254255
{
255256
return $this->attendeeCheckInRepository->create([
257+
AttendeeCheckInDomainObjectAbstract::ORDER_ID => $attendee->getOrderId(),
256258
AttendeeCheckInDomainObjectAbstract::ATTENDEE_ID => $attendee->getId(),
257259
AttendeeCheckInDomainObjectAbstract::CHECK_IN_LIST_ID => $checkInList->getId(),
258260
AttendeeCheckInDomainObjectAbstract::IP_ADDRESS => $checkInUserIpAddress,

backend/app/Services/Infrastructure/DomainObjectGenerator/ClassGenerator.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ class ClassGenerator
4040
private array $defaultIgnoreProperties = [];
4141

4242
private array $ignoredTables = [
43-
'migrations'
43+
'migrations',
44+
'job_batches',
45+
'failed_jobs',
4446
];
4547

4648
private AbstractSchemaManager $schemaManager;
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration {
8+
public function up(): void
9+
{
10+
Schema::table('attendee_check_ins', function (Blueprint $table) {
11+
$table->foreignId('order_id')->nullable()->constrained('orders');
12+
});
13+
}
14+
15+
public function down(): void
16+
{
17+
Schema::table('attendee_check_ins', function (Blueprint $table) {
18+
$table->dropColumn('order_id');
19+
});
20+
}
21+
};

frontend/src/mutations/useCreateCheckInPublic.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,38 @@ export const useCreateCheckInPublic = (pagination: QueryFilters) => {
2020
queryClient.setQueryData(
2121
[GET_CHECK_IN_LIST_ATTENDEES_PUBLIC_QUERY_KEY, checkInListShortId, pagination],
2222
(oldData: any) => {
23+
if (!oldData?.data) return oldData;
24+
25+
const updatedAttendee = data?.data?.find((checkIn: any) => checkIn.attendee_id);
26+
27+
if (!updatedAttendee) return oldData;
28+
29+
const updatedOrderId = updatedAttendee.order_id;
30+
2331
const newAttendees = oldData.data.map((attendee: any) => {
2432
const attendeeCheckIn = data?.data?.find(
2533
(checkIn: any) => checkIn.attendee_id === attendee.id
2634
);
2735

28-
if (attendeeCheckIn) {
29-
const hasError = data.errors && Object.keys(data.errors).some(
30-
(key) => key === attendee.public_id
31-
);
36+
const hasError = data.errors && Object.keys(data.errors).some(
37+
(key) => key === attendee.public_id
38+
);
3239

40+
if (attendeeCheckIn) {
3341
return {
3442
...attendee,
3543
check_in: attendeeCheckIn,
3644
status: markedAsPaid && !hasError ? 'ACTIVE' : attendee.status,
3745
};
3846
}
47+
48+
// Mark all attendees with the same order_id as ACTIVE if markedAsPaid
49+
if (markedAsPaid && attendee.order_id === updatedOrderId) {
50+
return {
51+
...attendee,
52+
status: 'ACTIVE',
53+
};
54+
}
3955
return attendee;
4056
});
4157

frontend/src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ export interface Attendee {
407407
check_in?: AttendeeCheckIn;
408408
}
409409

410-
export type PublicCheckIn = Pick<AttendeeCheckIn, 'id' | 'attendee_id' | 'check_in_list_id' | 'product_id' | 'event_id'>;
410+
export type PublicCheckIn = Pick<AttendeeCheckIn, 'id' | 'order_id' | 'attendee_id' | 'check_in_list_id' | 'product_id' | 'event_id'>;
411411

412412
export interface AttendeeCheckIn {
413413
id: IdParam;
@@ -416,6 +416,7 @@ export interface AttendeeCheckIn {
416416
product_id: IdParam;
417417
event_id: IdParam;
418418
short_id: IdParam;
419+
order_id: IdParam;
419420
created_at: string;
420421
}
421422

0 commit comments

Comments
 (0)