Skip to content

Commit

Permalink
refactor: set tickets label directly to the list component
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloiankoski committed Mar 21, 2024
1 parent 9b84325 commit 74f5ddf
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 56 deletions.
11 changes: 0 additions & 11 deletions src/EventTickets/Actions/EnqueueFormBuilderScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ public function __invoke()
'events' => $this->getEvents(),
'createEventUrl' => admin_url('edit.php?post_type=give_forms&page=give-event-tickets&new=event'),
'listEventsUrl' => admin_url('edit.php?post_type=give_forms&page=give-event-tickets'),
'ticketsLabel' => apply_filters(
'givewp_event_tickets_block/tickets_label',
__('Select Tickets', 'give')
),
'soldOutMessage' => apply_filters(
'givewp_event_tickets_block/sold_out_message',
__(
'Thank you for supporting our cause. Our fundraising event tickets are officially sold out. You can still contribute by making a donation.',
'give'
)
),
]
);

Expand Down
25 changes: 0 additions & 25 deletions src/EventTickets/Fields/EventTickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,4 @@ public function ticketTypes(array $ticketTypes): EventTickets
$this->ticketTypes = $ticketTypes;
return $this;
}

/**
* @since 3.6.0
*/
public function getTicketsLabel(): string
{
return apply_filters(
'givewp_event_tickets_block/tickets_label',
__('Select Tickets', 'give')
);
}

/**
* @since 3.6.0
*/
public function getSoldOutMessage(): string
{
return apply_filters(
'givewp_event_tickets_block/sold_out_message',
__(
'Thank you for supporting our cause. Our fundraising event tickets are officially sold out. You can still contribute by making a donation.',
'give'
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default function BlockPlaceholder({attributes}) {

<EventTicketsList
ticketTypes={event.ticketTypes}
ticketsLabel={ticketsLabel}
currency={currency}
currencyRate={1}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/EventTickets/resources/components/EventTicketsList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {__} from '@wordpress/i18n';
import EventTicketsListItem from './EventTicketsListItem';
import {EventTicketsListProps} from './types';

export default function EventTicketsList({
ticketTypes,
ticketsLabel,
currency,
currencyRate,
selectedTickets = [],
Expand All @@ -15,7 +15,7 @@ export default function EventTicketsList({

return (
<div className={'givewp-event-tickets__tickets'}>
<h4>{ticketsLabel}</h4>
<h4>{__('Select tickets', 'give')}</h4>
{ticketTypes.map((ticketType) => {
return (
<EventTicketsListItem
Expand Down
3 changes: 0 additions & 3 deletions src/EventTickets/resources/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export type Event = {
startDateTime: Date;
description: string;
ticketTypes: TicketType[];
ticketsLabel: string;
soldOutMessage: string;
};

export type TicketType = {
Expand All @@ -28,7 +26,6 @@ export type SelectedTicket = {

export type EventTicketsListProps = {
ticketTypes: TicketType[];
ticketsLabel: string;
currency: string;
currencyRate: number;
selectedTickets?: SelectedTicket[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useEffect, useState} from 'react';
import EventTicketsList from '../../components/EventTicketsList';
import {EventTicketsListHOCProps, OnSelectTicketProps} from './types';

export default function EventTicketsListHOC({name, ticketTypes, ticketsLabel}: EventTicketsListHOCProps) {
export default function EventTicketsListHOC({name, ticketTypes}: EventTicketsListHOCProps) {
const [selectedTickets, setSelectedTickets] = useState([]);
const {useWatch, useCurrencyFormatter, useDonationFormSettings, useDonationSummary, useFormContext} =
window.givewp.form.hooks;
Expand Down Expand Up @@ -69,7 +69,6 @@ export default function EventTicketsListHOC({name, ticketTypes, ticketsLabel}: E
return (
<EventTicketsList
ticketTypes={ticketTypes}
ticketsLabel={ticketsLabel}
currency={currency}
currencyRate={currencyRate}
selectedTickets={selectedTickets}
Expand Down
13 changes: 2 additions & 11 deletions src/EventTickets/resources/templates/EventTickets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,14 @@ import {Event} from '../../components/types';

import './styles.scss';

export default function EventTicketsField({
name,
id,
title,
startDateTime,
description,
ticketTypes,
ticketsLabel,
soldOutMessage,
}: Event) {
export default function EventTicketsField({name, title, startDateTime, description, ticketTypes}: Event) {
return (
<div className={'givewp-event-tickets'}>
<EventTicketsHeader title={title} startDateTime={new Date(startDateTime)} />

{description && <EventTicketsDescription description={description} />}

<EventTicketsListHOC name={name} ticketTypes={ticketTypes} ticketsLabel={ticketsLabel} />
<EventTicketsListHOC name={name} ticketTypes={ticketTypes} />
</div>
);
}
1 change: 0 additions & 1 deletion src/EventTickets/resources/templates/EventTickets/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {TicketType} from '../../components/types';
export type EventTicketsListHOCProps = {
name: string;
ticketTypes: TicketType[];
ticketsLabel: string;
};

export interface OnSelectTicketProps {
Expand Down

0 comments on commit 74f5ddf

Please sign in to comment.