Skip to content

Commit d07a85d

Browse files
committed
Fixes incorrect attendee check-in status display
1 parent 12efd7d commit d07a85d

File tree

8 files changed

+74
-25
lines changed

8 files changed

+74
-25
lines changed

backend/app/Exports/AttendeesExport.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace HiEvents\Exports;
44

55
use Carbon\Carbon;
6+
use HiEvents\DomainObjects\AttendeeDomainObject;
67
use HiEvents\DomainObjects\Enums\QuestionTypeEnum;
78
use HiEvents\DomainObjects\QuestionDomainObject;
89
use HiEvents\Resources\Attendee\AttendeeResource;
@@ -58,6 +59,10 @@ public function headings(): array
5859
], $questionTitles);
5960
}
6061

62+
/**
63+
* @param AttendeeDomainObject $attendee
64+
* @return array
65+
*/
6166
public function map($attendee): array
6267
{
6368
$answers = $this->questions->map(function (QuestionDomainObject $question) use ($attendee) {
@@ -76,9 +81,9 @@ public function map($attendee): array
7681
$attendee->getLastName(),
7782
$attendee->getEmail(),
7883
$attendee->getStatus(),
79-
$attendee->getCheckedInAt() ? 'Yes' : 'No',
80-
$attendee->getCheckedInAt()
81-
? Carbon::parse($attendee->getCheckedInAt())->format('Y-m-d H:i:s')
84+
$attendee->getCheckIn() ? 'Yes' : 'No',
85+
$attendee->getCheckIn()
86+
? Carbon::parse($attendee->getCheckIn()->getCreatedAt())->format('Y-m-d H:i:s')
8287
: '',
8388
$attendee->getTicketId(),
8489
$attendee->getEventId(),

backend/app/Http/Actions/Attendees/ExportAttendeesAction.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
namespace HiEvents\Http\Actions\Attendees;
44

5+
use HiEvents\DomainObjects\AttendeeCheckInDomainObject;
56
use HiEvents\DomainObjects\Enums\QuestionBelongsTo;
67
use HiEvents\DomainObjects\EventDomainObject;
78
use HiEvents\DomainObjects\QuestionAndAnswerViewDomainObject;
89
use HiEvents\Exports\AttendeesExport;
910
use HiEvents\Http\Actions\BaseAction;
11+
use HiEvents\Repository\Eloquent\Value\Relationship;
1012
use HiEvents\Repository\Interfaces\AttendeeRepositoryInterface;
1113
use HiEvents\Repository\Interfaces\QuestionRepositoryInterface;
1214
use Maatwebsite\Excel\Facades\Excel;
@@ -31,6 +33,10 @@ public function __invoke(int $eventId): BinaryFileResponse
3133

3234
$attendees = $this->attendeeRepository
3335
->loadRelation(QuestionAndAnswerViewDomainObject::class)
36+
->loadRelation(new Relationship(
37+
domainObject: AttendeeCheckInDomainObject::class,
38+
name: 'check_in',
39+
))
3440
->findByEventIdForExport($eventId);
3541

3642
$questions = $this->questionRepository->findWhere([

backend/app/Http/Actions/Attendees/GetAttendeeAction.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace HiEvents\Http\Actions\Attendees;
44

5+
use HiEvents\DomainObjects\AttendeeCheckInDomainObject;
56
use HiEvents\DomainObjects\EventDomainObject;
67
use HiEvents\DomainObjects\QuestionAndAnswerViewDomainObject;
78
use HiEvents\DomainObjects\TicketDomainObject;
@@ -27,14 +28,18 @@ public function __invoke(int $eventId, int $attendeeId): Response|JsonResponse
2728
$this->isActionAuthorized($eventId, EventDomainObject::class);
2829

2930
$attendee = $this->attendeeRepository
30-
->loadRelation(QuestionAndAnswerViewDomainObject::class)
31+
->loadRelation(relationship: QuestionAndAnswerViewDomainObject::class)
3132
->loadRelation(new Relationship(
3233
domainObject: TicketDomainObject::class,
3334
nested: [
3435
new Relationship(
3536
domainObject: TicketPriceDomainObject::class,
3637
),
3738
], name: 'ticket'))
39+
->loadRelation(new Relationship(
40+
domainObject: AttendeeCheckInDomainObject::class,
41+
name: 'check_in',
42+
))
3843
->findFirstWhere([
3944
'id' => $attendeeId,
4045
'event_id' => $eventId,

backend/app/Resources/Attendee/AttendeeResource.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use HiEvents\DomainObjects\AttendeeDomainObject;
66
use HiEvents\DomainObjects\Enums\QuestionBelongsTo;
7+
use HiEvents\Resources\CheckInList\AttendeeCheckInResource;
78
use HiEvents\Resources\Order\OrderResource;
89
use HiEvents\Resources\Question\QuestionAnswerViewResource;
910
use HiEvents\Resources\Ticket\TicketResource;
@@ -30,17 +31,21 @@ public function toArray(Request $request): array
3031
'public_id' => $this->getPublicId(),
3132
'short_id' => $this->getShortId(),
3233
'locale' => $this->getLocale(),
34+
'check_in' => $this->when(
35+
condition: $this->getCheckIn() !== null,
36+
value: fn() => new AttendeeCheckInResource($this->getCheckIn()),
37+
),
3338
'ticket' => $this->when(
34-
!is_null($this->getTicket()),
35-
fn() => new TicketResource($this->getTicket()),
39+
condition: !is_null($this->getTicket()),
40+
value: fn() => new TicketResource($this->getTicket()),
3641
),
3742
'order' => $this->when(
38-
!is_null($this->getOrder()),
39-
fn() => new OrderResource($this->getOrder())
43+
condition: !is_null($this->getOrder()),
44+
value: fn() => new OrderResource($this->getOrder())
4045
),
4146
'question_answers' => $this->when(
42-
$this->getQuestionAndAnswerViews() !== null,
43-
fn() => QuestionAnswerViewResource::collection(
47+
condition: $this->getQuestionAndAnswerViews() !== null,
48+
value: fn() => QuestionAnswerViewResource::collection(
4449
$this->getQuestionAndAnswerViews()
4550
?->filter(fn($qav) => $qav->getBelongsTo() === QuestionBelongsTo::TICKET->name)
4651
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace HiEvents\Resources\CheckInList;
4+
5+
use HiEvents\DomainObjects\AttendeeCheckInDomainObject;
6+
use Illuminate\Http\Resources\Json\JsonResource;
7+
8+
/**
9+
* @mixin AttendeeCheckInDomainObject
10+
*/
11+
class AttendeeCheckInResource extends JsonResource
12+
{
13+
public function toArray($request): array
14+
{
15+
return [
16+
'id' => $this->getId(),
17+
'attendee_id' => $this->getAttendeeId(),
18+
'check_in_list_id' => $this->getCheckInListId(),
19+
'ticket_id' => $this->getTicketId(),
20+
'event_id' => $this->getEventId(),
21+
'short_id' => $this->getShortId(),
22+
'created_at' => $this->getCreatedAt(),
23+
];
24+
}
25+
}

frontend/src/api/check-in.client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import {publicApi} from "./public-client";
22
import {
33
Attendee,
4-
CheckIn,
54
CheckInList,
65
GenericDataResponse,
76
GenericPaginatedResponse,
8-
IdParam,
7+
IdParam, PublicCheckIn,
98
QueryFilters,
109
} from "../types";
1110
import {queryParamsHelper} from "../utilites/queryParamsHelper";
@@ -20,13 +19,13 @@ export const publicCheckInClient = {
2019
return response.data;
2120
},
2221
createCheckIn: async (checkInListShortId: IdParam, attendeePublicId: IdParam) => {
23-
const response = await publicApi.post<GenericDataResponse<CheckIn[]>>(`/check-in-lists/${checkInListShortId}/check-ins`, {
22+
const response = await publicApi.post<GenericDataResponse<PublicCheckIn[]>>(`/check-in-lists/${checkInListShortId}/check-ins`, {
2423
"attendee_public_ids": [attendeePublicId],
2524
});
2625
return response.data;
2726
},
2827
deleteCheckIn: async (checkInListShortId: IdParam, checkInShortId: IdParam) => {
29-
const response = await publicApi.delete<GenericDataResponse<CheckIn>>(`/check-in-lists/${checkInListShortId}/check-ins/${checkInShortId}`);
28+
const response = await publicApi.delete<GenericDataResponse<PublicCheckIn>>(`/check-in-lists/${checkInListShortId}/check-ins/${checkInShortId}`);
3029
return response.data;
3130
},
3231
};

frontend/src/components/common/AttendeeDetails/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const AttendeeDetails = ({attendee}: { attendee: Attendee }) => {
3838
{t`Checked In`}
3939
</div>
4040
<div className={classes.amount}>
41-
{attendee.checked_in_at ? t`Yes` : t`No`}
41+
{attendee.check_in ? t`Yes` : t`No`}
4242
</div>
4343
</div>
4444
<div className={classes.block}>
@@ -59,4 +59,4 @@ export const AttendeeDetails = ({attendee}: { attendee: Attendee }) => {
5959
</div>
6060
</Card>
6161
);
62-
}
62+
}

frontend/src/types.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,19 @@ export interface Attendee {
345345
checked_in_by?: number;
346346
question_answers?: QuestionAnswer[];
347347
locale?: SupportedLocales;
348-
check_in?: CheckIn;
348+
check_in?: AttendeeCheckIn;
349+
}
350+
351+
export type PublicCheckIn = Pick<AttendeeCheckIn, 'id' | 'attendee_id' | 'check_in_list_id' | 'ticket_id' | 'event_id'>;
352+
353+
export interface AttendeeCheckIn {
354+
id: IdParam;
355+
attendee_id: IdParam;
356+
check_in_list_id: IdParam;
357+
ticket_id: IdParam;
358+
event_id: IdParam;
359+
short_id: IdParam;
360+
created_at: string;
349361
}
350362

351363
export interface Address {
@@ -475,14 +487,6 @@ export type CheckInListRequest =
475487
ticket_ids: IdParam[];
476488
};
477489

478-
export interface CheckIn {
479-
id: number;
480-
short_id: string;
481-
check_in_list_id: number;
482-
attendee_id: number;
483-
checked_in_at: string;
484-
}
485-
486490
export interface QuestionRequestData {
487491
title: string;
488492
description?: string;

0 commit comments

Comments
 (0)