diff --git a/assets/src/js/frontend/dashboard/pages/settings.ts b/assets/src/js/frontend/dashboard/pages/settings.ts index d08863c31a..219863b3f9 100644 --- a/assets/src/js/frontend/dashboard/pages/settings.ts +++ b/assets/src/js/frontend/dashboard/pages/settings.ts @@ -63,6 +63,11 @@ interface PreferencesFormProps { auto_play_next: boolean; theme: string; font_scale: number; + formId?: string; +} + +interface UpdateNotificationProps { + [key: string]: boolean | string; } const settings = () => { @@ -100,7 +105,8 @@ const settings = () => { this.handleResetPassword = this.handleResetPassword.bind(this); this.handleUpdateNotification = this.query.useMutation(this.updateNotification, { - onSuccess: (data: TutorMutationResponse) => { + onSuccess: (data: TutorMutationResponse, payload: UpdateNotificationProps) => { + this.form.reset(payload?.formId as string, payload as unknown as Record); this.toast.success(data?.message ?? __('Notification settings updated', 'tutor')); }, onError: (error: Error) => { @@ -168,7 +174,8 @@ const settings = () => { }); this.savePreferencesMutation = this.query.useMutation(this.updatePreferences, { - onSuccess: (data: TutorMutationResponse) => { + onSuccess: (data: TutorMutationResponse, payload: PreferencesFormProps) => { + this.form.reset(payload?.formId || '', payload as unknown as Record); this.toast.success(data?.message ?? __('Preferences saved successfully', 'tutor')); }, onError: (error: Error) => { @@ -177,16 +184,22 @@ const settings = () => { }); }, - async updatePreferences(payload: Record) { + async updatePreferences(payload: PreferencesFormProps) { return wpAjaxInstance.post(endpoints.UPDATE_USER_PREFERENCES, payload) as unknown as Promise< TutorMutationResponse >; }, - async updateNotification(payload: Record) { + async updateNotification(payload: UpdateNotificationProps) { const transformedPayload = Object.keys(payload).reduce( (formattedPayload, key) => { const value = payload[key]; + + if (typeof value !== 'boolean') { + formattedPayload[`${key}`] = value; + return formattedPayload; + } + const stringValue = typeof value === 'boolean' ? (value ? 'on' : 'off') : value; if (!key.includes('__')) { diff --git a/assets/src/scss/frontend/dashboard/_progress-card.scss b/assets/src/scss/frontend/dashboard/_progress-card.scss index 5fb6466037..faef24214c 100644 --- a/assets/src/scss/frontend/dashboard/_progress-card.scss +++ b/assets/src/scss/frontend/dashboard/_progress-card.scss @@ -160,12 +160,15 @@ } &-actions { - display: none; - } - - &-footer { + position: static; display: block; + visibility: visible; + opacity: 1; padding: $tutor-spacing-6 $tutor-spacing-4 0; + + .tutor-btn { + width: 100%; + } } } } \ No newline at end of file diff --git a/assets/src/scss/frontend/dashboard/settings/_profile.scss b/assets/src/scss/frontend/dashboard/settings/_profile.scss index 7107a7b8d0..34bcd2f303 100644 --- a/assets/src/scss/frontend/dashboard/settings/_profile.scss +++ b/assets/src/scss/frontend/dashboard/settings/_profile.scss @@ -107,10 +107,6 @@ body:has(#wpadminbar) { } } - .tutor-profile-notification-content { - border-top: 1px solid $tutor-border-idle; - } - .tutor-profile-notification-toggle { display: flex; align-items: center; @@ -142,8 +138,4 @@ body:has(#wpadminbar) { .tutor-input-field { margin-bottom: 0px; } - - .tutor-profile-notification-content { - border-top: 1px solid $tutor-border-idle; - } } diff --git a/classes/Course.php b/classes/Course.php index 07daa1a258..4af8325d41 100644 --- a/classes/Course.php +++ b/classes/Course.php @@ -14,7 +14,6 @@ exit; } -use stdClass; use TUTOR\Input; use Tutor\Ecommerce\Tax; use Tutor\Models\QuizModel; @@ -23,7 +22,6 @@ use Tutor\Ecommerce\Ecommerce; use Tutor\Traits\JsonResponse; use Tutor\Helpers\ValidationHelper; -use TutorPro\CourseBundle\Models\BundleModel; /** * Course Class @@ -300,6 +298,8 @@ public function __construct( $register_hooks = true ) { add_filter( 'template_include', array( $this, 'handle_password_protected' ) ); add_action( 'login_form_postpass', array( $this, 'handle_password_submit' ) ); add_filter( 'the_preview', array( $this, 'handle_schedule_courses' ) ); + + add_action( 'tutor_course_action_btn', array( $this, 'render_course_action_btn' ) ); } /** @@ -3244,4 +3244,39 @@ private static function set_course_regular_and_sale_price( $post_ID, $regular_pr update_post_meta( $post_ID, self::COURSE_PRICE_META, $regular_price ); update_post_meta( $post_ID, self::COURSE_SALE_PRICE_META, $sale_price ); } + + /** + * Render start/resume button in enrolled course action btn. + * + * @since 4.0.0 + * + * @param int $course_id course id. + * + * @return void + */ + public function render_course_action_btn( int $course_id ) { + $is_completed = tutor_utils()->is_completed_course( $course_id ); + if ( $is_completed ) { + return; + } + + $course_progress = tutor_utils()->get_course_completed_percent( $course_id, 0, true ); + + $button_text = $course_progress['completed_percent'] > 0 ? __( 'Resume', 'tutor' ) : __( 'Start', 'tutor' ); + $button_url = tutor_utils()->get_course_first_lesson( $course_id ); + + if ( ! $button_url ) { + $button_url = get_the_permalink( $course_id ); + } + + ob_start(); + ?> + + + + })' - x-bind="getFormBindings()" - @submit="handleSubmit((data) => { savePreferencesMutation?.mutate(data); })($event)" + @submit="handleSubmit((data) => { savePreferencesMutation?.mutate({...data, formId: ''}); })($event)" >
diff --git a/templates/dashboard/courses/course-card.php b/templates/dashboard/courses/course-card.php index dee6e7305d..d9271be673 100644 --- a/templates/dashboard/courses/course-card.php +++ b/templates/dashboard/courses/course-card.php @@ -20,73 +20,77 @@ $category_names = is_array( $course_categories ) ? wp_list_pluck( $course_categories, 'name' ) : array(); $category = implode( ', ', $category_names ); +$course_learning_url = tutor_utils()->get_course_first_lesson(); +if ( get_post_type() !== tutor()->course_post_type ) { + $course_learning_url = get_permalink(); +} + ?> - -
- -
- - - <?php the_title(); ?> +
+
+ + + <?php the_title(); ?> + +
+ +
+ +
+ +
+ +
+

+ +

-
diff --git a/templates/dashboard/student-dashboard.php b/templates/dashboard/student-dashboard.php index e5176aea7e..d56c2d083b 100644 --- a/templates/dashboard/student-dashboard.php +++ b/templates/dashboard/student-dashboard.php @@ -250,14 +250,7 @@ class="tutor-btn tutor-btn-link tutor-btn-x-small tutor-text-brand tutor-p-none
- - - -
-