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
Delete & update functionality
Dave Earleya6200629a655
diff --git a/backend/app/Http/Actions/CapacityAssignments/CreateCapacityAssignmentAction.php b/backend/app/Http/Actions/CapacityAssignments/CreateCapacityAssignmentAction.phpindex 5da2daf1a..f6229d20f 100644--- a/backend/app/Http/Actions/CapacityAssignments/CreateCapacityAssignmentAction.php+++ b/backend/app/Http/Actions/CapacityAssignments/CreateCapacityAssignmentAction.php@@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Response;class CreateCapacityAssignmentAction extends BaseAction{public function __construct(- private readonly CreateCapacityAssignmentHandler $createCapacityAssignmentHandler+ private readonly CreateCapacityAssignmentHandler $createCapacityAssignmentHandler,){}diff --git a/backend/app/Http/Actions/CapacityAssignments/DeleteCapacityAssignmentAction.php b/backend/app/Http/Actions/CapacityAssignments/DeleteCapacityAssignmentAction.phpindex e1062a600..0a11c156a 100644--- a/backend/app/Http/Actions/CapacityAssignments/DeleteCapacityAssignmentAction.php+++ b/backend/app/Http/Actions/CapacityAssignments/DeleteCapacityAssignmentAction.php@@ -10,7 +10,7 @@ use Illuminate\Http\Response;class DeleteCapacityAssignmentAction extends BaseAction{public function __construct(- private readonly DeleteCapacityAssignmentHandler $deleteCapacityAssignmentHandler+ private readonly DeleteCapacityAssignmentHandler $deleteCapacityAssignmentHandler,){}diff --git a/backend/app/Http/Actions/CapacityAssignments/GetCapacityAssignmentAction.php b/backend/app/Http/Actions/CapacityAssignments/GetCapacityAssignmentAction.phpnew file mode 100644index 000000000..15b61aaa9--- /dev/null+++ b/backend/app/Http/Actions/CapacityAssignments/GetCapacityAssignmentAction.php@@ -0,0 +1,31 @@+<?php++namespace HiEvents\Http\Actions\CapacityAssignments;++use HiEvents\DomainObjects\EventDomainObject;+use HiEvents\Http\Actions\BaseAction;+use HiEvents\Resources\CapacityAssignment\CapacityAssignmentResource;+use HiEvents\Services\Handlers\CapacityAssignment\GetCapacityAssignmentHandler;+use Illuminate\Http\JsonResponse;++class GetCapacityAssignmentAction extends BaseAction+{+ public function __construct(+ private readonly GetCapacityAssignmentHandler $getCapacityAssignmentsHandler,+ )+ {+ }++ public function __invoke(int $eventId, int $capacityAssignmentId): JsonResponse+ {+ $this->isActionAuthorized($eventId, EventDomainObject::class);++ return $this->resourceResponse(+ resource: CapacityAssignmentResource::class,+ data: $this->getCapacityAssignmentsHandler->handle(+ capacityAssignmentId: $capacityAssignmentId,+ eventId: $eventId,+ ),+ );+ }+}diff --git a/backend/app/Http/Actions/CapacityAssignments/UpdateCapacityAssignmentAction.php b/backend/app/Http/Actions/CapacityAssignments/UpdateCapacityAssignmentAction.phpindex 01af83fbb..0deb55fb3 100644--- a/backend/app/Http/Actions/CapacityAssignments/UpdateCapacityAssignmentAction.php+++ b/backend/app/Http/Actions/CapacityAssignments/UpdateCapacityAssignmentAction.php@@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Response;class UpdateCapacityAssignmentAction extends BaseAction{public function __construct(- private readonly UpdateCapacityAssignmentHandler $updateCapacityAssignmentHandler+ private readonly UpdateCapacityAssignmentHandler $updateCapacityAssignmentHandler,){}diff --git a/backend/app/Repository/Eloquent/CapacityAssignmentRepository.php b/backend/app/Repository/Eloquent/CapacityAssignmentRepository.phpindex 422a3ea1d..050ef6a33 100644--- a/backend/app/Repository/Eloquent/CapacityAssignmentRepository.php+++ b/backend/app/Repository/Eloquent/CapacityAssignmentRepository.php@@ -5,6 +5,7 @@ namespace HiEvents\Repository\Eloquent;use HiEvents\DomainObjects\CapacityAssignmentDomainObject;use HiEvents\Models\CapacityAssignment;use HiEvents\Repository\Interfaces\CapacityAssignmentRepositoryInterface;+use Illuminate\Pagination\LengthAwarePaginator;class CapacityAssignmentRepository extends BaseRepository implements CapacityAssignmentRepositoryInterface{@@ -17,4 +18,19 @@ class CapacityAssignmentRepository extends BaseRepository implements CapacityAss{return CapacityAssignmentDomainObject::class;}++ public function findCapacityAssignments(int $eventId): LengthAwarePaginator+ {+ $this->model->orderBy('created_at', 'desc');++ return $this->paginateWhere(+ where: [+ [+ 'event_id', '=', $eventId,+ ],+ ],+ limit: 100,+ page: 1,+ );+ }}diff --git a/backend/app/Repository/Interfaces/CapacityAssignmentRepositoryInterface.php b/backend/app/Repository/Interfaces/CapacityAssignmentRepositoryInterface.phpindex 7c0c042b3..5d5dae183 100644--- a/backend/app/Repository/Interfaces/CapacityAssignmentRepositoryInterface.php+++ b/backend/app/Repository/Interfaces/CapacityAssignmentRepositoryInterface.php@@ -3,11 +3,12 @@namespace HiEvents\Repository\Interfaces;use HiEvents\DomainObjects\CapacityAssignmentDomainObject;+use Illuminate\Contracts\Pagination\LengthAwarePaginator;/*** @extends RepositoryInterface<CapacityAssignmentDomainObject>*/interface CapacityAssignmentRepositoryInterface extends RepositoryInterface{-+ public function findCapacityAssignments(int $eventId): LengthAwarePaginator;}diff --git a/backend/app/Services/Domain/CapacityAssignment/CreateCapacityAssignmentService.php b/backend/app/Services/Domain/CapacityAssignment/CreateCapacityAssignmentService.phpindex 461cfa0ca..deeb4c9b4 100644--- a/backend/app/Services/Domain/CapacityAssignment/CreateCapacityAssignmentService.php+++ b/backend/app/Services/Domain/CapacityAssignment/CreateCapacityAssignmentService.php@@ -34,7 +34,10 @@ class CreateCapacityAssignmentServicereturn $this->persistAssignmentAndAssociateTickets($capacityAssignment, $ticketIds);}- private function persistAssignmentAndAssociateTickets(CapacityAssignmentDomainObject $capacityAssignment, ?array $ticketIds): CapacityAssignmentDomainObject+ private function persistAssignmentAndAssociateTickets(+ CapacityAssignmentDomainObject $capacityAssignment,+ ?array $ticketIds,+ ): CapacityAssignmentDomainObject{return $this->databaseManager->transaction(function () use ($capacityAssignment, $ticketIds) {/** @var CapacityAssignmentDomainObject $capacityAssignment */diff --git a/backend/app/Services/Domain/CapacityAssignment/UpdateCapacityAssignmentService.php b/backend/app/Services/Domain/CapacityAssignment/UpdateCapacityAssignmentService.phpindex 769909f12..b4d29be11 100644--- a/backend/app/Services/Domain/CapacityAssignment/UpdateCapacityAssignmentService.php+++ b/backend/app/Services/Domain/CapacityAssignment/UpdateCapacityAssignmentService.php@@ -41,7 +41,7 @@ class UpdateCapacityAssignmentService{return $this->databaseManager->transaction(function () use ($capacityAssignment, $ticketIds) {/** @var CapacityAssignmentDomainObject $capacityAssignment */- $capacityAssignment = $this->capacityAssignmentRepository->updateWhere(+ $this->capacityAssignmentRepository->updateWhere(attributes: [CapacityAssignmentDomainObjectAbstract::NAME => $capacityAssignment->getName(),CapacityAssignmentDomainObjectAbstract::EVENT_ID => $capacityAssignment->getEventId(),@@ -65,5 +65,4 @@ class UpdateCapacityAssignmentServicereturn $capacityAssignment;});}-}diff --git a/backend/app/Services/Handlers/CapacityAssignment/GetCapacityAssignmentHandler.php b/backend/app/Services/Handlers/CapacityAssignment/GetCapacityAssignmentHandler.phpnew file mode 100644index 000000000..cbdf770f0--- /dev/null+++ b/backend/app/Services/Handlers/CapacityAssignment/GetCapacityAssignmentHandler.php@@ -0,0 +1,33 @@+<?php++namespace HiEvents\Services\Handlers\CapacityAssignment;++use HiEvents\DomainObjects\CapacityAssignmentDomainObject;+use HiEvents\DomainObjects\TicketDomainObject;+use HiEvents\Repository\Interfaces\CapacityAssignmentRepositoryInterface;+use Symfony\Component\Routing\Exception\ResourceNotFoundException;++class GetCapacityAssignmentHandler+{+ public function __construct(+ private readonly CapacityAssignmentRepositoryInterface $capacityAssignmentRepository,+ )+ {+ }++ public function handle(int $capacityAssignmentId, int $eventId): CapacityAssignmentDomainObject+ {+ $capacityAssignment = $this->capacityAssignmentRepository+ ->loadRelation(TicketDomainObject::class)+ ->findFirstWhere([+ 'event_id' => $eventId,+ 'id' => $capacityAssignmentId,+ ]);++ if ($capacityAssignment === null) {+ throw new ResourceNotFoundException('Capacity assignment not found');+ }++ return $capacityAssignment;+ }+}diff --git a/backend/app/Services/Handlers/CapacityAssignment/GetCapacityAssignmentsHandler.php b/backend/app/Services/Handlers/CapacityAssignment/GetCapacityAssignmentsHandler.phpindex ada688d1f..dc058e73a 100644--- a/backend/app/Services/Handlers/CapacityAssignment/GetCapacityAssignmentsHandler.php+++ b/backend/app/Services/Handlers/CapacityAssignment/GetCapacityAssignmentsHandler.php@@ -5,7 +5,7 @@ namespace HiEvents\Services\Handlers\CapacityAssignment;use HiEvents\DomainObjects\TicketDomainObject;use HiEvents\Repository\Interfaces\CapacityAssignmentRepositoryInterface;use HiEvents\Services\Handlers\CapacityAssignment\DTO\GetCapacityAssignmentsDTO;-use Illuminate\Support\Collection;+use Illuminate\Contracts\Pagination\LengthAwarePaginator;class GetCapacityAssignmentsHandler{@@ -15,12 +15,10 @@ class GetCapacityAssignmentsHandler{}- public function handle(GetCapacityAssignmentsDTO $dto): Collection+ public function handle(GetCapacityAssignmentsDTO $dto): LengthAwarePaginator{return $this->capacityAssignmentRepository->loadRelation(TicketDomainObject::class)- ->findWhere([- 'event_id' => $dto->eventId,- ]);+ ->findCapacityAssignments($dto->eventId);}}diff --git a/backend/routes/api.php b/backend/routes/api.phpindex d3285e5e9..8133e0aab 100644--- a/backend/routes/api.php+++ b/backend/routes/api.php@@ -23,6 +23,7 @@ use HiEvents\Http\Actions\Auth\ResetPasswordAction;use HiEvents\Http\Actions\Auth\ValidateResetPasswordTokenAction;use HiEvents\Http\Actions\CapacityAssignments\CreateCapacityAssignmentAction;use HiEvents\Http\Actions\CapacityAssignments\DeleteCapacityAssignmentAction;+use HiEvents\Http\Actions\CapacityAssignments\GetCapacityAssignmentAction;use HiEvents\Http\Actions\CapacityAssignments\GetCapacityAssignmentsAction;use HiEvents\Http\Actions\CapacityAssignments\UpdateCapacityAssignmentAction;use HiEvents\Http\Actions\Common\Webhooks\StripeIncomingWebhookAction;@@ -214,6 +215,7 @@ $router->middleware(['auth:api'])->group($router->post('/events/{event_id}/capacity-assignments', CreateCapacityAssignmentAction::class);$router->get('/events/{event_id}/capacity-assignments', GetCapacityAssignmentsAction::class);+ $router->get('/events/{event_id}/capacity-assignments/{capacity_assignment_id}', GetCapacityAssignmentAction::class);$router->put('/events/{event_id}/capacity-assignments/{capacity_assignment_id}', UpdateCapacityAssignmentAction::class);$router->delete('/events/{event_id}/capacity-assignments/{capacity_assignment_id}', DeleteCapacityAssignmentAction::class);}diff --git a/frontend/src/components/common/ActionMenu/index.tsx b/frontend/src/components/common/ActionMenu/index.tsxnew file mode 100644index 000000000..1cda6ba76--- /dev/null+++ b/frontend/src/components/common/ActionMenu/index.tsx@@ -0,0 +1,55 @@+import React from 'react';+import {Button, Group, Menu} from '@mantine/core';+import {IconDotsVertical} from '@tabler/icons-react';++interface MenuItem {+ label: string;+ icon: React.ReactNode;+ onClick: () => void;+ color?: string;+ visible?: boolean;+}++export interface ActionMenuItemsGroup {+ label: string;+ items: MenuItem[];+ showDividerAbove?: boolean;+}++ interface ActionMenuProps {+ itemsGroups: ActionMenuItemsGroup[];+}++export const ActionMenu: React.FC<ActionMenuProps> = ({itemsGroups}) => {+ return (+ <Group wrap={'nowrap'} gap={0} justify={'flex-end'}>+ <Menu shadow="md" width={200}>+ <Menu.Target>+ <Button variant={'transparent'}>+ <IconDotsVertical/>+ </Button>+ </Menu.Target>++ <Menu.Dropdown>+ {itemsGroups.map((group, groupIndex) => (+ <React.Fragment key={groupIndex}>+ {group.showDividerAbove && <Menu.Divider/>}+ <Menu.Label>{group.label}</Menu.Label>+ {group.items.map((item, itemIndex) => item.visible !== false && (+ <Menu.Item+ key={itemIndex}+ color={item.color}+ leftSection={item.icon}+ onClick={item.onClick}+ >+ {item.label}+ </Menu.Item>+ ))}++ </React.Fragment>+ ))}+ </Menu.Dropdown>+ </Menu>+ </Group>+ );+};diff --git a/frontend/src/components/common/AttendeeTable/index.tsx b/frontend/src/components/common/AttendeeTable/index.tsxindex a70fcd9c3..f3d2d805f 100644--- a/frontend/src/components/common/AttendeeTable/index.tsx+++ b/frontend/src/components/common/AttendeeTable/index.tsx@@ -1,14 +1,6 @@-import {Anchor, Avatar, Badge, Button, Group, Menu, Table as MantineTable,} from '@mantine/core';+import {Anchor, Avatar, Badge, Button, Table as MantineTable,} from '@mantine/core';import {Attendee, MessageType} from "../../../types.ts";-import {- IconDotsVertical,- IconEye,- IconMailForward,- IconPencil,- IconPlus,- IconSend,- IconTrash-} from "@tabler/icons-react";+import {IconEye, IconMailForward, IconPencil, IconPlus, IconSend, IconTrash} from "@tabler/icons-react";import {getInitials, getTicketFromEvent} from "../../../utilites/helpers.ts";import {Table, TableHead} from "../Table";import {useDisclosure} from "@mantine/hooks";@@ -26,6 +18,7 @@ import {t, Trans} from "@lingui/macro";import {confirmationDialog} from "../../../utilites/confirmationDialog.tsx";import {useResendAttendeeTicket} from "../../../mutations/useResendAttendeeTicket.ts";import {ViewAttendeeModal} from "../../modals/ViewAttendeeModal";+import {ActionMenu} from '../ActionMenu/index.tsx';interface AttendeeTableProps {attendees: Attendee[];@@ -163,56 +156,45 @@ export const AttendeeTable = ({attendees, openCreateModal}: AttendeeTableProps)color={attendee.status === 'CANCELLED' ? 'red' : 'green'}>{attendee.status}</Badge></MantineTable.Td><MantineTable.Td style={{paddingRight: 0}}>- <Group wrap={'nowrap'} gap={0} justify={'flex-end'}>- <Menu shadow="md" width={200}>- <Menu.Target>- <Button variant={'transparent'}>- <IconDotsVertical/>- </Button>- </Menu.Target>-- <Menu.Dropdown>- <Menu.Label>{t`Manage`}</Menu.Label>- <Menu.Item- leftSection={<IconEye size={14}/>}- onClick={() => handleModalClick(attendee, viewModalOpen)}- >- {t`View attendee`}- </Menu.Item>-- <Menu.Item leftSection={<IconSend size={14}/>}- onClick={() => handleModalClick(attendee, messageModal)}>- {t`Message attendee`}- </Menu.Item>- <Menu.Item- leftSection={<IconPencil size={14}/>}- onClick={() => handleModalClick(attendee, editModal)}- >- {t`Edit attendee`}- </Menu.Item>-- {attendee.status === 'ACTIVE' && (- <Menu.Item- leftSection={<IconMailForward size={14}/>}- onClick={() => handleResendTicket(attendee)}- >- {t`Resend ticket email`}- </Menu.Item>- )}-- <Menu.Divider/>-- <Menu.Label>{t`Danger zone`}</Menu.Label>- <Menu.Item- color={attendee.status === 'CANCELLED' ? 'green' : 'red'}- leftSection={<IconTrash size={14}/>}- onClick={handleCancel(attendee)}- >- {attendee.status === 'CANCELLED' ? t`Activate` : t`Cancel`} {t`ticket`}- </Menu.Item>- </Menu.Dropdown>- </Menu>- </Group>+ <ActionMenu itemsGroups={[+ {+ label: t`Actions`,+ items: [+ {+ label: t`View attendee`,+ icon: <IconEye size={14}/>,+ onClick: () => handleModalClick(attendee, viewModalOpen),+ },+ {+ label: t`Message attendee`,+ icon: <IconSend size={14}/>,+ onClick: () => handleModalClick(attendee, messageModal),+ },+ {+ label: t`Edit attendee`,+ icon: <IconPencil size={14}/>,+ onClick: () => handleModalClick(attendee, editModal),+ },+ {+ label: t`Resend ticket email`,+ icon: <IconMailForward size={14}/>,+ onClick: () => handleResendTicket(attendee),+ visible: attendee.status === 'ACTIVE',+ },+ ],+ },+ {+ label: t`Danger Zone`,+ items: [+ {+ label: attendee.status === 'CANCELLED' ? t`Activate` : t`Cancel` + ` ` + t`ticket`,+ icon: <IconTrash size={14}/>,+ onClick: () => handleCancel(attendee),+ color: attendee.status === 'CANCELLED' ? 'green' : 'red',+ },+ ],+ },+ ]}/></MantineTable.Td></MantineTable.Tr>);diff --git a/frontend/src/components/common/CapacityAssignmentList/CapacityAssignmentList.module.scss b/frontend/src/components/common/CapacityAssignmentList/CapacityAssignmentList.module.scssindex 5c56de818..e7cb9227a 100644--- a/frontend/src/components/common/CapacityAssignmentList/CapacityAssignmentList.module.scss+++ b/frontend/src/components/common/CapacityAssignmentList/CapacityAssignmentList.module.scss@@ -5,11 +5,34 @@justify-content: space-between;align-items: center;+ @include respond-below(md) {+ flex-direction: column;+ align-items: flex-start;+ }+.search {+ width: 80%;+ margin-right: 20px;+ @include respond-below(md) {+ width: 100%;+ margin-bottom: 20px;+ }}-}+ .button {+ display: flex;+ place-content: flex-end;++ button {+ height: 42px;+ }++ @include respond-below(md) {+ width: 100%;+ }+ }+}.capacityAssignmentList {display: grid;@@ -41,7 +64,7 @@display: flex;color: #999;justify-content: center;- align-items: center;+ align-items: center;}}@@ -73,7 +96,5 @@}}}--}diff --git a/frontend/src/components/common/CapacityAssignmentList/index.tsx b/frontend/src/components/common/CapacityAssignmentList/index.tsxindex ebb5be7b5..2c06c4997 100644--- a/frontend/src/components/common/CapacityAssignmentList/index.tsx+++ b/frontend/src/components/common/CapacityAssignmentList/index.tsx@@ -1,7 +1,7 @@-import {CapacityAssignment} from "../../../types";+import {CapacityAssignment, IdParam} from "../../../types";import {Badge, Button, Progress} from "@mantine/core";import {t, Trans} from "@lingui/macro";-import {IconDotsVertical, IconHelp, IconPlus} from "@tabler/icons-react";+import {IconHelp, IconPencil, IconPlus, IconTrash} from "@tabler/icons-react";import Truncate from "../Truncate";import {NoResultsSplash} from "../NoResultsSplash";import classes from './CapacityAssignmentList.module.scss';@@ -9,6 +9,12 @@ import {Card} from "../Card";import {Popover} from "../Popover";import {SearchBar} from "../SearchBar";import {useState} from "react";+import {ActionMenu} from "../ActionMenu";+import {useDisclosure} from "@mantine/hooks";+import {EditCapacityAssignmentModal} from "../../modals/EditCapacityAssignmentModal";+import {useDeleteCapacityAssignment} from "../../../mutations/useDeleteCapacityAssignment";+import {showError, showSuccess} from "../../../utilites/notifications.tsx";+import {confirmationDialog} from "../../../utilites/confirmationDialog.tsx";interface CapacityAssignmentListProps {capacityAssignments: CapacityAssignment[];@@ -17,7 +23,20 @@ interface CapacityAssignmentListProps {export const CapacityAssignmentList = ({capacityAssignments, openCreateModal}: CapacityAssignmentListProps) => {const [searchValue, setSearchValue] = useState<string>('');+ const [editModalOpen, {open: openEditModal, close: closeEditModal}] = useDisclosure(false);+ const [selectedCapacityAssignmentId, setSelectedCapacityAssignmentId] = useState<IdParam>();+ const deleteMutation = useDeleteCapacityAssignment();+ const handleDeleteTicket = (capacityAssignmentId: IdParam, eventId: IdParam) => {+ deleteMutation.mutate({capacityAssignmentId, eventId}, {+ onSuccess: () => {+ showSuccess(t`Capacity Assignment deleted successfully`);+ },+ onError: (error: any) => {+ showError(error.message);+ }+ });+ }if (capacityAssignments.length === 0) {return (@@ -60,6 +79,7 @@ export const CapacityAssignmentList = ({capacityAssignments, openCreateModal}: C<div className={classes.toolbar}><div className={classes.search}><SearchBar+ placeholder={t`Search capacity assignments`}onClear={() => setSearchValue('')}value={searchValue}onChange={(value) => setSearchValue(value.target.value)}@@ -150,29 +170,53 @@ export const CapacityAssignmentList = ({capacityAssignments, openCreateModal}: C)}</div><div className={classes.capacityAssignmentActions}>- <Button variant={'transparent'}>- <IconDotsVertical/>- </Button>+ <ActionMenu+ itemsGroups={[+ {+ label: t`Manage`,+ items: [+ {+ label: t`Edit Capacity`,+ icon: <IconPencil size={14}/>,+ onClick: () => {+ console.log('Editing assignment:', assignment);+ setSelectedCapacityAssignmentId(assignment.id as IdParam);+ openEditModal();+ }+ },+ ],+ },+ {+ label: t`Danger zone`,+ items: [+ {+ label: t`Delete Capacity`,+ icon: <IconTrash size={14}/>,+ onClick: () => {+ confirmationDialog(+ t`Are you sure you would like to delete this Capacity Assignment?`,+ () => {+ handleDeleteTicket(+ assignment.id as IdParam,+ assignment.event_id as IdParam,+ );+ })+ },+ color: 'red',+ },+ ],+ },+ ]}+ /></div></div></Card>);})}</div>+ {(editModalOpen && selectedCapacityAssignmentId)+ && <EditCapacityAssignmentModal onClose={closeEditModal}+ capacityAssignmentId={selectedCapacityAssignmentId}/>}</>);};--// Dummy handlers for menu actions (should be replaced with actual implementations)-const handleModalClick = (assignment: CapacityAssignment, modalOpen: any) => {- console.log('Opening modal for:', assignment);-};--const handleDelete = (assignment: CapacityAssignment) => {- return () => {- console.log('Deleting assignment:', assignment);- };-};--const viewModalOpen = {}; // Placeholder for actual modal open state-const editModal = {}; // Placeholder for actual modal open statediff --git a/frontend/src/components/common/CheckoutQuestion/index.tsx b/frontend/src/components/common/CheckoutQuestion/index.tsxindex 96d3c3487..bccf6f663 100644--- a/frontend/src/components/common/CheckoutQuestion/index.tsx+++ b/frontend/src/components/common/CheckoutQuestion/index.tsx@@ -134,8 +134,8 @@ const AddressInput = ({question, name, form}: QuestionInputProps) => {return (<><h4>{question.title}</h4>- <div className={classes.description} dangerouslySetInnerHTML={{__html: question.description || ''}}>- </div>+ <div className={classes.description} dangerouslySetInnerHTML={{__html: question.description || ''}}/>+<TextInput withAsterisk={question.required}{...form.getInputProps(`${name}.address_line_1`)}label={t`Address line 1`}/>diff --git a/frontend/src/components/forms/CapaciyAssigmentForm/index.tsx b/frontend/src/components/forms/CapaciyAssigmentForm/index.tsxindex 8016483a3..07d99de68 100644--- a/frontend/src/components/forms/CapaciyAssigmentForm/index.tsx+++ b/frontend/src/components/forms/CapaciyAssigmentForm/index.tsx@@ -4,15 +4,7 @@ import {t} from "@lingui/macro";import {UseFormReturnType} from "@mantine/form";import {CapacityAssignmentRequest, Ticket} from "../../../types.ts";import {CustomSelect, ItemProps} from "../../common/CustomSelect";-import {- IconCalendarEvent,- IconCash, IconCheck,- IconCoinOff,- IconCoins, IconCross,- IconHeartDollar,- IconSwitch,- IconTicket, IconX-} from "@tabler/icons-react";+import {IconCalendarEvent, IconCheck, IconTicket, IconX} from "@tabler/icons-react";interface CapaciyAssigmentFormProps {form: UseFormReturnType<CapacityAssignmentRequest>;diff --git a/frontend/src/components/modals/EditCapacityAssignmentModal/index.tsx b/frontend/src/components/modals/EditCapacityAssignmentModal/index.tsxnew file mode 100644index 000000000..0ef13d78e--- /dev/null+++ b/frontend/src/components/modals/EditCapacityAssignmentModal/index.tsx@@ -0,0 +1,82 @@+import {CapacityAssignmentRequest, GenericModalProps, IdParam, Ticket} from "../../../types.ts";+import {Modal} from "../../common/Modal";+import {t} from "@lingui/macro";+import {CapaciyAssigmentForm} from "../../forms/CapaciyAssigmentForm";+import {useForm} from "@mantine/form";+import {Button} from "@mantine/core";+import {showSuccess} from "../../../utilites/notifications.tsx";+import {useParams} from "react-router-dom";+import {useFormErrorResponseHandler} from "../../../hooks/useFormErrorResponseHandler.tsx";+import {useGetEvent} from "../../../queries/useGetEvent.ts";+import {useEditCapacityAssignment} from "../../../mutations/useEditCapacityAssignment.ts";+import {useGetEventCapacityAssignment} from "../../../queries/useGetCapacityAssignment.ts";+import {useEffect} from "react";++interface EditCapacityAssignmentModalProps {+ capacityAssignmentId: IdParam;+}++export const EditCapacityAssignmentModal = ({+ onClose,+ capacityAssignmentId+ }: GenericModalProps & EditCapacityAssignmentModalProps) => {+ const {eventId} = useParams();+ const errorHandler = useFormErrorResponseHandler();+ const {data: capacityAssignment} = useGetEventCapacityAssignment(+ capacityAssignmentId,+ eventId+ );+ const {data: event} = useGetEvent(eventId);+ const form = useForm<CapacityAssignmentRequest>({+ initialValues: {+ name: '',+ capacity: undefined,+ applies_to: 'EVENT',+ status: 'ACTIVE',+ ticket_ids: [],+ }+ });+ const editMutation = useEditCapacityAssignment();++ const handleSubmit = (requestData: CapacityAssignmentRequest) => {+ editMutation.mutate({+ eventId: eventId,+ capacityAssignmentData: requestData,+ capacityAssignmentId: capacityAssignmentId,+ }, {+ onSuccess: () => {+ showSuccess(t`Successfully updated Capacity Assignment`);+ onClose();+ },+ onError: (error) => errorHandler(form, error),+ })+ }++ useEffect(() => {+ if (capacityAssignment) {+ form.setValues({+ name: capacityAssignment.name,+ capacity: capacityAssignment.capacity,+ applies_to: capacityAssignment.applies_to,+ status: capacityAssignment.status,+ ticket_ids: capacityAssignment.tickets.map(ticket => String(ticket.id)),+ });+ }+ }, [capacityAssignment]);++ return (+ <Modal opened onClose={onClose} heading={t`Edit Capacity Assignment`}>+ <form onSubmit={form.onSubmit(handleSubmit)}>+ {event && <CapaciyAssigmentForm form={form} tickets={event.tickets as Ticket[]}/>}+ <Button+ type={'submit'}+ fullWidth+ loading={editMutation.isLoading}+ >+ {t`Edit Capacity Assignment`}+ </Button>+ </form>+ </Modal>+ );+}+diff --git a/frontend/src/mutations/useDeleteCapacityAssignment.ts b/frontend/src/mutations/useDeleteCapacityAssignment.tsnew file mode 100644index 000000000..f051b335a--- /dev/null+++ b/frontend/src/mutations/useDeleteCapacityAssignment.ts@@ -0,0 +1,18 @@+import {useMutation, useQueryClient} from "@tanstack/react-query";+import {IdParam} from "../types.ts";+import {capacityAssignmentClient} from "../api/capacity-assignment.client.ts";+import {GET_EVENT_CAPACITY_ASSIGNMENTS_QUERY_KEY} from "../queries/useGetCapacityAssignments.ts";++export const useDeleteCapacityAssignment = () => {+ const queryClient = useQueryClient();++ return useMutation(+ ({capacityAssignmentId, eventId}: {+ capacityAssignmentId: IdParam,+ eventId: IdParam,+ }) => capacityAssignmentClient.delete(eventId, capacityAssignmentId),+ {+ onSuccess: () => queryClient.invalidateQueries([GET_EVENT_CAPACITY_ASSIGNMENTS_QUERY_KEY]),+ }+ )+}diff --git a/frontend/src/mutations/useEditCapacityAssignment.ts b/frontend/src/mutations/useEditCapacityAssignment.tsnew file mode 100644index 000000000..d4c2a6404--- /dev/null+++ b/frontend/src/mutations/useEditCapacityAssignment.ts@@ -0,0 +1,23 @@+import {useMutation, useQueryClient} from "@tanstack/react-query";+import {CapacityAssignmentRequest, IdParam} from "../types.ts";+import {GET_EVENT_CAPACITY_ASSIGNMENTS_QUERY_KEY} from "../queries/useGetCapacityAssignments.ts";+import {capacityAssignmentClient} from "../api/capacity-assignment.client.ts";++export const useEditCapacityAssignment = () => {+ const queryClient = useQueryClient();++ return useMutation(+ ({capacityAssignmentData, eventId, capacityAssignmentId}: {+ eventId: IdParam,+ capacityAssignmentData: CapacityAssignmentRequest,+ capacityAssignmentId: IdParam,+ }) => capacityAssignmentClient.update(+ eventId,+ capacityAssignmentId,+ capacityAssignmentData,+ ),+ {+ onSuccess: () => queryClient.invalidateQueries({queryKey: [GET_EVENT_CAPACITY_ASSIGNMENTS_QUERY_KEY]}),+ }+ )+}diff --git a/frontend/src/queries/useGetCapacityAssignment.ts b/frontend/src/queries/useGetCapacityAssignment.tsnew file mode 100644index 000000000..ecff923f7--- /dev/null+++ b/frontend/src/queries/useGetCapacityAssignment.ts@@ -0,0 +1,15 @@+import {useQuery} from "@tanstack/react-query";+import {IdParam} from "../types.ts";+import {capacityAssignmentClient} from "../api/capacity-assignment.client.ts";++export const GET_EVENT_CAPACITY_ASSIGNMENT_QUERY_KEY = 'getEventCapacityAssignment';++export const useGetEventCapacityAssignment = (capacityAssignmentId: IdParam, eventId: IdParam) => {+ return useQuery(+ [GET_EVENT_CAPACITY_ASSIGNMENT_QUERY_KEY, eventId, capacityAssignmentId],+ async () => {+ const {data} = await capacityAssignmentClient.get(eventId, capacityAssignmentId);+ return data;+ }+ )+};diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 46ebeec06..8c43b6cea 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -413,7 +413,7 @@ export interface CapacityAssignment {}export type CapacityAssignmentRequest = Omit<CapacityAssignment, 'id' | 'event_id' | 'used_capacity'> & {- ticket_ids: number[];+ ticket_ids: IdParam[];};export interface QuestionRequestData {