| 1 |
import {useState} from 'react'; |
| 2 |
import cx from 'classnames'; |
| 3 |
import {__} from '@wordpress/i18n'; |
| 4 |
import {GiveIcon} from '@givewp/components'; |
| 5 |
import styles from './EventDetailsPage.module.scss'; |
| 6 |
import {GiveEventTicketsDetails} from './types'; |
| 7 |
import EventSection from './EventSection'; |
| 8 |
import TicketTypesSection from './TicketTypesSection'; |
| 9 |
import DonationFormsSection from './DonationFormsSection'; |
| 10 |
import AttendeesSection from './AttendeesSection'; |
| 11 |
|
| 12 |
declare global { |
| 13 |
interface Window { |
| 14 |
GiveEventTicketsDetails: GiveEventTicketsDetails; |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
const tabs = { |
| 19 |
overview: __('Overview', 'give'), |
| 20 |
attendees: __('Attendees', 'give'), |
| 21 |
}; |
| 22 |
|
| 23 |
export default function EventDetailsPage() { |
| 24 |
const [activeTab, setActiveTab] = useState<'overview' | 'attendees'>('overview'); |
| 25 |
const [updateErrors, setUpdateErrors] = useState<{errors: Array<number>; successes: Array<number>}>({ |
| 26 |
errors: [], |
| 27 |
successes: [], |
| 28 |
}); |
| 29 |
|
| 30 |
return ( |
| 31 |
<> |
| 32 |
<article className={styles.page}> |
| 33 |
<header className={styles.pageHeader}> |
| 34 |
<div className={styles.flexRow}> |
| 35 |
<GiveIcon size={'1.875rem'} /> |
| 36 |
<h1 className={styles.pageTitle}>{__('Event details', 'give')}</h1> |
| 37 |
</div> |
| 38 |
<div className={styles.flexRow}> |
| 39 |
<a |
| 40 |
href={`${window.GiveEventTicketsDetails.adminUrl}edit.php?post_type=give_forms&page=give-event-tickets`} |
| 41 |
className={`button button-secondary ${styles.goToEventsListButton}`} |
| 42 |
> |
| 43 |
{__('Go to events list', 'give')} |
| 44 |
</a> |
| 45 |
</div> |
| 46 |
</header> |
| 47 |
<div className={cx('wp-header-end', 'hidden')} /> |
| 48 |
|
| 49 |
<nav className={styles.tabsNav}> |
| 50 |
{Object.keys(tabs).map((tab) => ( |
| 51 |
<button |
| 52 |
key={tab} |
| 53 |
className={cx(styles.tabButton, activeTab === tab && styles.activeTab)} |
| 54 |
onClick={() => setActiveTab(tab as 'overview' | 'attendees')} |
| 55 |
> |
| 56 |
{tabs[tab]} |
| 57 |
</button> |
| 58 |
))} |
| 59 |
</nav> |
| 60 |
|
| 61 |
<div className={styles.pageContent}> |
| 62 |
{activeTab === 'attendees' ? ( |
| 63 |
<AttendeesSection /> |
| 64 |
) : ( |
| 65 |
<> |
| 66 |
<EventSection setUpdateErrors={setUpdateErrors} /> |
| 67 |
<TicketTypesSection /> |
| 68 |
<DonationFormsSection /> |
| 69 |
</> |
| 70 |
)} |
| 71 |
</div> |
| 72 |
</article> |
| 73 |
</> |
| 74 |
); |
| 75 |
} |
| 76 |
|