Skip to content

Conversation

@b-l-i-n-d
Copy link
Collaborator

@b-l-i-n-d b-l-i-n-d commented Dec 30, 2025

In this PR:

  • Make a dynamic review component with API integrations.
  • ✨ New StarRatingInput, StartRating components
  • InputField component bugfix
  • Button component icon-only variant

@b-l-i-n-d b-l-i-n-d added the 4.0.0 Tutor v4.w0w label Dec 30, 2025
@b-l-i-n-d b-l-i-n-d marked this pull request as draft December 30, 2025 07:39
@b-l-i-n-d b-l-i-n-d marked this pull request as ready for review January 1, 2026 10:50

export const initializeReviews = () => {
window.TutorComponentRegistry.registerAll({
components: [reviewCardMeta, reviewServicesMeta],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both will be initialized at the same time. I think it's best to keep everything inside one function. There are only 2 mutations.

Copy link
Collaborator Author

@b-l-i-n-d b-l-i-n-d Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both will be initialized at the same time, but they are not used in the same level of DOM structure. reviewServicesMeta is used at an upper level to update deleteModal without creating a new one for each review-card.

transition-property: background-color, border-color, opacity;
transition-duration: 0.2s;
transition-timing-function: ease-in-out;
@include tutor-transition((background-color, border-color, opacity));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why double bracket?

Copy link
Collaborator Author

@b-l-i-n-d b-l-i-n-d Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first parameter of the mixing, without brackets, it will be considered as three different parameters.

return $this;
}

/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can determine if icon only or not programmatically. No need to add prop support.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prop support is needed, as label will be used as aria-label for accessibility.

$content = self::POSITION_RIGHT === ( $this->icon_position ? $this->icon_position : self::POSITION_LEFT )
? sprintf( '%1$s%2$s', esc_html( $this->label ), $icon_html )
: sprintf( '%1$s%2$s', $icon_html, esc_html( $this->label ) );
if ( $this->icon_only ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary I guess.

Copy link
Collaborator Author

@b-l-i-n-d b-l-i-n-d Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When icon-only, we don't need to perform those checks; it's better to leave early when possible.

if ( ! defined( 'ABSPATH' ) ) {
exit;
}
use TUTOR\Icon;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we still working on demo components?

Copy link
Collaborator Author

@b-l-i-n-d b-l-i-n-d Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed demo component and created new StarRating component.

@submit.prevent="handleSubmit(
(data) => handleReviewSubmit(data),
(errors) => {
console.log('Form errors:', errors);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Display toast for errors.

Copy link
Collaborator Author

@b-l-i-n-d b-l-i-n-d Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was not intentional. Removing this since we are handling errors inside query.

<div class="tutor-review-rating">
<?php
tutor_load_template(
'demo-components.dashboard.components.star-rating',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why demo-components?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used newly created component.

->message( __( 'Are you sure you want to delete this review? Please confirm your choice.', 'tutor' ) )
->confirm_handler( 'handleDeleteReview(payload?.id)' )
->mutation_state( 'deleteReviewMutation' )
->confirm_button(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to provide confirm_button and cancel_button. the default should work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

</ul>
</div>
<?php endif; ?>
$converted_reviews = array_map(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to skip this. Update the review-card template accordingly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

return wpAjaxInstance.post(endpoints.PLACE_RATING, payload).then((res) => res.data);
},

convertFormDataToPayload(data: ReviewFormProps): ReviewPayload {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to skip this conversion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed as the payload does not match the input names.

'paged' => $current_page,
);

$pagination_template_frontend = tutor()->path . 'templates/dashboard/elements/pagination.php';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use pagination component.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the instructor design, which is not here yet. So, I kept the previous code as it was.

</table>
</div>
<?php else : ?>
<?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use empty state component

Copy link
Collaborator Author

@b-l-i-n-d b-l-i-n-d Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the instructor design, which is not here yet. So, I kept the previous code as it was.

<?php endif; ?>

<?php if ( $reviews->count ) : ?>
<div class="tutor-table-responsive">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this design?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

*
* @return $this
*/
public function error( $error ) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this method removed?

</span>
<?php endif; ?>

<?php if ( null !== $this->count ) : ?>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We write simply
if ( $this->count )

<?php endfor; ?>
</div>

<?php if ( $this->show_average || null !== $this->count ) : ?>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ( $this->show_average ||  $this->count )

*
* @var string
*/
protected $field_name = '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default name should be rating

*
* @var int
*/
protected $icon_size = 20;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use Size::SIZE_20

* @link https://themeum.com
* @since 4.0.0
*/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevent direct access

* @since 4.0.0
*/

use TUTOR\Icon;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this file changes. This is not part of this PR

@@ -1,87 +0,0 @@
<?php
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this file has been removed?

'learning-area' => 'Learning Area',
'user-profile' => 'User Profile',
'certificates' => 'Certificates',
'reviews' => 'Reviews',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not remove

@@ -1,27 +0,0 @@
<?php
/**
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not remove demo component now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0.0 Tutor v4.w0w

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants