@magmamath/students-features 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js +21 -5
- package/dist/commonjs/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/commonjs/features/feedback/components/EmptyComment/EmptyComment.js +2 -2
- package/dist/commonjs/features/feedback/components/EmptyComment/EmptyComment.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedback.js +12 -5
- package/dist/commonjs/features/feedback/components/TeacherFeedback.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +65 -16
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.js +17 -0
- package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +7 -3
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js +16 -5
- package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js.map +1 -1
- package/dist/commonjs/features/feedback/components/UnreadMessagesBadge.js +3 -2
- package/dist/commonjs/features/feedback/components/UnreadMessagesBadge.js.map +1 -1
- package/dist/commonjs/features/feedback/constants.js +24 -5
- package/dist/commonjs/features/feedback/constants.js.map +1 -1
- package/dist/commonjs/features/feedback/index.js +11 -0
- package/dist/commonjs/features/feedback/index.js.map +1 -1
- package/dist/commonjs/features/feedback/model/teacherFeedback.model.js +97 -34
- package/dist/commonjs/features/feedback/model/teacherFeedback.model.js.map +1 -1
- package/dist/commonjs/features/feedback/types/teacherFeedback.types.js.map +1 -1
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js +22 -6
- package/dist/module/features/chatbot/components/ChatControls/ChatControls.js.map +1 -1
- package/dist/module/features/feedback/components/EmptyComment/EmptyComment.js +3 -3
- package/dist/module/features/feedback/components/EmptyComment/EmptyComment.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedback.js +12 -5
- package/dist/module/features/feedback/components/TeacherFeedback.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +65 -16
- package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.js +17 -0
- package/dist/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +8 -4
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js +17 -6
- package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js.map +1 -1
- package/dist/module/features/feedback/components/UnreadMessagesBadge.js +3 -2
- package/dist/module/features/feedback/components/UnreadMessagesBadge.js.map +1 -1
- package/dist/module/features/feedback/constants.js +23 -4
- package/dist/module/features/feedback/constants.js.map +1 -1
- package/dist/module/features/feedback/index.js +1 -0
- package/dist/module/features/feedback/index.js.map +1 -1
- package/dist/module/features/feedback/model/teacherFeedback.model.js +97 -34
- package/dist/module/features/feedback/model/teacherFeedback.model.js.map +1 -1
- package/dist/module/features/feedback/types/teacherFeedback.types.js.map +1 -1
- package/dist/typescript/commonjs/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedback.d.ts +4 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedback.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts +4 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts +17 -0
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts +2 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts +3 -1
- package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/components/UnreadMessagesBadge.d.ts +3 -2
- package/dist/typescript/commonjs/features/feedback/components/UnreadMessagesBadge.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/constants.d.ts +15 -3
- package/dist/typescript/commonjs/features/feedback/constants.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/index.d.ts +1 -0
- package/dist/typescript/commonjs/features/feedback/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/model/teacherFeedback.model.d.ts +6 -5
- package/dist/typescript/commonjs/features/feedback/model/teacherFeedback.model.d.ts.map +1 -1
- package/dist/typescript/commonjs/features/feedback/types/teacherFeedback.types.d.ts +6 -0
- package/dist/typescript/commonjs/features/feedback/types/teacherFeedback.types.d.ts.map +1 -1
- package/dist/typescript/module/features/chatbot/components/ChatControls/ChatControls.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedback.d.ts +4 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedback.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts +4 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts +17 -0
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/colorSchemes.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts +2 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts +3 -1
- package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/components/UnreadMessagesBadge.d.ts +3 -2
- package/dist/typescript/module/features/feedback/components/UnreadMessagesBadge.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/constants.d.ts +15 -3
- package/dist/typescript/module/features/feedback/constants.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/index.d.ts +1 -0
- package/dist/typescript/module/features/feedback/index.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/model/teacherFeedback.model.d.ts +6 -5
- package/dist/typescript/module/features/feedback/model/teacherFeedback.model.d.ts.map +1 -1
- package/dist/typescript/module/features/feedback/types/teacherFeedback.types.d.ts +6 -0
- package/dist/typescript/module/features/feedback/types/teacherFeedback.types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/features/chatbot/components/ChatControls/ChatControls.tsx +27 -4
- package/src/features/feedback/components/EmptyComment/EmptyComment.tsx +3 -3
- package/src/features/feedback/components/TeacherFeedback.tsx +10 -4
- package/src/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.tsx +71 -13
- package/src/features/feedback/components/TeacherFeedbackButton/colorSchemes.ts +17 -0
- package/src/features/feedback/components/TeacherFeedbackComments/TeacherComment.tsx +6 -5
- package/src/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.tsx +24 -4
- package/src/features/feedback/components/UnreadMessagesBadge.tsx +4 -3
- package/src/features/feedback/constants.ts +25 -5
- package/src/features/feedback/index.ts +1 -0
- package/src/features/feedback/model/teacherFeedback.model.ts +125 -47
- package/src/features/feedback/types/teacherFeedback.types.ts +5 -0
|
@@ -4,32 +4,38 @@ import { View, StyleSheet } from 'react-native'
|
|
|
4
4
|
import { TeacherFeedbackButton } from './TeacherFeedbackButton/TeacherFeedbackButton'
|
|
5
5
|
import { TeacherFeedbackComments } from './TeacherFeedbackComments/TeacherFeedbackComments'
|
|
6
6
|
import { TeacherFeedbackModel } from '../model/teacherFeedback.model'
|
|
7
|
+
import { FeedbackButtonColors, FeedbackButtonSize, FeedbackMode } from '../constants'
|
|
7
8
|
|
|
8
9
|
type TeacherFeedbackProps = {
|
|
9
10
|
model: TeacherFeedbackModel
|
|
11
|
+
mode: FeedbackMode
|
|
12
|
+
isExam: boolean
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
export const TeacherFeedback = ({ model }: TeacherFeedbackProps) => {
|
|
15
|
+
export const TeacherFeedback = ({ model, mode, isExam = false }: TeacherFeedbackProps) => {
|
|
13
16
|
const isOpen = useUnit(model.$isOpened)
|
|
17
|
+
const assignmentId = useUnit(model.$assignmentId)
|
|
14
18
|
const problemId = useUnit(model.$currentProblemId)
|
|
15
19
|
const locale = useUnit(model.$locale)
|
|
16
20
|
const isLoading = useUnit(model.getCommentsByAssignmentIdFx.pending)
|
|
17
21
|
const teacherFeedback = useStoreMap({
|
|
18
22
|
store: model.$comments,
|
|
19
|
-
fn: (feedback, [problemId]) => feedback.get(problemId
|
|
20
|
-
keys: [problemId],
|
|
23
|
+
fn: (feedback, [assignmentId, problemId]) => feedback.get(assignmentId)?.[problemId] ?? null,
|
|
24
|
+
keys: [assignmentId, problemId],
|
|
21
25
|
})
|
|
22
26
|
|
|
23
27
|
if (!problemId || !teacherFeedback) return null
|
|
24
28
|
|
|
25
29
|
return (
|
|
26
30
|
<View style={styles.container}>
|
|
27
|
-
{isOpen && <TeacherFeedbackComments comments={teacherFeedback.comments} locale={locale} />}
|
|
31
|
+
{isOpen && <TeacherFeedbackComments comments={teacherFeedback.comments} locale={locale} mode={mode} />}
|
|
28
32
|
<TeacherFeedbackButton
|
|
29
33
|
onPress={() => model.setIsOpened(!isOpen)}
|
|
30
34
|
unreadCommentsCount={teacherFeedback.unreadMessagesCount}
|
|
31
35
|
isOpen={isOpen}
|
|
32
36
|
isLoading={isLoading}
|
|
37
|
+
size={mode === FeedbackMode.NORMAL ? FeedbackButtonSize.SMALL : FeedbackButtonSize.LARGE}
|
|
38
|
+
color={isExam ? FeedbackButtonColors.PURPLE : FeedbackButtonColors.BLUE}
|
|
33
39
|
/>
|
|
34
40
|
</View>
|
|
35
41
|
)
|
|
@@ -5,58 +5,84 @@ import { UnreadMessagesBadge } from '../UnreadMessagesBadge'
|
|
|
5
5
|
import { MessageBubbleIcon } from '../icons/MessageBubbleIcon'
|
|
6
6
|
import { XCloseIcon } from '../icons/XCloseIcon'
|
|
7
7
|
import { COLOR_SCHEMES } from './colorSchemes'
|
|
8
|
+
import { FeedbackButtonColors, FeedbackButtonSize, TEACHER_FEEDBACK_BUTTON_ID } from '../../constants'
|
|
9
|
+
|
|
10
|
+
const ICON_SIZES = {
|
|
11
|
+
[FeedbackButtonSize.LARGE]: 37,
|
|
12
|
+
[FeedbackButtonSize.SMALL]: 26
|
|
13
|
+
}
|
|
8
14
|
|
|
9
15
|
type TeacherFeedbackButtonProps = {
|
|
10
16
|
isOpen: boolean
|
|
11
17
|
isLoading: boolean
|
|
12
18
|
onPress?: () => void
|
|
13
19
|
unreadCommentsCount?: number
|
|
20
|
+
size?: FeedbackButtonSize
|
|
21
|
+
color?: FeedbackButtonColors
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
export const TeacherFeedbackButton = ({
|
|
17
25
|
isOpen,
|
|
18
26
|
onPress,
|
|
19
|
-
unreadCommentsCount,
|
|
27
|
+
// unreadCommentsCount,
|
|
20
28
|
isLoading,
|
|
29
|
+
size = FeedbackButtonSize.LARGE,
|
|
30
|
+
color = FeedbackButtonColors.BLUE,
|
|
21
31
|
}: TeacherFeedbackButtonProps) => {
|
|
32
|
+
|
|
33
|
+
const unreadCommentsCount = 5
|
|
34
|
+
const isLarge = size === FeedbackButtonSize.LARGE
|
|
35
|
+
const isPurpleColor = color === FeedbackButtonColors.PURPLE
|
|
36
|
+
|
|
22
37
|
if (isOpen) {
|
|
23
38
|
return (
|
|
24
39
|
<Button
|
|
25
|
-
|
|
40
|
+
id={TEACHER_FEEDBACK_BUTTON_ID}
|
|
26
41
|
onPress={onPress}
|
|
27
42
|
size='large'
|
|
28
43
|
variant='primary'
|
|
29
44
|
disabled={isLoading}
|
|
30
45
|
isLoading={isLoading}
|
|
31
46
|
style={{
|
|
32
|
-
container: styles.container,
|
|
33
|
-
button: [styles.button, { borderColor: COLORS.NEUTRAL_5 }],
|
|
47
|
+
container: isLarge ? styles.containerLarge : styles.container,
|
|
48
|
+
button: [styles.button, { borderColor: COLORS.NEUTRAL_5 }, styles[size]],
|
|
34
49
|
}}
|
|
35
50
|
customColorScheme={COLOR_SCHEMES.GREY}
|
|
36
|
-
icon={<XCloseIcon />}
|
|
51
|
+
icon={<XCloseIcon size={ICON_SIZES[size]} />}
|
|
37
52
|
/>
|
|
38
53
|
)
|
|
39
54
|
}
|
|
40
55
|
|
|
41
56
|
return (
|
|
42
57
|
<Button
|
|
43
|
-
|
|
58
|
+
id={TEACHER_FEEDBACK_BUTTON_ID}
|
|
44
59
|
onPress={onPress}
|
|
45
60
|
size='large'
|
|
46
61
|
variant='primary'
|
|
47
62
|
disabled={isLoading}
|
|
48
63
|
isLoading={isLoading}
|
|
49
64
|
style={{
|
|
50
|
-
container: styles.container,
|
|
51
|
-
button: [
|
|
65
|
+
container: isLarge ? styles.containerLarge : styles.container,
|
|
66
|
+
button: [
|
|
67
|
+
styles.button,
|
|
68
|
+
{ borderColor: !!unreadCommentsCount ? (isPurpleColor ? COLORS.PURPLE_6 : COLORS.BLUE_6) : COLORS.NEUTRAL_5 },
|
|
69
|
+
styles[size],
|
|
70
|
+
],
|
|
52
71
|
}}
|
|
53
|
-
customColorScheme={!!unreadCommentsCount ? COLOR_SCHEMES.BLUE : COLOR_SCHEMES.GREY}
|
|
72
|
+
customColorScheme={!!unreadCommentsCount ? (isPurpleColor ? COLOR_SCHEMES.PURPLE : COLOR_SCHEMES.BLUE) : COLOR_SCHEMES.GREY}
|
|
54
73
|
icon={
|
|
55
74
|
<View style={styles.iconContainer}>
|
|
56
|
-
<MessageBubbleIcon
|
|
75
|
+
<MessageBubbleIcon
|
|
76
|
+
color={!!unreadCommentsCount ? COLORS.NEUTRAL_1 : COLORS.NEUTRAL_9}
|
|
77
|
+
size={ICON_SIZES[size]}
|
|
78
|
+
/>
|
|
57
79
|
{!!unreadCommentsCount && (
|
|
58
|
-
<View style={styles.badgeContainer}>
|
|
59
|
-
<UnreadMessagesBadge
|
|
80
|
+
<View style={isLarge ? styles.badgeContainerLarge : styles.badgeContainer}>
|
|
81
|
+
<UnreadMessagesBadge
|
|
82
|
+
badgeContent={unreadCommentsCount}
|
|
83
|
+
textStyle={isLarge && styles.textLarge}
|
|
84
|
+
style={isLarge && styles.badgeLarge}
|
|
85
|
+
/>
|
|
60
86
|
</View>
|
|
61
87
|
)}
|
|
62
88
|
</View>
|
|
@@ -70,17 +96,49 @@ const styles = StyleSheet.create({
|
|
|
70
96
|
width: 54,
|
|
71
97
|
height: 54,
|
|
72
98
|
},
|
|
73
|
-
|
|
99
|
+
containerLarge: {
|
|
100
|
+
width: 80,
|
|
101
|
+
height: 80,
|
|
102
|
+
},
|
|
103
|
+
[FeedbackButtonSize.SMALL]: {
|
|
74
104
|
width: 50,
|
|
75
105
|
height: 50,
|
|
106
|
+
},
|
|
107
|
+
[FeedbackButtonSize.LARGE]: {
|
|
108
|
+
width: 75,
|
|
109
|
+
height: 75,
|
|
110
|
+
},
|
|
111
|
+
button: {
|
|
112
|
+
borderWidth: 2,
|
|
113
|
+
},
|
|
114
|
+
buttonLarge: {
|
|
115
|
+
width: 75,
|
|
116
|
+
height: 75,
|
|
76
117
|
borderWidth: 2,
|
|
77
118
|
},
|
|
78
119
|
iconContainer: {
|
|
79
120
|
position: 'relative',
|
|
80
121
|
},
|
|
122
|
+
badgeContainerLarge: {
|
|
123
|
+
position: 'absolute',
|
|
124
|
+
top: -24,
|
|
125
|
+
right: -24,
|
|
126
|
+
},
|
|
81
127
|
badgeContainer: {
|
|
82
128
|
position: 'absolute',
|
|
83
129
|
top: -17,
|
|
84
130
|
right: -17,
|
|
85
131
|
},
|
|
132
|
+
textLarge: {
|
|
133
|
+
fontSize: 18,
|
|
134
|
+
lineHeight: 0,
|
|
135
|
+
textAlign: 'center',
|
|
136
|
+
alignItems: 'center',
|
|
137
|
+
justifyContent: 'center',
|
|
138
|
+
},
|
|
139
|
+
badgeLarge: {
|
|
140
|
+
width: 32,
|
|
141
|
+
height: 32,
|
|
142
|
+
borderRadius: 16,
|
|
143
|
+
}
|
|
86
144
|
})
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { ButtonStates, COLORS } from '@magmamath/react-native-ui'
|
|
2
2
|
|
|
3
3
|
export const COLOR_SCHEMES = {
|
|
4
|
+
PURPLE: {
|
|
5
|
+
[ButtonStates.DEFAULT]: {
|
|
6
|
+
borderColor: COLORS.PURPLE_6,
|
|
7
|
+
raiseColor: COLORS.PURPLE_6,
|
|
8
|
+
backgroundColor: COLORS.PRIMARY_PURPLE,
|
|
9
|
+
},
|
|
10
|
+
[ButtonStates.PRESSED]: {
|
|
11
|
+
borderColor: COLORS.PURPLE_6,
|
|
12
|
+
raiseColor: COLORS.PURPLE_6,
|
|
13
|
+
backgroundColor: COLORS.PRIMARY_PURPLE,
|
|
14
|
+
},
|
|
15
|
+
[ButtonStates.HOVER]: {
|
|
16
|
+
borderColor: COLORS.PURPLE_6,
|
|
17
|
+
raiseColor: COLORS.PURPLE_6,
|
|
18
|
+
backgroundColor: COLORS.PRIMARY_PURPLE,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
4
21
|
BLUE: {
|
|
5
22
|
[ButtonStates.DEFAULT]: {
|
|
6
23
|
borderColor: COLORS.BLUE_6,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { View, Text, StyleSheet
|
|
2
|
+
import { View, Text, StyleSheet } from 'react-native'
|
|
3
3
|
import { COLORS } from '@magmamath/react-native-ui'
|
|
4
4
|
import { getRelativeTime } from '../../helpers'
|
|
5
5
|
import { BUENOS_AIRES_FONT } from '../../constants'
|
|
@@ -10,11 +10,12 @@ type TeacherCommentProps = {
|
|
|
10
10
|
teacherName: string
|
|
11
11
|
createdAt: Date
|
|
12
12
|
locale: Locale | null
|
|
13
|
+
isLastComment: boolean
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
export const TeacherComment = ({ content, teacherName, createdAt, locale }: TeacherCommentProps) => {
|
|
16
|
+
export const TeacherComment = ({ content, teacherName, createdAt, locale, isLastComment }: TeacherCommentProps) => {
|
|
16
17
|
return (
|
|
17
|
-
|
|
18
|
+
<View style={{ marginBottom: isLastComment ? 8 : 0 }}>
|
|
18
19
|
<View style={styles.authorInfo}>
|
|
19
20
|
<Text style={styles.teacherName} numberOfLines={1}>
|
|
20
21
|
{teacherName}
|
|
@@ -28,7 +29,7 @@ export const TeacherComment = ({ content, teacherName, createdAt, locale }: Teac
|
|
|
28
29
|
<View style={styles.container}>
|
|
29
30
|
<Text style={styles.text}>{content}</Text>
|
|
30
31
|
</View>
|
|
31
|
-
|
|
32
|
+
</View>
|
|
32
33
|
)
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -39,7 +40,7 @@ const styles = StyleSheet.create({
|
|
|
39
40
|
borderTopLeftRadius: 8,
|
|
40
41
|
borderTopRightRadius: 8,
|
|
41
42
|
borderBottomRightRadius: 8,
|
|
42
|
-
shadowColor: COLORS.
|
|
43
|
+
shadowColor: COLORS.NEUTRAL_10,
|
|
43
44
|
shadowOffset: { width: 0, height: 1 },
|
|
44
45
|
shadowOpacity: 0.25,
|
|
45
46
|
shadowRadius: 3,
|
package/src/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.tsx
CHANGED
|
@@ -3,20 +3,28 @@ import { Platform, ScrollView, StyleSheet, useWindowDimensions, View } from 'rea
|
|
|
3
3
|
import { Locale, TeacherComment as FeedbackComment } from '../../types/teacherFeedback.types'
|
|
4
4
|
import { TeacherComment } from './TeacherComment'
|
|
5
5
|
import { EmptyComment } from '../EmptyComment/EmptyComment'
|
|
6
|
-
import { EMPTY_COMMENT_ID } from '../../constants'
|
|
6
|
+
import { EMPTY_COMMENT_ID, FeedbackMode } from '../../constants'
|
|
7
|
+
import { COLORS } from '@magmamath/react-native-ui'
|
|
7
8
|
|
|
8
9
|
const TOOLBAR_HEIGHT = 140
|
|
9
10
|
const BOTTOM_OFFSET = Platform.OS === 'web' ? 270 : 304
|
|
11
|
+
const SIMPLE_MODE_OFFSET = 70
|
|
10
12
|
|
|
11
13
|
type TeacherFeedbackCommentsProps = {
|
|
12
14
|
comments: FeedbackComment[] | null
|
|
13
15
|
locale: Locale | null
|
|
16
|
+
mode: FeedbackMode
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
export const TeacherFeedbackComments = ({
|
|
19
|
+
export const TeacherFeedbackComments = ({
|
|
20
|
+
comments,
|
|
21
|
+
locale,
|
|
22
|
+
mode,
|
|
23
|
+
}: TeacherFeedbackCommentsProps) => {
|
|
17
24
|
const ref = useRef<ScrollView | null>(null)
|
|
18
25
|
const dimensions = useWindowDimensions()
|
|
19
26
|
const MAX_HEIGHT = dimensions.height - TOOLBAR_HEIGHT - BOTTOM_OFFSET
|
|
27
|
+
const isSimpleMode = mode === FeedbackMode.SIMPLE
|
|
20
28
|
|
|
21
29
|
useEffect(() => {
|
|
22
30
|
ref.current?.scrollToEnd({ animated: false })
|
|
@@ -25,7 +33,12 @@ export const TeacherFeedbackComments = ({ comments, locale }: TeacherFeedbackCom
|
|
|
25
33
|
if (!comments) return null
|
|
26
34
|
|
|
27
35
|
return (
|
|
28
|
-
<View
|
|
36
|
+
<View
|
|
37
|
+
style={[
|
|
38
|
+
styles.container,
|
|
39
|
+
{ maxHeight: MAX_HEIGHT - (isSimpleMode ? SIMPLE_MODE_OFFSET : 0) },
|
|
40
|
+
]}
|
|
41
|
+
>
|
|
29
42
|
<ScrollView
|
|
30
43
|
ref={ref}
|
|
31
44
|
contentContainerStyle={styles.commentsList}
|
|
@@ -34,13 +47,14 @@ export const TeacherFeedbackComments = ({ comments, locale }: TeacherFeedbackCom
|
|
|
34
47
|
{comments.length === 1 && comments[0]._id === EMPTY_COMMENT_ID ? (
|
|
35
48
|
<EmptyComment locale={locale} />
|
|
36
49
|
) : (
|
|
37
|
-
comments.map((comment) => (
|
|
50
|
+
comments.map((comment, index) => (
|
|
38
51
|
<TeacherComment
|
|
39
52
|
key={comment._id}
|
|
40
53
|
teacherName={comment.teacherName}
|
|
41
54
|
content={comment.content}
|
|
42
55
|
createdAt={comment.createdAt}
|
|
43
56
|
locale={locale}
|
|
57
|
+
isLastComment={index === comments.length - 1}
|
|
44
58
|
/>
|
|
45
59
|
))
|
|
46
60
|
)}
|
|
@@ -52,6 +66,12 @@ export const TeacherFeedbackComments = ({ comments, locale }: TeacherFeedbackCom
|
|
|
52
66
|
const styles = StyleSheet.create({
|
|
53
67
|
container: {
|
|
54
68
|
width: 368,
|
|
69
|
+
backgroundColor: COLORS.NEUTRAL_1,
|
|
70
|
+
paddingTop: 8,
|
|
71
|
+
paddingLeft: 8,
|
|
72
|
+
paddingRight: 8,
|
|
73
|
+
paddingBottom: 0,
|
|
74
|
+
borderRadius: 8,
|
|
55
75
|
},
|
|
56
76
|
commentsList: {
|
|
57
77
|
gap: 8,
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { Text, View, StyleSheet, Platform, StyleProp, ViewStyle } from 'react-native'
|
|
2
|
+
import { Text, View, StyleSheet, Platform, StyleProp, ViewStyle, TextStyle } from 'react-native'
|
|
3
3
|
import { COLORS } from '@magmamath/react-native-ui'
|
|
4
4
|
|
|
5
5
|
type UnreadMessagesBadgeProps = {
|
|
6
6
|
badgeContent?: number
|
|
7
7
|
withBorder?: boolean
|
|
8
8
|
style?: StyleProp<ViewStyle>
|
|
9
|
+
textStyle?: StyleProp<TextStyle>
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export const UnreadMessagesBadge = ({ badgeContent, withBorder = false, style }: UnreadMessagesBadgeProps) => {
|
|
12
|
+
export const UnreadMessagesBadge = ({ badgeContent, withBorder = false, style, textStyle }: UnreadMessagesBadgeProps) => {
|
|
12
13
|
return (
|
|
13
14
|
<View
|
|
14
15
|
style={[
|
|
@@ -19,7 +20,7 @@ export const UnreadMessagesBadge = ({ badgeContent, withBorder = false, style }:
|
|
|
19
20
|
withBorder && (badgeContent ? styles.withBorderSize : styles.withBorderSizeEmpty),
|
|
20
21
|
]}
|
|
21
22
|
>
|
|
22
|
-
<Text style={styles.text}>{badgeContent && badgeContent > 99 ? '99+' : badgeContent}</Text>
|
|
23
|
+
<Text style={[styles.text, textStyle]}>{badgeContent && badgeContent > 99 ? '99+' : badgeContent}</Text>
|
|
23
24
|
</View>
|
|
24
25
|
)
|
|
25
26
|
}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { Platform } from 'react-native'
|
|
2
2
|
import { Locale } from './types/teacherFeedback.types'
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
export const NO_COMMENTS_ENG = 'No comments yet'
|
|
7
|
-
export const NO_COMMENTS_SWE = 'Inga kommentarer än'
|
|
4
|
+
export const TEACHER_FEEDBACK_BUTTON_ID = 'teacherFeedbackButton'
|
|
8
5
|
export const EMPTY_COMMENT_ID = 'empty-comment'
|
|
6
|
+
export const BUENOS_AIRES_FONT =
|
|
7
|
+
Platform.OS === 'web' ? 'Buenos Aires, sans-serif' : 'BuenosAires-Regular'
|
|
8
|
+
|
|
9
|
+
export const NO_COMMENTS_TRANSLATIONS: Record<Locale, string> = {
|
|
10
|
+
[Locale.SV]: 'Inga kommentarer än',
|
|
11
|
+
[Locale.GB]: 'No comments yet',
|
|
12
|
+
[Locale.US]: 'No comments yet',
|
|
13
|
+
}
|
|
9
14
|
|
|
10
15
|
export const getEmptyComment = (problemId: string, locale: Locale | null) => {
|
|
11
16
|
return {
|
|
12
17
|
__v: 0,
|
|
13
18
|
_id: EMPTY_COMMENT_ID,
|
|
14
|
-
content: locale
|
|
19
|
+
content: NO_COMMENTS_TRANSLATIONS[locale ?? Locale.US],
|
|
15
20
|
createdAt: new Date(),
|
|
16
21
|
exerciseId: '',
|
|
17
22
|
isRead: true,
|
|
@@ -22,3 +27,18 @@ export const getEmptyComment = (problemId: string, locale: Locale | null) => {
|
|
|
22
27
|
updatedAt: new Date(),
|
|
23
28
|
}
|
|
24
29
|
}
|
|
30
|
+
|
|
31
|
+
export enum FeedbackButtonColors {
|
|
32
|
+
BLUE = 'BLUE',
|
|
33
|
+
PURPLE = 'PURPLE',
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export enum FeedbackButtonSize {
|
|
37
|
+
SMALL = 'SMALL',
|
|
38
|
+
LARGE = 'LARGE',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export enum FeedbackMode {
|
|
42
|
+
SIMPLE = 'SIMPLE',
|
|
43
|
+
NORMAL = 'NORMAL',
|
|
44
|
+
}
|