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
import {
IconArrowLeft,
IconCalendarRepeat,
IconChartPie,
IconChevronRight,
IconDashboard,
IconDeviceTabletCode,
IconDiscount2,
IconExternalLink,
IconEye,
IconEyeOff,
IconMailCheck,
IconMailForward,
IconMicrophone2,
IconPaint,
IconQrcode,
IconReceipt,
IconSend,
IconSettings,
IconShare,
IconCashRegister,
IconTicket,
IconTrendingUp,
IconUserQuestion,
IconUsers,
IconArmchair,
IconUsersGroup,
IconWebhook,
IconListCheck,
} from "@tabler/icons-react";
import {useAccess} from "../../../hooks/useAccess.ts";
import {t} from "@lingui/macro";
import {useGetEvent} from "../../../queries/useGetEvent";
import {OrganizerDatesProvider} from "../../common/OrganizerDatesProvider";
import {useGetEventSettings} from "../../../queries/useGetEventSettings";
import {useGetEventCounts} from "../../../queries/useGetEventCounts";
import {useGeoStatus} from "../../../queries/useGeoStatus.ts";
import Truncate from "../../common/Truncate";
import {BreadcrumbItem, NavItem} from "../AppLayout/types.ts";
import AppLayout from "../AppLayout";
import {NavLink, useLocation, useParams} from "react-router";
import classes from './Event.module.scss';
import {Badge, Button} from "@mantine/core";
import {confirmationDialog} from "../../../utilites/confirmationDialog.tsx";
import {useUpdateEventStatus} from "../../../mutations/useUpdateEventStatus.ts";
import {showError, showSuccess} from "../../../utilites/notifications.tsx";
import {ShareModal} from "../../modals/ShareModal";
import {EventLiveCelebrationModal} from "../../modals/EventLiveCelebrationModal";
import {PublishEventModal} from "../../modals/PublishEventModal";
import {useDisclosure} from "@mantine/hooks";
import {TopBarButton} from "../../common/TopBarButton";
import {useWindowWidth} from "../../../hooks/useWindowWidth.ts";
import {SidebarCallout} from "../../common/SidebarCallout";
import {useGetMe} from "../../../queries/useGetMe.ts";
import {FeatureFlag} from "../../../constants/featureFlags.ts";
import {useResendEmailConfirmation} from "../../../mutations/useResendEmailConfirmation.ts";
import {useMemo, useState} from "react";
import {eventHomepageUrl} from "../../../utilites/urlHelper.ts";
import {EventType} from "../../../types.ts";
import {useGetEventOccurrence} from "../../../queries/useGetEventOccurrence.ts";
import {useLicensedFeature} from "../../../ee/licensing/hooks/useLicensedFeature.ts";
import {prettyDate} from "../../../utilites/dates.ts";
import {GenericErrorPage} from "../../common/GenericErrorPage";
const EventLayout = () => {
const location = useLocation();
const {eventId} = useParams();
const [opened, {open, close}] = useDisclosure(false);
const [celebrationOpened, {open: openCelebration, close: closeCelebration}] = useDisclosure(false);
const [publishModalOpened, {open: openPublishModal, close: closePublishModal}] = useDisclosure(false);
const statusToggleMutation = useUpdateEventStatus();
const {data: event, isFetched: isEventFetched, error: eventError} = useGetEvent(eventId);
const {isFetched: isEventSettingsFetched} = useGetEventSettings(eventId);
const {data: eventCounts} = useGetEventCounts(eventId);
const seating = useLicensedFeature(FeatureFlag.SEATING);
const boxOffice = useLicensedFeature(FeatureFlag.BOX_OFFICE);
const {data: me} = useGetMe();
const {isReadOnly, can, canManageOrganizer} = useAccess();
const resendEmailConfirmationMutation = useResendEmailConfirmation();
const [emailConfirmationResent, setEmailConfirmationResent] = useState(false);
useGeoStatus();
const occurrenceIdFromUrl = useMemo(() => {
const match = location.pathname.match(/\/occurrences\/(\d+)$/);
return match ? match[1] : undefined;
}, [location.pathname]);
const {data: occurrence} = useGetEventOccurrence(eventId, occurrenceIdFromUrl);
const handleEmailConfirmationResend = () => {
resendEmailConfirmationMutation.mutate({
userId: me?.id
}, {
onSuccess: () => {
showSuccess(t`Email confirmation resent successfully`);
setEmailConfirmationResent(true);
},
onError: () => {
showError(t`Something went wrong. Please try again.`);
}
})
}
const navItems: NavItem[] = [
{
link: '/manage/organizer/' + event?.organizer?.id,
label: t`Organizer Dashboard`,
icon: IconArrowLeft,
showWhen: () => canManageOrganizer(event?.organizer_id),
},
// 1. OVERVIEW
{label: t`Overview`},
{link: 'dashboard', label: t`Dashboard`, icon: IconDashboard},
{
link: 'reports',
label: t`Reports`,
icon: IconChartPie,
isActive: (isActive) => isActive || location.pathname.includes('/report/'),
showWhen: () => can('VIEW_FINANCIALS'),
},
// 2. EVENT SETUP
{label: t`Setup & Design`},
{
link: 'occurrences',
label: t`Occurrence Schedule`,
icon: IconCalendarRepeat,
showWhen: () => event?.type === EventType.RECURRING,
},
{link: 'settings', label: t`Event Settings`, icon: IconSettings, showWhen: () => !isReadOnly},
{link: 'lineup', label: t`Lineup & Schedule`, icon: IconMicrophone2},
{link: 'homepage-designer', label: t`Homepage Designer`, icon: IconPaint, showWhen: () => !isReadOnly},
{link: 'ticket-designer', label: t`Ticket Designer`, icon: IconTicket, showWhen: () => !isReadOnly},
{link: 'seating', label: t`Seating`, icon: IconArmchair, showWhen: () => !isReadOnly && (seating.isEnabled || !!event?.has_seat_map)},
{link: 'questions', label: t`Registration Questions`, icon: IconUserQuestion},
// 3. Ticketing & Sales
{label: t`Ticketing & Sales`},
{link: 'products', label: t`Tickets & Products`, icon: IconTicket},
{link: 'orders', label: t`Orders`, icon: IconReceipt, badge: eventCounts?.total_orders},
{link: 'promo-codes', label: t`Promo Codes`, icon: IconDiscount2},
{link: 'affiliates', label: t`Affiliates`, icon: IconTrendingUp},
// 4. GUESTS
{label: t`Guest Management`},
{link: 'attendees', label: t`Attendees`, icon: IconUsers, badge: eventCounts?.total_attendees_registered},
{link: 'check-in', label: t`Check-In Lists`, icon: IconQrcode},
{link: 'box-office', label: t`Box Office`, icon: IconCashRegister, showWhen: () => boxOffice.isVisible},
{link: 'messages', label: t`Messages`, icon: IconSend},
{link: 'sold-out-waitlist', label: t`Waitlist`, icon: IconListCheck},
{
link: 'capacity-assignments',
label: t`Capacity Management`,
icon: IconUsersGroup,
showWhen: () => event?.type !== EventType.RECURRING,
},
// 5. INTEGRATIONS
{label: t`Integrations`},
{link: 'widget', label: t`Widget Embed`, icon: IconDeviceTabletCode},
{link: 'webhooks', label: t`Webhooks`, icon: IconWebhook, showWhen: () => can('VIEW_FINANCIALS')},
{label: t`Team`},
{link: 'team', label: t`Team Access`, icon: IconUsersGroup, showWhen: () => can('MANAGE_TEAM')},
];
const navItemsWithLoading = !isEventSettingsFetched || !isEventFetched
? navItems.map(item => item.link ? {...item, loading: true} : item)
: navItems;
const screenWidth = useWindowWidth();
const breadcrumbItemsWidth = screenWidth > 1100 ? 60 : 23;
const breadcrumbItems: BreadcrumbItem[] = isEventFetched ? [
{
link: canManageOrganizer(event?.organizer_id) ? `/manage/organizer/${event?.organizer?.id}` : undefined,
content: <Truncate length={breadcrumbItemsWidth} text={event?.organizer?.name} showTooltip={false}/>
},
{
link: `/manage/event/${event?.id}`,
content: <Truncate length={breadcrumbItemsWidth} text={event?.title} showTooltip={false}/>
},
...(occurrenceIdFromUrl && occurrence ? [{
link: `/manage/event/${event?.id}/occurrences/${occurrenceIdFromUrl}`,
content: <Truncate
length={breadcrumbItemsWidth}
text={prettyDate(occurrence.start_date, event?.timezone || 'UTC') + (occurrence.label ? ` (${occurrence.label})` : '')}
showTooltip={false}
/>
}] : []),
] : [
{link: '#', content: '...'}
];
const handleStatusToggle = () => {
if (event?.status === 'PENDING_MANUAL_REVIEW') {
showError(t`This event is pending manual review and cannot be published until the review is complete.`);
return;
}
if (event?.status !== 'LIVE') {
openPublishModal();
return;
}
const message = t`Are you sure you want to make this event draft? This will make the event invisible to the public`;
confirmationDialog(message, () => {
statusToggleMutation.mutate({
eventId,
status: 'DRAFT'
}, {
onSuccess: () => {
showSuccess(t`Event status updated`);
},
onError: (error: any) => {
showError(error?.response?.data?.message || t`Event status update failed. Please try again later`);
}
});
});
};
if ((eventError as any)?.response?.data?.error_code === 'ACCESS_RESTRICTED') {
return (
<GenericErrorPage
title={t`You don't have access to this event`}
description={t`Ask an account admin to give you access, or open one of your own events.`}
buttonText={t`Go to your events`}
buttonUrl="/manage/events"
buttonIcon={<IconArrowLeft size={18}/>}
/>
);
}
return (
<OrganizerDatesProvider firstDayOfWeek={event?.organizer?.settings?.first_day_of_week}>
<AppLayout
navItems={navItemsWithLoading}
breadcrumbItems={breadcrumbItems}
entityType="event"
topBarContent={(
<div className={classes.statusToggleContainer}>
{isReadOnly && <Badge variant="white" color="dark" data-testid="view-only-badge">{t`View only`}</Badge>}
{isEventFetched && !isReadOnly && (
<TopBarButton
onClick={handleStatusToggle}
data-testid="event-status-toggle"
size="sm"
leftSection={(event?.status === 'DRAFT' || event?.status === 'PENDING_MANUAL_REVIEW') ? <IconEyeOff size={16}/> : <IconEye size={16}/>}
rightSection={<IconChevronRight size={14}/>}
>
{event?.status === 'PENDING_MANUAL_REVIEW'
? <span>{t`Pending Review`}</span>
: event?.status === 'DRAFT'
? <span>{t`Draft`} <span
className={classes.statusAction}>{t`- Click to Publish`}</span></span>
: <span>{t`Live`} <span
className={classes.statusAction}>{t`- Click to Unpublish`}</span></span>
}
</TopBarButton>
)}
</div>
)}
breadcrumbContentRight={(
<div className={classes.shareButton}>
{event && (
<>
<Button
onClick={open}
variant="transparent"
leftSection={<IconShare size={16}/>}
>
{t`Share Event`}
</Button>
<ShareModal
url={eventHomepageUrl(event)}
title={event.title}
modalTitle={t`Share Event`}
opened={opened}
onClose={close}
/>
<EventLiveCelebrationModal
opened={celebrationOpened}
onClose={closeCelebration}
url={eventHomepageUrl(event)}
eventTitle={event.title}
eventId={String(event.id)}
/>
{publishModalOpened && (
<PublishEventModal
opened={publishModalOpened}
onClose={closePublishModal}
event={event}
onSuccess={() => {
closePublishModal();
openCelebration();
}}
/>
)}
</>
)}
</div>
)}
actionGroupContent={(
<Button
component={NavLink}
to={`/event/${eventId}/${event?.slug}`}
target={'_blank'}
variant={'transparent'}
leftSection={<IconExternalLink size={17}/>}
className={classes.eventPageButton}
title={t`Preview Event page`}
>
<div className={classes.eventPageButtonText}>
<span className={classes.desktop}>
{t`Preview Event page`}
</span>
<span className={classes.mobile}>
{t`Event Page`}
</span>
</div>
</Button>
)}
sidebarFooter={
(me && !me.is_email_verified && !emailConfirmationResent ? (
<SidebarCallout
icon={<IconMailCheck size={20}/>}
heading={t`Verify your email`}
description={t`Confirm your email to access all features.`}
buttonIcon={<IconMailForward size={16}/>}
buttonText={t`Resend email`}
onClick={() => handleEmailConfirmationResend()}
/>
) : null)
}
/>
</OrganizerDatesProvider>
);
};
export default EventLayout;