|
9 | 9 | * @since 4.0.0 |
10 | 10 | */ |
11 | 11 |
|
| 12 | +use Tutor\Components\ConfirmationModal; |
12 | 13 | use Tutor\Components\Pagination; |
13 | 14 | use Tutor\Components\Sorting; |
14 | | -use TUTOR\Icon; |
15 | 15 | use TUTOR\Input; |
| 16 | +use TUTOR\User; |
16 | 17 |
|
17 | | -$is_instructor = tutor_utils()->is_instructor( null, true ); |
18 | | -$view_option = get_user_meta( get_current_user_id(), 'tutor_qa_view_as', true ); |
| 18 | +$user_id = get_current_user_id(); |
| 19 | +$is_instructor = tutor_utils()->is_instructor( $user_id, true ); |
| 20 | +$view_option = get_user_meta( $user_id, 'tutor_qa_view_as', true ); |
19 | 21 | $q_status = Input::get( 'data' ); |
20 | | -$view_as = $is_instructor ? ( $view_option ? $view_option : 'instructor' ) : 'student'; |
21 | | -$asker_id = 'instructor' === $view_as ? null : get_current_user_id(); |
| 22 | +$view_as = $is_instructor ? ( $view_option ? $view_option : User::VIEW_AS_INSTRUCTOR ) : User::VIEW_AS_STUDENT; |
| 23 | +$asker_id = User::VIEW_AS_INSTRUCTOR === $view_as ? null : $user_id; |
22 | 24 |
|
23 | 25 | $total_items = (int) tutor_utils()->get_qa_questions( $offset, $item_per_page, '', null, null, $asker_id, $q_status, true ); |
24 | 26 | $questions = tutor_utils()->get_qa_questions( $offset, $item_per_page, '', null, null, $asker_id, $q_status, false, array( 'order' => $order_filter ) ); |
|
55 | 57 | <?php endif; ?> |
56 | 58 | </div> |
57 | 59 |
|
58 | | -<?php if ( ! empty( $questions ) ) : ?> |
59 | | -<div x-data="tutorModal({ id: 'tutor-qna-delete-modal' })" x-cloak> |
60 | | - <template x-teleport="body"> |
61 | | - <div x-bind="getModalBindings()"> |
62 | | - <div x-bind="getBackdropBindings()"></div> |
63 | | - <div x-bind="getModalContentBindings()" style="max-width: 426px;"> |
64 | | - <button x-data="tutorIcon({ name: 'cross', width: 16, height: 16})", x-bind="getCloseButtonBindings()"></button> |
65 | | - |
66 | | - <div class="tutor-p-7 tutor-pt-10 tutor-flex tutor-flex-column tutor-items-center"> |
67 | | - <?php tutor_utils()->render_svg_icon( Icon::BIN, 100, 100 ); ?> |
68 | | - <h5 class="tutor-h5 tutor-font-medium tutor-mt-8"> |
69 | | - <?php esc_html_e( 'Delete This Question?', 'tutor' ); ?> |
70 | | - </h5> |
71 | | - <p class="tutor-p3 tutor-text-secondary tutor-mt-2 tutor-text-center"> |
72 | | - <?php esc_html_e( 'All the replies also will be deleted.', 'tutor' ); ?> |
73 | | - </p> |
74 | | - </div> |
75 | | - |
76 | | - <div class="tutor-modal-footer"> |
77 | | - <button class="tutor-btn tutor-btn-ghost tutor-btn-small" @click="TutorCore.modal.closeModal('tutor-qna-delete-modal')"> |
78 | | - <?php esc_html_e( 'Cancel', 'tutor' ); ?> |
79 | | - </button> |
80 | | - <button |
81 | | - class="tutor-btn tutor-btn-destructive tutor-btn-small" |
82 | | - :class="deleteQnAMutation?.isPending ? 'tutor-btn-loading' : ''" |
83 | | - @click="handleDeleteQnA(payload?.questionId)" |
84 | | - :disabled="deleteQnAMutation?.isPending" |
85 | | - > |
86 | | - <?php esc_html_e( 'Yes, Delete This', 'tutor' ); ?> |
87 | | - </button> |
88 | | - </div> |
89 | | - </div> |
90 | | - </div> |
91 | | - </template> |
92 | | -</div> |
93 | | -<?php endif; ?> |
| 60 | +<?php |
| 61 | +if ( ! empty( $questions ) ) { |
| 62 | + ConfirmationModal::make() |
| 63 | + ->id( 'tutor-qna-delete-modal' ) |
| 64 | + ->title( __( 'Delete This Question?', 'tutor' ) ) |
| 65 | + ->message( __( 'Are you sure you want to delete this question permanently? Please confirm your choice.', 'tutor' ) ) |
| 66 | + ->confirm_text( __( 'Yes, Delete This', 'tutor' ) ) |
| 67 | + ->confirm_handler( 'handleDeleteQnA(payload?.questionId)' ) |
| 68 | + ->mutation_state( 'deleteQnAMutation' ) |
| 69 | + ->render(); |
| 70 | +} |
| 71 | +?> |
0 commit comments