@magmamath/students-features 0.2.9 → 0.2.11

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.
Files changed (163) hide show
  1. package/dist/commonjs/features/feedback/components/EmptyComment.js +4 -5
  2. package/dist/commonjs/features/feedback/components/EmptyComment.js.map +1 -1
  3. package/dist/commonjs/features/feedback/components/ListCardCommentsCount.js +1 -1
  4. package/dist/commonjs/features/feedback/components/TeacherFeedback.js +5 -6
  5. package/dist/commonjs/features/feedback/components/TeacherFeedback.js.map +1 -1
  6. package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +32 -9
  7. package/dist/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js.map +1 -1
  8. package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +1 -3
  9. package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
  10. package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js +1 -8
  11. package/dist/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js.map +1 -1
  12. package/dist/commonjs/features/feedback/constants.js +11 -3
  13. package/dist/commonjs/features/feedback/constants.js.map +1 -1
  14. package/dist/commonjs/features/feedback/helpers.js +24 -0
  15. package/dist/commonjs/features/feedback/helpers.js.map +1 -1
  16. package/dist/commonjs/features/feedback/model/api.js.map +1 -1
  17. package/dist/commonjs/features/feedback/model/comments.js +17 -33
  18. package/dist/commonjs/features/feedback/model/comments.js.map +1 -1
  19. package/dist/commonjs/features/feedback/model/model.js +5 -3
  20. package/dist/commonjs/features/feedback/model/model.js.map +1 -1
  21. package/dist/commonjs/features/feedback/types.js.map +1 -1
  22. package/dist/commonjs/lib/helpers/helpers.js +20 -16
  23. package/dist/commonjs/lib/helpers/helpers.js.map +1 -1
  24. package/dist/commonjs/lib/localization/en.json +12 -0
  25. package/dist/commonjs/lib/localization/gb.json +12 -0
  26. package/dist/commonjs/lib/localization/sw.json +12 -0
  27. package/dist/commonjs/shared/icons/MessageBubbleIcon.js.map +1 -0
  28. package/dist/commonjs/shared/icons/XCloseIcon.js.map +1 -0
  29. package/dist/commonjs/shared/translation/constants.js +1 -42
  30. package/dist/commonjs/shared/translation/constants.js.map +1 -1
  31. package/dist/commonjs/shared/translation/helpers.js.map +1 -1
  32. package/dist/commonjs/shared/translation/types.js.map +1 -1
  33. package/dist/module/features/feedback/components/EmptyComment.js +5 -6
  34. package/dist/module/features/feedback/components/EmptyComment.js.map +1 -1
  35. package/dist/module/features/feedback/components/ListCardCommentsCount.js +1 -1
  36. package/dist/module/features/feedback/components/ListCardCommentsCount.js.map +1 -1
  37. package/dist/module/features/feedback/components/TeacherFeedback.js +6 -7
  38. package/dist/module/features/feedback/components/TeacherFeedback.js.map +1 -1
  39. package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js +32 -9
  40. package/dist/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.js.map +1 -1
  41. package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js +1 -3
  42. package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.js.map +1 -1
  43. package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js +2 -9
  44. package/dist/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.js.map +1 -1
  45. package/dist/module/features/feedback/constants.js +10 -2
  46. package/dist/module/features/feedback/constants.js.map +1 -1
  47. package/dist/module/features/feedback/helpers.js +23 -0
  48. package/dist/module/features/feedback/helpers.js.map +1 -1
  49. package/dist/module/features/feedback/model/api.js.map +1 -1
  50. package/dist/module/features/feedback/model/comments.js +14 -30
  51. package/dist/module/features/feedback/model/comments.js.map +1 -1
  52. package/dist/module/features/feedback/model/model.js +6 -4
  53. package/dist/module/features/feedback/model/model.js.map +1 -1
  54. package/dist/module/features/feedback/types.js.map +1 -1
  55. package/dist/module/lib/helpers/helpers.js +20 -16
  56. package/dist/module/lib/helpers/helpers.js.map +1 -1
  57. package/dist/module/lib/localization/en.json +12 -0
  58. package/dist/module/lib/localization/gb.json +12 -0
  59. package/dist/module/lib/localization/sw.json +12 -0
  60. package/dist/module/shared/icons/MessageBubbleIcon.js.map +1 -0
  61. package/dist/module/shared/icons/XCloseIcon.js.map +1 -0
  62. package/dist/module/shared/translation/constants.js +0 -41
  63. package/dist/module/shared/translation/constants.js.map +1 -1
  64. package/dist/module/shared/translation/helpers.js.map +1 -1
  65. package/dist/module/shared/translation/types.js.map +1 -1
  66. package/dist/typescript/commonjs/features/feedback/components/EmptyComment.d.ts +1 -6
  67. package/dist/typescript/commonjs/features/feedback/components/EmptyComment.d.ts.map +1 -1
  68. package/dist/typescript/commonjs/features/feedback/components/TeacherFeedback.d.ts +5 -5
  69. package/dist/typescript/commonjs/features/feedback/components/TeacherFeedback.d.ts.map +1 -1
  70. package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts.map +1 -1
  71. package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts +2 -4
  72. package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts.map +1 -1
  73. package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts +2 -4
  74. package/dist/typescript/commonjs/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts.map +1 -1
  75. package/dist/typescript/commonjs/features/feedback/constants.d.ts +2 -2
  76. package/dist/typescript/commonjs/features/feedback/constants.d.ts.map +1 -1
  77. package/dist/typescript/commonjs/features/feedback/helpers.d.ts +10 -1
  78. package/dist/typescript/commonjs/features/feedback/helpers.d.ts.map +1 -1
  79. package/dist/typescript/commonjs/features/feedback/model/api.d.ts +6 -2
  80. package/dist/typescript/commonjs/features/feedback/model/api.d.ts.map +1 -1
  81. package/dist/typescript/commonjs/features/feedback/model/comments.d.ts +10 -12
  82. package/dist/typescript/commonjs/features/feedback/model/comments.d.ts.map +1 -1
  83. package/dist/typescript/commonjs/features/feedback/model/model.d.ts +4 -7
  84. package/dist/typescript/commonjs/features/feedback/model/model.d.ts.map +1 -1
  85. package/dist/typescript/commonjs/features/feedback/types.d.ts +8 -1
  86. package/dist/typescript/commonjs/features/feedback/types.d.ts.map +1 -1
  87. package/dist/typescript/commonjs/lib/helpers/helpers.d.ts +1 -2
  88. package/dist/typescript/commonjs/lib/helpers/helpers.d.ts.map +1 -1
  89. package/dist/typescript/commonjs/shared/icons/MessageBubbleIcon.d.ts.map +1 -0
  90. package/dist/typescript/commonjs/shared/icons/XCloseIcon.d.ts.map +1 -0
  91. package/dist/typescript/commonjs/shared/translation/constants.d.ts +38 -40
  92. package/dist/typescript/commonjs/shared/translation/constants.d.ts.map +1 -1
  93. package/dist/typescript/commonjs/shared/translation/helpers.d.ts.map +1 -1
  94. package/dist/typescript/commonjs/shared/translation/types.d.ts +4 -1
  95. package/dist/typescript/commonjs/shared/translation/types.d.ts.map +1 -1
  96. package/dist/typescript/module/features/feedback/components/EmptyComment.d.ts +1 -6
  97. package/dist/typescript/module/features/feedback/components/EmptyComment.d.ts.map +1 -1
  98. package/dist/typescript/module/features/feedback/components/TeacherFeedback.d.ts +5 -5
  99. package/dist/typescript/module/features/feedback/components/TeacherFeedback.d.ts.map +1 -1
  100. package/dist/typescript/module/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.d.ts.map +1 -1
  101. package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts +2 -4
  102. package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherComment.d.ts.map +1 -1
  103. package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts +2 -4
  104. package/dist/typescript/module/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.d.ts.map +1 -1
  105. package/dist/typescript/module/features/feedback/constants.d.ts +2 -2
  106. package/dist/typescript/module/features/feedback/constants.d.ts.map +1 -1
  107. package/dist/typescript/module/features/feedback/helpers.d.ts +10 -1
  108. package/dist/typescript/module/features/feedback/helpers.d.ts.map +1 -1
  109. package/dist/typescript/module/features/feedback/model/api.d.ts +6 -2
  110. package/dist/typescript/module/features/feedback/model/api.d.ts.map +1 -1
  111. package/dist/typescript/module/features/feedback/model/comments.d.ts +10 -12
  112. package/dist/typescript/module/features/feedback/model/comments.d.ts.map +1 -1
  113. package/dist/typescript/module/features/feedback/model/model.d.ts +4 -7
  114. package/dist/typescript/module/features/feedback/model/model.d.ts.map +1 -1
  115. package/dist/typescript/module/features/feedback/types.d.ts +8 -1
  116. package/dist/typescript/module/features/feedback/types.d.ts.map +1 -1
  117. package/dist/typescript/module/lib/helpers/helpers.d.ts +1 -2
  118. package/dist/typescript/module/lib/helpers/helpers.d.ts.map +1 -1
  119. package/dist/typescript/module/shared/icons/MessageBubbleIcon.d.ts.map +1 -0
  120. package/dist/typescript/module/shared/icons/XCloseIcon.d.ts.map +1 -0
  121. package/dist/typescript/module/shared/translation/constants.d.ts +38 -40
  122. package/dist/typescript/module/shared/translation/constants.d.ts.map +1 -1
  123. package/dist/typescript/module/shared/translation/helpers.d.ts.map +1 -1
  124. package/dist/typescript/module/shared/translation/types.d.ts +4 -1
  125. package/dist/typescript/module/shared/translation/types.d.ts.map +1 -1
  126. package/package.json +1 -1
  127. package/src/features/feedback/components/EmptyComment.tsx +5 -8
  128. package/src/features/feedback/components/ListCardCommentsCount.tsx +1 -1
  129. package/src/features/feedback/components/TeacherFeedback.tsx +7 -8
  130. package/src/features/feedback/components/TeacherFeedbackButton/TeacherFeedbackButton.tsx +30 -16
  131. package/src/features/feedback/components/TeacherFeedbackComments/TeacherComment.tsx +3 -5
  132. package/src/features/feedback/components/TeacherFeedbackComments/TeacherFeedbackComments.tsx +2 -10
  133. package/src/features/feedback/constants.ts +12 -3
  134. package/src/features/feedback/helpers.ts +31 -0
  135. package/src/features/feedback/model/api.ts +6 -2
  136. package/src/features/feedback/model/comments.ts +17 -39
  137. package/src/features/feedback/model/model.ts +8 -11
  138. package/src/features/feedback/types.ts +7 -1
  139. package/src/lib/helpers/helpers.ts +24 -16
  140. package/src/lib/localization/en.json +12 -0
  141. package/src/lib/localization/gb.json +12 -0
  142. package/src/lib/localization/sw.json +12 -0
  143. package/src/shared/translation/constants.ts +0 -42
  144. package/src/shared/translation/helpers.ts +17 -17
  145. package/src/shared/translation/types.ts +12 -4
  146. package/dist/commonjs/features/feedback/assets/icons/MessageBubbleIcon.js.map +0 -1
  147. package/dist/commonjs/features/feedback/assets/icons/XCloseIcon.js.map +0 -1
  148. package/dist/module/features/feedback/assets/icons/MessageBubbleIcon.js.map +0 -1
  149. package/dist/module/features/feedback/assets/icons/XCloseIcon.js.map +0 -1
  150. package/dist/typescript/commonjs/features/feedback/assets/icons/MessageBubbleIcon.d.ts.map +0 -1
  151. package/dist/typescript/commonjs/features/feedback/assets/icons/XCloseIcon.d.ts.map +0 -1
  152. package/dist/typescript/module/features/feedback/assets/icons/MessageBubbleIcon.d.ts.map +0 -1
  153. package/dist/typescript/module/features/feedback/assets/icons/XCloseIcon.d.ts.map +0 -1
  154. /package/dist/commonjs/{features/feedback/assets → shared}/icons/MessageBubbleIcon.js +0 -0
  155. /package/dist/commonjs/{features/feedback/assets → shared}/icons/XCloseIcon.js +0 -0
  156. /package/dist/module/{features/feedback/assets → shared}/icons/MessageBubbleIcon.js +0 -0
  157. /package/dist/module/{features/feedback/assets → shared}/icons/XCloseIcon.js +0 -0
  158. /package/dist/typescript/commonjs/{features/feedback/assets → shared}/icons/MessageBubbleIcon.d.ts +0 -0
  159. /package/dist/typescript/commonjs/{features/feedback/assets → shared}/icons/XCloseIcon.d.ts +0 -0
  160. /package/dist/typescript/module/{features/feedback/assets → shared}/icons/MessageBubbleIcon.d.ts +0 -0
  161. /package/dist/typescript/module/{features/feedback/assets → shared}/icons/XCloseIcon.d.ts +0 -0
  162. /package/src/{features/feedback/assets → shared}/icons/MessageBubbleIcon.tsx +0 -0
  163. /package/src/{features/feedback/assets → shared}/icons/XCloseIcon.tsx +0 -0
@@ -1,47 +1,45 @@
1
1
  export declare const LOCALIZATION_CONFIGS: {
2
- "en-SE": {};
3
- "en-GB": {};
4
- "sv-SE": {};
5
- };
6
- export declare const RELATIVE_TIME_LABELS: {
7
2
  "en-SE": {
8
- justNow: string;
9
- minuteAgo: string;
10
- minutesAgo: string;
11
- hourAgo: string;
12
- hoursAgo: string;
13
- dayAgo: string;
14
- daysAgo: string;
15
- monthAgo: string;
16
- monthsAgo: string;
17
- yearAgo: string;
18
- yearsAgo: string;
19
- };
20
- "sv-SE": {
21
- justNow: string;
22
- minuteAgo: string;
23
- minutesAgo: string;
24
- hourAgo: string;
25
- hoursAgo: string;
26
- dayAgo: string;
27
- daysAgo: string;
28
- monthAgo: string;
29
- monthsAgo: string;
30
- yearAgo: string;
31
- yearsAgo: string;
3
+ "teacherFeedback.noComments": string;
4
+ "time.justNow": string;
5
+ "time.minuteAgo": string;
6
+ "time.minutesAgo": string;
7
+ "time.hourAgo": string;
8
+ "time.hoursAgo": string;
9
+ "time.dayAgo": string;
10
+ "time.daysAgo": string;
11
+ "time.monthAgo": string;
12
+ "time.monthsAgo": string;
13
+ "time.yearAgo": string;
14
+ "time.yearsAgo": string;
32
15
  };
33
16
  "en-GB": {
34
- justNow: string;
35
- minuteAgo: string;
36
- minutesAgo: string;
37
- hourAgo: string;
38
- hoursAgo: string;
39
- dayAgo: string;
40
- daysAgo: string;
41
- monthAgo: string;
42
- monthsAgo: string;
43
- yearAgo: string;
44
- yearsAgo: string;
17
+ "teacherFeedback.noComments": string;
18
+ "time.justNow": string;
19
+ "time.minuteAgo": string;
20
+ "time.minutesAgo": string;
21
+ "time.hourAgo": string;
22
+ "time.hoursAgo": string;
23
+ "time.dayAgo": string;
24
+ "time.daysAgo": string;
25
+ "time.monthAgo": string;
26
+ "time.monthsAgo": string;
27
+ "time.yearAgo": string;
28
+ "time.yearsAgo": string;
29
+ };
30
+ "sv-SE": {
31
+ "teacherFeedback.noComments": string;
32
+ "time.justNow": string;
33
+ "time.minuteAgo": string;
34
+ "time.minutesAgo": string;
35
+ "time.hourAgo": string;
36
+ "time.hoursAgo": string;
37
+ "time.dayAgo": string;
38
+ "time.daysAgo": string;
39
+ "time.monthAgo": string;
40
+ "time.monthsAgo": string;
41
+ "time.yearAgo": string;
42
+ "time.yearsAgo": string;
45
43
  };
46
44
  };
47
45
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB;;;;CAIhC,CAAA;AAED,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChC,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIhC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAErD,eAAO,MAAM,oBAAoB,QAAS,MAAM,kBAAiB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAWtF,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,OAUrB,CAAA;AAED,eAAO,MAAM,uBAAuB,cACrB,CAAC,CAAC,MAAM,EAAE,OAAO,oBAAoB,KAAK,kBAAkB,CAAC,GAAG,kBAAkB,SAGhG,CAAA"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAmB,MAAM,SAAS,CAAA;AAEtE,eAAO,MAAM,oBAAoB,QAAS,MAAM,kBAAiB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAWtF,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,OAUrB,CAAA;AAED,eAAO,MAAM,uBAAuB,cACvB,CAAC,CAAC,MAAM,EAAE,OAAO,oBAAoB,KAAK,kBAAkB,CAAC,GAAG,kBAAkB,SAG9F,CAAA"}
@@ -1,4 +1,7 @@
1
- export type GetText = (key: string, args?: Record<string, string> | null) => string;
1
+ import enTranslations from '../../lib/localization/en.json';
2
+ export type Translations = typeof enTranslations;
3
+ export type TranslationKeys = keyof Translations;
4
+ export type GetText = <T extends TranslationKeys>(key: T, args?: Record<string, string> | null) => Translations[T];
2
5
  export declare enum Locale {
3
6
  EN = "en-SE",
4
7
  SW = "sv-SE",
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,KAAK,MAAM,CAAA;AAEnF,oBAAY,MAAM;IACd,EAAE,UAAU;IACZ,EAAE,UAAU;IACZ,EAAE,UAAU;CACf;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/shared/translation/types.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,gCAAgC,CAAA;AAE3D,MAAM,MAAM,YAAY,GAAG,OAAO,cAAc,CAAA;AAChD,MAAM,MAAM,eAAe,GAAG,MAAM,YAAY,CAAA;AAEhD,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,SAAS,eAAe,EAC9C,GAAG,EAAE,CAAC,EACN,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,KACjC,YAAY,CAAC,CAAC,CAAC,CAAA;AAEpB,oBAAY,MAAM;IAChB,EAAE,UAAU;IACZ,EAAE,UAAU;IACZ,EAAE,UAAU;CACb;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magmamath/students-features",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Magmamath features library",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/commonjs/index.js",
@@ -1,17 +1,14 @@
1
1
  import React from 'react'
2
2
  import { StyleSheet, Text, View } from 'react-native'
3
3
  import { COLORS } from '@magmamath/react-native-ui'
4
- import { BUENOS_AIRES_FONT, NO_COMMENTS_SWE, NO_COMMENTS_ENG } from '../constants'
5
- import { Locale } from '../../../shared/translation/types'
4
+ import { BUENOS_AIRES_FONT } from '../constants'
5
+ import { useText } from '../../../shared/translation'
6
6
 
7
- type EmptyCommentProps = {
8
- locale: Locale | null
9
- }
10
-
11
- export const EmptyComment = ({ locale }: EmptyCommentProps) => {
7
+ export const EmptyComment = () => {
8
+ const t = useText()
12
9
  return (
13
10
  <View style={styles.container}>
14
- <Text style={styles.text}>{locale === Locale.SW ? NO_COMMENTS_SWE : NO_COMMENTS_ENG}</Text>
11
+ <Text style={styles.text}>{t('teacherFeedback.noComments')}</Text>
15
12
  </View>
16
13
  )
17
14
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { Text, View, StyleSheet } from 'react-native'
3
- import { MessageBubbleIcon } from '../assets/icons/MessageBubbleIcon'
3
+ import { MessageBubbleIcon } from '../../../shared/icons/MessageBubbleIcon'
4
4
  import { COLORS } from '@magmamath/react-native-ui'
5
5
  import { BUENOS_AIRES_FONT } from '../constants'
6
6
 
@@ -5,15 +5,15 @@ import { TeacherFeedbackButton } from './TeacherFeedbackButton/TeacherFeedbackBu
5
5
  import { TeacherFeedbackComments } from './TeacherFeedbackComments/TeacherFeedbackComments'
6
6
  import { FeedbackButtonColors, FeedbackButtonSize, FeedbackMode } from '../constants'
7
7
  import { TeacherFeedbackModel } from '../model/model'
8
- import { Locale } from '../../../shared/translation'
9
8
 
10
9
  type TeacherFeedbackProps = {
11
10
  model: TeacherFeedbackModel
12
11
  mode: FeedbackMode
13
- locale: Locale
14
12
  assignmentId: string
15
13
  problemId: string
16
- color: FeedbackButtonColors
14
+ color?: FeedbackButtonColors
15
+ size?: FeedbackButtonSize
16
+ heightOffset?: number
17
17
  }
18
18
 
19
19
  export const TeacherFeedback = ({
@@ -21,8 +21,9 @@ export const TeacherFeedback = ({
21
21
  mode,
22
22
  assignmentId,
23
23
  problemId,
24
- locale,
25
24
  color = FeedbackButtonColors.BLUE,
25
+ size = FeedbackButtonSize.SMALL,
26
+ heightOffset = 0,
26
27
  }: TeacherFeedbackProps) => {
27
28
  const isOpen = useUnit(model.$isOpen)
28
29
  const isLoading = useUnit(model.api.getCommentsFx.pending)
@@ -31,7 +32,6 @@ export const TeacherFeedback = ({
31
32
  fn: (feedback, [assignmentId, problemId]) => feedback?.get(assignmentId)?.[problemId] ?? null,
32
33
  keys: [assignmentId, problemId],
33
34
  })
34
- const isSimpleMode = mode === FeedbackMode.SIMPLE
35
35
 
36
36
  if (!problemId || !teacherFeedback) return null
37
37
 
@@ -40,9 +40,8 @@ export const TeacherFeedback = ({
40
40
  {isOpen && (
41
41
  <TeacherFeedbackComments
42
42
  comments={teacherFeedback.comments}
43
- locale={locale}
44
43
  mode={mode}
45
- maxHeightOffset={isSimpleMode ? 70 : 0}
44
+ maxHeightOffset={heightOffset}
46
45
  />
47
46
  )}
48
47
  <TeacherFeedbackButton
@@ -50,7 +49,7 @@ export const TeacherFeedback = ({
50
49
  unreadCommentsCount={teacherFeedback.unreadMessagesCount}
51
50
  isOpen={isOpen}
52
51
  isLoading={isLoading}
53
- size={isSimpleMode ? FeedbackButtonSize.LARGE : FeedbackButtonSize.SMALL}
52
+ size={size}
54
53
  color={color}
55
54
  />
56
55
  </View>
@@ -2,8 +2,8 @@ import React from 'react'
2
2
  import { StyleSheet, View } from 'react-native'
3
3
  import { Button, COLORS } from '@magmamath/react-native-ui'
4
4
  import { UnreadMessagesBadge } from '../UnreadMessagesBadge'
5
- import { MessageBubbleIcon } from '../../assets/icons/MessageBubbleIcon'
6
- import { XCloseIcon } from '../../assets/icons/XCloseIcon'
5
+ import { MessageBubbleIcon } from '../../../../shared/icons/MessageBubbleIcon'
6
+ import { XCloseIcon } from '../../../../shared/icons/XCloseIcon'
7
7
  import { COLOR_SCHEMES } from './colorSchemes'
8
8
  import {
9
9
  FeedbackButtonColors,
@@ -16,6 +16,26 @@ const ICON_SIZES = {
16
16
  [FeedbackButtonSize.SMALL]: 26,
17
17
  }
18
18
 
19
+ const COLOR_PRESETS = {
20
+ [FeedbackButtonColors.PURPLE]: {
21
+ borderColor: COLORS.PURPLE_6,
22
+ schemeColor: COLOR_SCHEMES.PURPLE,
23
+ },
24
+ [FeedbackButtonColors.BLUE]: {
25
+ borderColor: COLORS.BLUE_6,
26
+ schemeColor: COLOR_SCHEMES.BLUE,
27
+ },
28
+ }
29
+
30
+ const getVariantStyles = (isUnread: boolean, color: FeedbackButtonColors) => {
31
+ const { borderColor, schemeColor } = COLOR_PRESETS[color]
32
+ return {
33
+ iconColor: isUnread ? COLORS.NEUTRAL_1 : COLORS.NEUTRAL_9,
34
+ customColorScheme: isUnread ? schemeColor : COLOR_SCHEMES.GREY,
35
+ borderColor: isUnread ? borderColor : COLORS.NEUTRAL_5,
36
+ }
37
+ }
38
+
19
39
  type TeacherFeedbackButtonProps = {
20
40
  isOpen: boolean
21
41
  isLoading: boolean
@@ -34,9 +54,10 @@ export const TeacherFeedbackButton = ({
34
54
  color = FeedbackButtonColors.BLUE,
35
55
  }: TeacherFeedbackButtonProps) => {
36
56
  const isLarge = size === FeedbackButtonSize.LARGE
37
- const isPurpleColor = color === FeedbackButtonColors.PURPLE
38
- const borderColor = isPurpleColor ? COLORS.PURPLE_6 : COLORS.BLUE_6
39
- const schemeColor = isPurpleColor ? COLOR_SCHEMES.PURPLE : COLOR_SCHEMES.BLUE
57
+ const { borderColor, iconColor, customColorScheme } = getVariantStyles(
58
+ !!unreadCommentsCount,
59
+ color,
60
+ )
40
61
 
41
62
  if (isOpen) {
42
63
  return (
@@ -67,20 +88,13 @@ export const TeacherFeedbackButton = ({
67
88
  isLoading={isLoading}
68
89
  style={{
69
90
  container: isLarge ? styles.containerLarge : styles.container,
70
- button: [
71
- styles.button,
72
- { borderColor: !!unreadCommentsCount ? borderColor : COLORS.NEUTRAL_5 },
73
- styles[size],
74
- ],
91
+ button: [styles.button, { borderColor }, styles[size]],
75
92
  }}
76
- customColorScheme={!!unreadCommentsCount ? schemeColor : COLOR_SCHEMES.GREY}
93
+ customColorScheme={customColorScheme}
77
94
  icon={
78
95
  <View style={styles.iconContainer}>
79
- <MessageBubbleIcon
80
- color={!!unreadCommentsCount ? COLORS.NEUTRAL_1 : COLORS.NEUTRAL_9}
81
- size={ICON_SIZES[size]}
82
- />
83
- {!!unreadCommentsCount && (
96
+ <MessageBubbleIcon color={iconColor} size={ICON_SIZES[size]} />
97
+ {unreadCommentsCount && (
84
98
  <View style={isLarge ? styles.badgeContainerLarge : styles.badgeContainer}>
85
99
  <UnreadMessagesBadge
86
100
  badgeContent={unreadCommentsCount}
@@ -4,15 +4,13 @@ import { COLORS } from '@magmamath/react-native-ui'
4
4
  import { BUENOS_AIRES_FONT } from '../../constants'
5
5
  import { getRelativeTimeText } from '../../../../lib/helpers/helpers'
6
6
  import { TeacherComment as TeacherCommentEntity } from '../../types'
7
- import { Locale } from '../../../../shared/translation/types'
8
7
 
9
8
  type TeacherCommentProps = {
10
9
  comment: TeacherCommentEntity
11
- locale: Locale | null
12
- style: StyleProp<ViewStyle>
10
+ style?: StyleProp<ViewStyle>
13
11
  }
14
12
 
15
- export const TeacherComment = ({ comment, locale, style }: TeacherCommentProps) => {
13
+ export const TeacherComment = ({ comment, style }: TeacherCommentProps) => {
16
14
  return (
17
15
  <View style={style}>
18
16
  <View style={styles.authorInfo}>
@@ -21,7 +19,7 @@ export const TeacherComment = ({ comment, locale, style }: TeacherCommentProps)
21
19
  </Text>
22
20
  <View style={styles.spacer} />
23
21
  <Text style={styles.dateAdded} numberOfLines={1}>
24
- {getRelativeTimeText(comment.createdAt, locale ?? Locale.EN)}
22
+ {getRelativeTimeText(comment.createdAt)}
25
23
  </Text>
26
24
  </View>
27
25
 
@@ -4,7 +4,6 @@ import { TeacherComment } from './TeacherComment'
4
4
  import { EmptyComment } from '../EmptyComment'
5
5
  import { EMPTY_COMMENT_ID, FeedbackMode } from '../../constants'
6
6
  import { COLORS } from '@magmamath/react-native-ui'
7
- import { Locale } from '../../../../shared/translation'
8
7
  import { TeacherComment as TeacherCommentEntity } from '../../types'
9
8
 
10
9
  const TOOLBAR_HEIGHT = 140
@@ -14,29 +13,23 @@ const BOTTOM_OFFSET = Platform.select({
14
13
  })
15
14
 
16
15
  type TeacherFeedbackCommentsProps = {
17
- comments: TeacherCommentEntity[] | null
18
- locale: Locale | null
16
+ comments: TeacherCommentEntity[]
19
17
  mode: FeedbackMode
20
18
  maxHeightOffset: number
21
19
  }
22
20
 
23
21
  export const TeacherFeedbackComments = ({
24
22
  comments,
25
- locale,
26
- mode,
27
23
  maxHeightOffset,
28
24
  }: TeacherFeedbackCommentsProps) => {
29
25
  const ref = useRef<ScrollView | null>(null)
30
26
  const dimensions = useWindowDimensions()
31
27
  const MAX_HEIGHT = dimensions.height - TOOLBAR_HEIGHT - BOTTOM_OFFSET
32
- const isSimpleMode = mode === FeedbackMode.SIMPLE
33
28
 
34
29
  useEffect(() => {
35
30
  ref.current?.scrollToEnd({ animated: false })
36
31
  }, [])
37
32
 
38
- if (!comments) return null
39
-
40
33
  return (
41
34
  <View style={[styles.container, { maxHeight: MAX_HEIGHT - maxHeightOffset }]}>
42
35
  <ScrollView
@@ -45,13 +38,12 @@ export const TeacherFeedbackComments = ({
45
38
  onContentSizeChange={() => ref.current?.scrollToEnd()}
46
39
  >
47
40
  {comments.length === 1 && comments[0]._id === EMPTY_COMMENT_ID ? (
48
- <EmptyComment locale={locale} />
41
+ <EmptyComment />
49
42
  ) : (
50
43
  comments.map((comment, index) => (
51
44
  <TeacherComment
52
45
  key={comment._id}
53
46
  comment={comment}
54
- locale={locale}
55
47
  style={{ marginBottom: index === comments.length - 1 ? 8 : 0 }}
56
48
  />
57
49
  ))
@@ -1,12 +1,10 @@
1
1
  import { Platform } from 'react-native'
2
+ import { NoCommentsMessage } from './types'
2
3
 
3
4
  export const BUENOS_AIRES_FONT =
4
5
  Platform.OS === 'web' ? 'Buenos Aires, sans-serif' : 'BuenosAires-Regular'
5
6
 
6
- export const NO_COMMENTS_ENG = 'No comments yet'
7
- export const NO_COMMENTS_SWE = 'Inga kommentarer än'
8
7
  export const EMPTY_COMMENT_ID = 'empty-comment'
9
-
10
8
  export const TEACHER_FEEDBACK_BUTTON_ID = 'teacherFeedbackButton'
11
9
 
12
10
  export enum FeedbackButtonColors {
@@ -23,3 +21,14 @@ export enum FeedbackMode {
23
21
  SIMPLE = 'SIMPLE',
24
22
  NORMAL = 'NORMAL',
25
23
  }
24
+
25
+ export const EMPTY_COMMENT: NoCommentsMessage = {
26
+ __v: 0,
27
+ _id: EMPTY_COMMENT_ID,
28
+ createdAt: new Date(),
29
+ isRead: true,
30
+ studentId: '',
31
+ teacherId: '',
32
+ teacherName: '',
33
+ updatedAt: new Date(),
34
+ } as const
@@ -31,3 +31,34 @@ export function findCommentsByCredits({
31
31
  }: FindCommentsByCreditsProps) {
32
32
  return data?.get(assignmentId)?.[problemId]?.comments ?? []
33
33
  }
34
+
35
+ type UpdateCommentsStateProps = {
36
+ state: CommentsMap | null
37
+ assignmentId: string
38
+ problemId: string
39
+ fn: (data: FeedbackEntity) => FeedbackEntity | undefined
40
+ }
41
+
42
+ export function updateCommentsState({
43
+ state,
44
+ assignmentId,
45
+ problemId,
46
+ fn,
47
+ }: UpdateCommentsStateProps) {
48
+ if (!state) return state
49
+
50
+ const updatedState = new Map(state)
51
+ const assignmentMap = updatedState.get(assignmentId) || {}
52
+ const currentData = assignmentMap[problemId] || { comments: [], unreadMessagesCount: 0 }
53
+ const updatedData = fn(currentData)
54
+
55
+ if (updatedData === undefined) {
56
+ delete assignmentMap[problemId]
57
+ if (Object.keys(assignmentMap).length === 0) updatedState.delete(assignmentId)
58
+ return updatedState
59
+ }
60
+
61
+ assignmentMap[problemId] = updatedData
62
+ updatedState.set(assignmentId, assignmentMap)
63
+ return updatedState
64
+ }
@@ -1,12 +1,16 @@
1
1
  import { createEffect, Effect } from 'effector'
2
- import { TeacherFeedbackModelProps } from './model'
3
2
  import { GetCommentsPayload, GetCommentsResponse, UpdateCommentStatusSeenPayload } from '../types'
4
3
 
4
+ type TeacherFeedbackAPIProps = {
5
+ getComments: (props: GetCommentsPayload) => Promise<GetCommentsResponse>
6
+ updateCommentStatusSeen: (props: UpdateCommentStatusSeenPayload) => Promise<void>
7
+ }
8
+
5
9
  export class TeacherFeedbackAPI {
6
10
  public readonly getCommentsFx: Effect<GetCommentsPayload, GetCommentsResponse>
7
11
  public readonly updateCommentStatusSeenFx: Effect<UpdateCommentStatusSeenPayload, void>
8
12
 
9
- constructor(api: TeacherFeedbackModelProps['api']) {
13
+ constructor(api: TeacherFeedbackAPIProps) {
10
14
  this.getCommentsFx = createEffect(api.getComments)
11
15
  this.updateCommentStatusSeenFx = createEffect(api.updateCommentStatusSeen)
12
16
  }
@@ -1,25 +1,25 @@
1
1
  import { createEvent, restore, sample, Store } from 'effector'
2
- import { CommentsMap, Credits, FeedbackEntity, TeacherComment } from '../types'
2
+ import { AddCommentProps, CommentsMap, Credits, DeleteCommentProps, TeacherComment } from '../types'
3
3
  import { TeacherFeedbackAPI } from './api'
4
- import { TeacherFeedbackModelProps } from './model'
4
+ import { updateCommentsState } from '../helpers'
5
+ import { getText } from '../../../shared/translation/helpers'
6
+ import { EMPTY_COMMENT } from '@magmamath/students-features'
5
7
 
6
- type UpdateProps = {
7
- state: CommentsMap | null
8
- assignmentId: string
9
- problemId: string
10
- fn: (data: FeedbackEntity) => FeedbackEntity | undefined
8
+ type TeacherCommentsModelProps = {
9
+ api: TeacherFeedbackAPI
10
+ $isOpen: Store<boolean>
11
11
  }
12
12
 
13
- export class TeacherComments {
13
+ export class TeacherCommentsModel {
14
14
  private readonly setNoCommentsMessage = createEvent<TeacherComment>()
15
15
  public readonly setAllCommentsRead = createEvent<Credits>()
16
- public readonly add = createEvent<Credits & { comment: TeacherComment; isRead: boolean }>()
17
- public readonly delete = createEvent<Credits & { commentId: string }>()
16
+ public readonly add = createEvent<AddCommentProps>()
17
+ public readonly delete = createEvent<DeleteCommentProps>()
18
18
 
19
19
  public readonly setData = createEvent<CommentsMap>()
20
20
  public readonly $data = restore<CommentsMap | null>(this.setData, null)
21
21
  .on(this.setAllCommentsRead, (state, { assignmentId, problemId }) =>
22
- this.update({
22
+ updateCommentsState({
23
23
  state,
24
24
  assignmentId,
25
25
  problemId,
@@ -30,7 +30,7 @@ export class TeacherComments {
30
30
  }),
31
31
  )
32
32
  .on(this.add, (state, { assignmentId, problemId, comment, isRead }) =>
33
- this.update({
33
+ updateCommentsState({
34
34
  state,
35
35
  assignmentId,
36
36
  problemId,
@@ -41,7 +41,7 @@ export class TeacherComments {
41
41
  }),
42
42
  )
43
43
  .on(this.delete, (state, { assignmentId, problemId, commentId }) =>
44
- this.update({
44
+ updateCommentsState({
45
45
  state,
46
46
  assignmentId,
47
47
  problemId,
@@ -62,7 +62,7 @@ export class TeacherComments {
62
62
  }),
63
63
  )
64
64
  .on(this.setNoCommentsMessage, (state, noCommentsMessage) =>
65
- this.update({
65
+ updateCommentsState({
66
66
  state,
67
67
  assignmentId: noCommentsMessage.exerciseId,
68
68
  problemId: noCommentsMessage.problemId,
@@ -73,11 +73,7 @@ export class TeacherComments {
73
73
  }),
74
74
  )
75
75
 
76
- constructor(
77
- api: TeacherFeedbackAPI,
78
- $isOpen: Store<boolean>,
79
- EMPTY_COMMENT: TeacherFeedbackModelProps['defaults']['EMPTY_COMMENT'],
80
- ) {
76
+ constructor({ api, $isOpen }: TeacherCommentsModelProps) {
81
77
  sample({
82
78
  clock: this.add,
83
79
  source: { isOpen: $isOpen },
@@ -97,31 +93,13 @@ export class TeacherComments {
97
93
  ?.comments.length
98
94
  return isOpen && hasNoMessages
99
95
  },
100
- fn: (_, { assignmentId, problemId }) => ({
96
+ fn: (_, { assignmentId, problemId }): TeacherComment => ({
101
97
  ...EMPTY_COMMENT,
102
98
  exerciseId: assignmentId,
103
99
  problemId,
100
+ content: getText('teacherFeedback.noComments'),
104
101
  }),
105
102
  target: this.setNoCommentsMessage,
106
103
  })
107
104
  }
108
-
109
- private update({ state, assignmentId, problemId, fn }: UpdateProps) {
110
- if (!state) return state
111
-
112
- const updatedState = new Map(state)
113
- const assignmentMap = updatedState.get(assignmentId) || {}
114
- const currentData = assignmentMap[problemId] || { comments: [], unreadMessagesCount: 0 }
115
- const updatedData = fn(currentData)
116
-
117
- if (updatedData === undefined) {
118
- delete assignmentMap[problemId]
119
- if (Object.keys(assignmentMap).length === 0) updatedState.delete(assignmentId)
120
- return updatedState
121
- }
122
-
123
- assignmentMap[problemId] = updatedData
124
- updatedState.set(assignmentId, assignmentMap)
125
- return updatedState
126
- }
127
105
  }
@@ -1,14 +1,9 @@
1
1
  import { createEvent, restore, sample, Store } from 'effector'
2
2
  import { TeacherFeedbackAPI } from './api'
3
3
  import { TeacherFeedbackSockets } from './sockets'
4
- import { TeacherComments } from './comments'
4
+ import { TeacherCommentsModel } from './comments'
5
5
  import { findCommentsByCredits, generateCommentsMap } from '../helpers'
6
- import {
7
- GetCommentsPayload,
8
- GetCommentsResponse,
9
- NoCommentsMessage,
10
- UpdateCommentStatusSeenPayload,
11
- } from '../types'
6
+ import { GetCommentsPayload, GetCommentsResponse, UpdateCommentStatusSeenPayload } from '../types'
12
7
  import { EMPTY_COMMENT_ID } from '../constants'
13
8
 
14
9
  export type TeacherFeedbackModelProps = {
@@ -21,23 +16,25 @@ export type TeacherFeedbackModelProps = {
21
16
  $assignmentId: Store<string>
22
17
  $problemId: Store<string>
23
18
  }
24
- defaults: { EMPTY_COMMENT: NoCommentsMessage }
25
19
  }
26
20
 
27
21
  export class TeacherFeedbackModel {
28
22
  public readonly sockets: TeacherFeedbackSockets
29
23
  public readonly api: TeacherFeedbackAPI
30
- public readonly comments: TeacherComments
24
+ public readonly comments: TeacherCommentsModel
31
25
  public readonly setIsOpen = createEvent<boolean>()
32
26
  public readonly $isOpen = restore(this.setIsOpen, false)
33
27
 
34
28
  public readonly setIsFeedbackIconDisplayed = createEvent<boolean>()
35
29
  public readonly $isFeedbackIconDisplayed = restore(this.setIsFeedbackIconDisplayed, true)
36
30
 
37
- constructor({ api, socket, credits, defaults }: TeacherFeedbackModelProps) {
31
+ constructor({ api, socket, credits }: TeacherFeedbackModelProps) {
38
32
  this.api = new TeacherFeedbackAPI(api)
39
33
  this.sockets = new TeacherFeedbackSockets(socket)
40
- this.comments = new TeacherComments(this.api, this.$isOpen, defaults.EMPTY_COMMENT)
34
+ this.comments = new TeacherCommentsModel({
35
+ api: this.api,
36
+ $isOpen: this.$isOpen,
37
+ })
41
38
 
42
39
  sample({
43
40
  clock: credits.$problemId,
@@ -26,7 +26,10 @@ export type TeacherComment = {
26
26
  __v: number
27
27
  }
28
28
 
29
- export type NoCommentsMessage = Omit<TeacherComment, '_id' | 'problemId' | 'exerciseId'> & {
29
+ export type NoCommentsMessage = Omit<
30
+ TeacherComment,
31
+ '_id' | 'problemId' | 'exerciseId' | 'content'
32
+ > & {
30
33
  _id: typeof EMPTY_COMMENT_ID
31
34
  }
32
35
 
@@ -46,3 +49,6 @@ export enum FeedbackSocketEvents {
46
49
  COMMENT_ADDED = 'exerciseCommentCreated',
47
50
  COMMENT_DELETED = 'exerciseCommentDeleted',
48
51
  }
52
+
53
+ export type AddCommentProps = Credits & { comment: TeacherComment; isRead: boolean }
54
+ export type DeleteCommentProps = Credits & { commentId: string }