Skip to content

Commit 6c21745

Browse files
committed
Merge branch '4.0.0-dev' into v4-meeting
2 parents 91dcdf6 + aaf2770 commit 6c21745

File tree

33 files changed

+1032
-869
lines changed

33 files changed

+1032
-869
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
@use '../tokens' as *;
2+
@use '../mixins' as *;
3+
4+
.tutor-alert {
5+
@include tutor-flex(row, center, space-between);
6+
gap: $tutor-spacing-5;
7+
padding: $tutor-spacing-4;
8+
border-radius: $tutor-radius-sm;
9+
min-height: 48px;
10+
11+
.tutor-alert-content {
12+
@include tutor-flex(row, start);
13+
gap: $tutor-spacing-3;
14+
}
15+
16+
.tutor-alert-icon {
17+
flex-shrink: 0;
18+
display: flex;
19+
align-items: center;
20+
justify-content: center;
21+
color: $tutor-icon-idle;
22+
23+
svg {
24+
width: 20px;
25+
height: 20px;
26+
}
27+
}
28+
29+
.tutor-alert-text {
30+
@include tutor-typography('tiny', 'regular', 'secondary');
31+
}
32+
33+
.tutor-alert-action {
34+
flex-shrink: 0;
35+
}
36+
37+
&.tutor-alert-default {
38+
background-color: $tutor-surface-l1-hover;
39+
}
40+
41+
&.tutor-alert-info {
42+
background-color: $tutor-surface-brand-quaternary;
43+
}
44+
45+
&.tutor-alert-success {
46+
background-color: $tutor-surface-success;
47+
}
48+
49+
&.tutor-alert-warning {
50+
background-color: $tutor-surface-warning-hover;
51+
}
52+
53+
&.tutor-alert-error {
54+
background-color: $tutor-surface-critical;
55+
}
56+
}

assets/core/scss/components/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@forward 'accordion';
2+
@forward 'alert';
23
@forward 'button';
34
@forward 'card';
45
@forward 'input';

assets/core/scss/components/_toast.scss

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
height: 36px;
7272
@include tutor-flex(row, center, center);
7373
border-radius: $tutor-radius-full;
74-
color: $tutor-icon-idle-inverse;
7574
}
7675

7776
&-content {
@@ -98,14 +97,10 @@
9897

9998
// Type variants
10099
&-success {
101-
background-color: $tutor-actions-success-tertiary;
100+
background-color: $tutor-surface-success;
102101

103102
.tutor-toast-icon {
104-
background-color: $tutor-actions-success-primary;
105-
box-shadow:
106-
0px 0px 0px 2px #36cf4224,
107-
0px 1px 2px 0px #1018280f,
108-
0px 1px 3px 0px #1018281a;
103+
background-color: $tutor-icon-success-primary;
109104
}
110105

111106
.tutor-toast-title {
@@ -114,14 +109,10 @@
114109
}
115110

116111
&-warning {
117-
background-color: $tutor-actions-warning-tertiary;
112+
background-color: $tutor-surface-warning;
118113

119114
.tutor-toast-icon {
120-
background-color: $tutor-button-caution;
121-
box-shadow:
122-
0px 0px 0px 2px #dee52624,
123-
0px 1px 2px 0px #1018280f,
124-
0px 1px 3px 0px #1018281a;
115+
background-color: $tutor-icon-caution;
125116
}
126117

127118
.tutor-toast-title {
@@ -130,13 +121,10 @@
130121
}
131122

132123
&-error {
133-
background-color: $tutor-button-destructive-soft;
124+
background-color: $tutor-surface-critical;
134125

135126
.tutor-toast-icon {
136-
background-color: $tutor-button-destructive;
137-
box-shadow:
138-
0px 0px 0px 2px #f044383d,
139-
0px 1px 2px 0px #1018280d;
127+
background-color: $tutor-icon-critical;
140128
}
141129

142130
.tutor-toast-title {
@@ -145,11 +133,10 @@
145133
}
146134

147135
&-info {
148-
background-color: $tutor-button-primary-soft-focused;
136+
background-color: $tutor-surface-brand-quaternary;
149137

150138
.tutor-toast-icon {
151-
background-color: $tutor-surface-brand-primary;
152-
box-shadow: 0px 0px 0px 2px #90a0f7;
139+
background-color: $tutor-icon-brand;
153140
}
154141

155142
.tutor-toast-title {

assets/core/scss/themes/_dark.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
--tutor-text-success: #{$tutor-success-600};
4444
--tutor-text-critical: #{$tutor-error-600};
4545
--tutor-text-warning: #{$tutor-warning-600};
46-
--tutor-text-caution: #{$tutor-brand-600};
46+
--tutor-text-caution: #{$tutor-yellow-600};
4747
--tutor-text-exception1: #{$tutor-exception-1};
4848
--tutor-text-exception2: #{$tutor-exception-2};
4949
--tutor-text-exception4: #{$tutor-warning-400};

assets/icons/warning-line.svg

Lines changed: 9 additions & 0 deletions
Loading

assets/src/js/frontend/dashboard/header.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { type MutationState } from '@Core/ts/services/Query';
22
import { type AjaxResponse } from '@FrontendTypes/index';
3+
import { tutorConfig } from '@TutorShared/config/config';
34
import { wpAjaxInstance } from '@TutorShared/utils/api';
45
import { convertToErrorMessage } from '@TutorShared/utils/util';
56

@@ -16,7 +17,7 @@ const header = () => {
1617
onSuccess: (res: AjaxResponse) => {
1718
window.TutorCore.toast.success(res?.message);
1819
setTimeout(() => {
19-
window.location.reload();
20+
window.location.href = tutorConfig.tutor_frontend_dashboard_url;
2021
}, 1000);
2122
},
2223
onError: (error: Error) => {

assets/src/js/frontend/learning-area/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import { initializeAssignmentView } from './pages/assignment-view';
55
import { initializeCoursePlayer } from './pages/course-player';
66
import { initializeLessonContent } from './pages/lesson-content';
7+
import { initializeQna } from './pages/qna';
78
import { initializeQuizInterface } from './pages/quiz';
89

910
const initializeLearningArea = () => {
@@ -23,6 +24,9 @@ const initializeLearningArea = () => {
2324
case 'assignment-view':
2425
initializeAssignmentView();
2526
break;
27+
case 'qna':
28+
initializeQna();
29+
break;
2630
default:
2731
// eslint-disable-next-line no-console
2832
console.warn('Unknown learning area page:', currentPage);
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { type MutationState } from '@Core/ts/services/Query';
2+
import { wpAjaxInstance } from '@TutorShared/utils/api';
3+
import endpoints from '@TutorShared/utils/endpoints';
4+
import { convertToErrorMessage } from '@TutorShared/utils/util';
5+
import { __ } from '@wordpress/i18n';
6+
7+
interface CreateQnaPayload {
8+
course_id: number;
9+
question: string;
10+
}
11+
12+
interface ReplyQnaPayload {
13+
course_id: number;
14+
question_id: number;
15+
answer: string;
16+
}
17+
18+
interface DeleteQnaPayload {
19+
question_id: number;
20+
context: string;
21+
}
22+
23+
/**
24+
* Q&A Page Component
25+
* Handles Q&A related action in learning area
26+
*/
27+
const qnaPage = () => {
28+
const query = window.TutorCore.query;
29+
30+
return {
31+
query,
32+
createQnaMutation: null as MutationState<unknown, CreateQnaPayload> | null,
33+
replyQnaMutation: null as MutationState<unknown, ReplyQnaPayload> | null,
34+
deleteQnaMutation: null as MutationState<unknown, unknown> | null,
35+
focused: false,
36+
37+
init() {
38+
this.createQnaMutation = this.query.useMutation(this.createQnA, {
39+
onSuccess: () => {
40+
window.TutorCore.toast.success(__('Question saved successfully', 'tutor'));
41+
window.location.reload();
42+
},
43+
onError: (error: Error) => {
44+
window.TutorCore.toast.error(convertToErrorMessage(error));
45+
},
46+
});
47+
48+
this.replyQnaMutation = this.query.useMutation(this.replyQna, {
49+
onSuccess: () => {
50+
window.TutorCore.toast.success(__('Reply saved successfully', 'tutor'));
51+
window.location.reload();
52+
},
53+
onError: (error: Error) => {
54+
window.TutorCore.toast.error(convertToErrorMessage(error));
55+
},
56+
});
57+
58+
this.deleteQnaMutation = this.query.useMutation(this.deleteQnA, {
59+
onSuccess: (result, payload) => {
60+
if (payload?.context === 'question') {
61+
window.TutorCore.toast.success(__('Question deleted successfully', 'tutor'));
62+
const url = new URL(window.location.href);
63+
url.searchParams.delete('question_id');
64+
window.location.href = url.toString();
65+
} else if (payload?.context === 'reply') {
66+
window.TutorCore.toast.success(__('Reply deleted successfully', 'tutor'));
67+
window.location.reload();
68+
} else {
69+
window.location.reload();
70+
}
71+
},
72+
onError: (error: Error) => {
73+
window.TutorCore.toast.error(convertToErrorMessage(error));
74+
},
75+
});
76+
},
77+
78+
createQnA(payload: CreateQnaPayload) {
79+
return wpAjaxInstance.post(endpoints.CREATE_UPDATE_QNA, payload);
80+
},
81+
82+
replyQna(payload: ReplyQnaPayload) {
83+
return wpAjaxInstance.post(endpoints.CREATE_UPDATE_QNA, payload);
84+
},
85+
86+
deleteQnA(payload: DeleteQnaPayload) {
87+
return wpAjaxInstance.post(endpoints.DELETE_DASHBOARD_QNA, payload);
88+
},
89+
};
90+
};
91+
92+
export const initializeQna = () => {
93+
window.TutorComponentRegistry.register({
94+
type: 'component',
95+
meta: {
96+
name: 'qna',
97+
component: qnaPage,
98+
},
99+
});
100+
window.TutorComponentRegistry.initWithAlpine(window.Alpine);
101+
};

assets/src/js/v3/shared/icons/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ export const icons = [
367367
'vimeo',
368368
'visited',
369369
'warning',
370+
'warningLine',
370371
'weightBox',
371372
'wifi',
372373
'wishlist',

assets/src/scss/frontend/components/_discussion-card.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
.tutor-discussion-card-bookmark {
5353
position: absolute;
54-
top: -3px;
54+
top: -4px;
5555
inset-inline-end: $tutor-spacing-5;
5656
color: $tutor-icon-exception4;
5757
}

0 commit comments

Comments
 (0)