Skip to content

Commit 3c09cc2

Browse files
authored
Merge pull request #331 from HiEventsDev/fix/attendee-check-in-status
Fixes incorrect attendee check-in status display
2 parents 12efd7d + 35c3374 commit 3c09cc2

File tree

9 files changed

+101
-25
lines changed

9 files changed

+101
-25
lines changed

backend/app/Exports/AttendeesExport.php

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

55
use Carbon\Carbon;
6+
use HiEvents\DomainObjects\AttendeeDomainObject;
67
use HiEvents\DomainObjects\Enums\QuestionTypeEnum;
8+
use HiEvents\DomainObjects\Enums\TicketType;
79
use HiEvents\DomainObjects\QuestionDomainObject;
10+
use HiEvents\DomainObjects\TicketDomainObject;
11+
use HiEvents\DomainObjects\TicketPriceDomainObject;
812
use HiEvents\Resources\Attendee\AttendeeResource;
913
use HiEvents\Services\Domain\Question\QuestionAnswerFormatter;
1014
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
@@ -50,6 +54,7 @@ public function headings(): array
5054
'Is Checked In',
5155
'Checked In At',
5256
'Ticket ID',
57+
'Ticket Name',
5358
'Event ID',
5459
'Public ID',
5560
'Short ID',
@@ -58,6 +63,10 @@ public function headings(): array
5863
], $questionTitles);
5964
}
6065

66+
/**
67+
* @param AttendeeDomainObject $attendee
68+
* @return array
69+
*/
6170
public function map($attendee): array
6271
{
6372
$answers = $this->questions->map(function (QuestionDomainObject $question) use ($attendee) {
@@ -70,17 +79,28 @@ public function map($attendee): array
7079
);
7180
});
7281

82+
/** @var TicketDomainObject $ticket */
83+
$ticket = $attendee->getTicket();
84+
$ticketName = $ticket->getTitle();
85+
if ($attendee->getTicket()?->getType() === TicketType::TIERED->name) {
86+
$ticketName .= ' - ' . $ticket
87+
->getTicketPrices()
88+
->first(fn(TicketPriceDomainObject $tp) => $tp->getId() === $attendee->getTicketPriceId())
89+
->getLabel();
90+
}
91+
7392
return array_merge([
7493
$attendee->getId(),
7594
$attendee->getFirstName(),
7695
$attendee->getLastName(),
7796
$attendee->getEmail(),
7897
$attendee->getStatus(),
79-
$attendee->getCheckedInAt() ? 'Yes' : 'No',
80-
$attendee->getCheckedInAt()
81-
? Carbon::parse($attendee->getCheckedInAt())->format('Y-m-d H:i:s')
98+
$attendee->getCheckIn() ? 'Yes' : 'No',
99+
$attendee->getCheckIn()
100+
? Carbon::parse($attendee->getCheckIn()->getCreatedAt())->format('Y-m-d H:i:s')
82101
: '',
83102
$attendee->getTicketId(),
103+
$ticketName,
84104
$attendee->getEventId(),
85105
$attendee->getPublicId(),
86106
$attendee->getShortId(),

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
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;
9+
use HiEvents\DomainObjects\TicketDomainObject;
10+
use HiEvents\DomainObjects\TicketPriceDomainObject;
811
use HiEvents\Exports\AttendeesExport;
912
use HiEvents\Http\Actions\BaseAction;
13+
use HiEvents\Repository\Eloquent\Value\Relationship;
1014
use HiEvents\Repository\Interfaces\AttendeeRepositoryInterface;
1115
use HiEvents\Repository\Interfaces\QuestionRepositoryInterface;
1216
use Maatwebsite\Excel\Facades\Excel;
@@ -31,6 +35,19 @@ public function __invoke(int $eventId): BinaryFileResponse
3135

3236
$attendees = $this->attendeeRepository
3337
->loadRelation(QuestionAndAnswerViewDomainObject::class)
38+
->loadRelation(new Relationship(
39+
domainObject: AttendeeCheckInDomainObject::class,
40+
name: 'check_in',
41+
))
42+
->loadRelation(new Relationship(
43+
domainObject: TicketDomainObject::class,
44+
nested: [
45+
new Relationship(
46+
domainObject: TicketPriceDomainObject::class,
47+
),
48+
],
49+
name: 'ticket'
50+
))
3451
->findByEventIdForExport($eventId);
3552

3653
$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/Repository/Eloquent/CheckInListRepository.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function getCheckedInAttendeeCountById(int $checkInListId): CheckedInAtte
4141
JOIN ticket_check_in_lists tcil ON a.ticket_id = tcil.ticket_id
4242
WHERE a.deleted_at IS NULL
4343
AND tcil.deleted_at IS NULL
44+
AND a.status = 'ACTIVE'
4445
)
4546
SELECT
4647
cil.id AS check_in_list_id,

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)