Skip to content

Commit

Permalink
Merge pull request #525 from GatherPress/GP-524
Browse files Browse the repository at this point in the history
Change attend to no_status
  • Loading branch information
mauteri authored Feb 3, 2024
2 parents 3cc3738 + 4ced4d4 commit 1fe4ab2
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion build/blocks/events-list/events-list.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '102d9ce24cd27f5a1b3d');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'f7c3f6f593f30e15498a');
4 changes: 2 additions & 2 deletions build/blocks/events-list/events-list.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/events-list/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '7d75b0853ccb1fee0c70');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '93ccc8cad8799a601345');
4 changes: 2 additions & 2 deletions build/blocks/events-list/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/rsvp/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '44aa820ac177123b4c07');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '73fa6f8b6deb8ce18c34');
4 changes: 2 additions & 2 deletions build/blocks/rsvp/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/rsvp/rsvp.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '418c1d9e76bd3b408ccb');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '65433b4e1a5e00a44efb');
4 changes: 2 additions & 2 deletions build/blocks/rsvp/rsvp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion includes/core/classes/class-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ protected function events_list_route(): array {
* @return bool True if the parameter is a valid RSVP status, false otherwise.
*/
public function validate_rsvp_status( $param ): bool {
return ( 'attend' === $param || 'attending' === $param || 'not_attending' === $param );
return ( 'attending' === $param || 'not_attending' === $param || 'no_status' === $param );
}

/**
Expand Down
14 changes: 7 additions & 7 deletions includes/core/classes/class-rsvp.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ class Rsvp {
* An array of RSVP statuses.
*
* @since 1.0.0
* @var string[] Contains RSVP statuses such as 'attend', 'attending', 'not_attending', and 'waiting_list'.
* @var string[] Contains RSVP statuses such as 'attending', 'not_attending', 'waiting_list', and 'no_status'.
*/
public array $statuses = array(
'attend',
'attending',
'not_attending',
'waiting_list',
'no_status',
);

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ public function get( int $user_id ): array {
'post_id' => $event_id,
'user_id' => $user_id,
'timestamp' => null,
'status' => 'attend',
'status' => 'no_status',
'guests' => 0,
'anonymous' => 0,
);
Expand All @@ -136,7 +136,7 @@ public function get( int $user_id ): array {
* @param string $status RSVP status ('attending', 'not_attending', 'waiting_list').
* @param int $anonymous Indicates if the RSVP is anonymous (1 for anonymous, 0 for not anonymous).
* @param int $guests Number of guests accompanying the user.
* @return string The updated RSVP status ('attend', 'attending', 'not_attending', 'waiting_list').
* @return string The updated RSVP status ('attending', 'not_attending', 'waiting_list', 'no_status').
*/
public function save( int $user_id, string $status, int $anonymous = 0, int $guests = 0 ): string {
global $wpdb;
Expand Down Expand Up @@ -178,7 +178,7 @@ public function save( int $user_id, string $status, int $anonymous = 0, int $gue
// If not attending and anonymous, just remove record.
if ( 'not_attending' === $status && $anonymous ) {
$save = $wpdb->delete( $table, $where ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$status = 'attend'; // Set default status for UI.
$status = 'no_status'; // Set default status for UI.
} else {
$save = $wpdb->update( $table, $data, $where ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
}
Expand Down Expand Up @@ -309,8 +309,8 @@ public function responses(): array {
$all_guests = 0;
$statuses = $this->statuses;

// `attend` status is not relevant here.
$status_key = array_search( 'attend', $statuses, true );
// `no_status` status is not relevant here.
$status_key = array_search( 'no_status', $statuses, true );
unset( $statuses[ $status_key ] );
$statuses = array_values( $statuses );

Expand Down
4 changes: 2 additions & 2 deletions src/components/Rsvp.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const Rsvp = ({ eventId, currentUser = '', type, enableAnonymousRsvp }) => {
let buttonStatus = '';
let buttonLabel = '';

if ('not_attending' === status || 'attend' === status) {
if ('not_attending' === status || 'no_status' === status) {
buttonStatus = 'attending';
buttonLabel = __('Attend', 'gatherpress');
} else {
Expand Down Expand Up @@ -360,7 +360,7 @@ const Rsvp = ({ eventId, currentUser = '', type, enableAnonymousRsvp }) => {
)}
</Modal>
</ButtonGroup>
{'attend' !== rsvpStatus && (
{'no_status' !== rsvpStatus && (
<div className="gp-status">
<RsvpStatusResponse type={type} status={rsvpStatus} />

Expand Down
22 changes: 11 additions & 11 deletions src/components/RsvpStatusResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ import { __ } from '@wordpress/i18n';
*
* @since 1.0.0
*
* @param {Object} props - Component props.
* @param {string} [props.type='upcoming'] - The type of the event, either 'upcoming' or 'past'.
* @param {string} [props.status='attend'] - The RSVP status, such as 'attend', 'attending', 'waiting_list', or 'not_attending'.
* @param {Object} props - Component props.
* @param {string} [props.type='upcoming'] - The type of the event, either 'upcoming' or 'past'.
* @param {string} [props.status='no_status'] - The RSVP status, such as 'attending', 'waiting_list', 'not_attending', 'no_status'.
*
* @return {JSX.Element} The rendered React component.
*/
const RsvpStatusResponse = ({ type = 'upcoming', status = 'attend' }) => {
const RsvpStatusResponse = ({ type = 'upcoming', status = 'no_status' }) => {
const responses = {
upcoming: {
attend: {
icon: '',
text: '',
},
attending: {
icon: 'dashicons dashicons-yes-alt',
text: __('Attending', 'gatherpress'),
Expand All @@ -37,21 +33,25 @@ const RsvpStatusResponse = ({ type = 'upcoming', status = 'attend' }) => {
icon: 'dashicons dashicons-dismiss',
text: __('Not Attending', 'gatherpress'),
},
no_status: {
icon: '',
text: '',
},
},
past: {
attending: {
icon: 'dashicons dashicons-yes-alt',
text: __('Went', 'gatherpress'),
},
attend: {
waiting_list: {
icon: 'dashicons dashicons-dismiss',
text: __("Didn't Go", 'gatherpress'),
},
waiting_list: {
not_attending: {
icon: 'dashicons dashicons-dismiss',
text: __("Didn't Go", 'gatherpress'),
},
not_attending: {
no_status: {
icon: 'dashicons dashicons-dismiss',
text: __("Didn't Go", 'gatherpress'),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function test_validate_rsvp_status(): void {
'Failed to assert valid attendance status.'
);
$this->assertTrue(
$instance->validate_rsvp_status( 'attend' ),
$instance->validate_rsvp_status( 'no_status' ),
'Failed to assert valid attendance status.'
);
$this->assertFalse(
Expand Down

0 comments on commit 1fe4ab2

Please sign in to comment.